mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 876761 - Mirror moznetwork and mozcrash to m-c, r=jhammel
This commit is contained in:
parent
ee120a4e32
commit
8d74610e77
@ -125,6 +125,15 @@ def check_for_crashes(dump_directory, symbols_path,
|
||||
if dump_save_path is None:
|
||||
dump_save_path = os.environ.get('MINIDUMP_SAVE_PATH', None)
|
||||
if dump_save_path:
|
||||
# This code did not previously create the directory,
|
||||
# so there may be a file hanging out with its name.
|
||||
if os.path.isfile(dump_save_path):
|
||||
os.unlink(dump_save_path)
|
||||
if not os.path.isdir(dump_save_path):
|
||||
try:
|
||||
os.makedirs(dump_save_path)
|
||||
except OSError:
|
||||
pass
|
||||
shutil.move(d, dump_save_path)
|
||||
log.info("Saved dump as %s", os.path.join(dump_save_path,
|
||||
os.path.basename(d)))
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
PACKAGE_VERSION = '0.5'
|
||||
PACKAGE_VERSION = '0.6'
|
||||
|
||||
# dependencies
|
||||
deps = ['mozfile >= 0.3',
|
||||
|
@ -92,6 +92,34 @@ class TestCrash(unittest.TestCase):
|
||||
dump_save_path=save_path))
|
||||
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
|
||||
|
||||
def test_save_path_not_present(self):
|
||||
"""
|
||||
Test that dump_save_path works when the directory doesn't exist.
|
||||
"""
|
||||
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
|
||||
save_path = os.path.join(self.tempdir, "saved")
|
||||
self.stdouts.append(["this is some output"])
|
||||
self.assert_(mozcrash.check_for_crashes(self.tempdir,
|
||||
'symbols_path',
|
||||
stackwalk_binary=self.stackwalk,
|
||||
dump_save_path=save_path))
|
||||
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
|
||||
|
||||
def test_save_path_isfile(self):
|
||||
"""
|
||||
Test that dump_save_path works when the directory doesn't exist,
|
||||
but a file with the same name exists.
|
||||
"""
|
||||
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
|
||||
save_path = os.path.join(self.tempdir, "saved")
|
||||
open(save_path, "w").write("junk")
|
||||
self.stdouts.append(["this is some output"])
|
||||
self.assert_(mozcrash.check_for_crashes(self.tempdir,
|
||||
'symbols_path',
|
||||
stackwalk_binary=self.stackwalk,
|
||||
dump_save_path=save_path))
|
||||
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
|
||||
|
||||
def test_save_path_envvar(self):
|
||||
"""
|
||||
Test that the MINDUMP_SAVE_PATH environment variable works.
|
||||
|
5
testing/mozbase/moznetwork/moznetwork/__init__.py
Normal file
5
testing/mozbase/moznetwork/moznetwork/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from moznetwork import *
|
71
testing/mozbase/moznetwork/moznetwork/moznetwork.py
Normal file
71
testing/mozbase/moznetwork/moznetwork/moznetwork.py
Normal file
@ -0,0 +1,71 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os
|
||||
import socket
|
||||
import array
|
||||
import struct
|
||||
if os.name != 'nt':
|
||||
import fcntl
|
||||
|
||||
|
||||
class NetworkError(Exception):
|
||||
"""Unable to obtain interface or IP"""
|
||||
|
||||
|
||||
def _get_interface_list():
|
||||
"""Provides a list of available network interfaces
|
||||
as a list of tuples (name, ip)"""
|
||||
max_iface = 32 # Maximum number of interfaces(Aribtrary)
|
||||
bytes = max_iface * 32
|
||||
is_32bit = (8 * struct.calcsize("P")) == 32 # Set Architecture
|
||||
struct_size = 32 if is_32bit else 40
|
||||
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
names = array.array('B', '\0' * bytes)
|
||||
outbytes = struct.unpack('iL', fcntl.ioctl(
|
||||
s.fileno(),
|
||||
0x8912, # SIOCGIFCONF
|
||||
struct.pack('iL', bytes, names.buffer_info()[0])
|
||||
))[0]
|
||||
namestr = names.tostring()
|
||||
return [(namestr[i:i + 32].split('\0', 1)[0],
|
||||
socket.inet_ntoa(namestr[i + 20:i + 24]))\
|
||||
for i in range(0, outbytes, struct_size)]
|
||||
|
||||
except IOError:
|
||||
raise NetworkError('Unable to call ioctl with SIOCGIFCONF')
|
||||
|
||||
|
||||
def get_ip():
|
||||
"""Provides an available network interface address. A
|
||||
NetworkError exception is raised in case of failure."""
|
||||
try:
|
||||
try:
|
||||
ip = socket.gethostbyname(socket.gethostname())
|
||||
except socket.gaierror: # for Mac OS X
|
||||
ip = socket.gethostbyname(socket.gethostname() + ".local")
|
||||
except socket.gaierror:
|
||||
# sometimes the hostname doesn't resolve to an ip address, in which
|
||||
# case this will always fail
|
||||
ip = None
|
||||
|
||||
if (ip is None or ip.startswith("127.")) and os.name != "nt":
|
||||
interfaces = _get_interface_list()
|
||||
for ifconfig in interfaces:
|
||||
if ifconfig[0] == 'lo':
|
||||
continue
|
||||
else:
|
||||
return ifconfig[1]
|
||||
|
||||
if ip is None:
|
||||
raise NetworkError('Unable to obtain network address')
|
||||
|
||||
return ip
|
||||
|
||||
|
||||
def get_lan_ip():
|
||||
"""Deprecated. Please use get_ip() instead."""
|
||||
return get_ip()
|
25
testing/mozbase/moznetwork/setup.py
Normal file
25
testing/mozbase/moznetwork/setup.py
Normal file
@ -0,0 +1,25 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
PACKAGE_VERSION = '0.21'
|
||||
|
||||
deps=[]
|
||||
|
||||
setup(name='moznetwork',
|
||||
version=PACKAGE_VERSION,
|
||||
description="Library of network utilities for use in Mozilla testing",
|
||||
long_description="see http://mozbase.readthedocs.org/",
|
||||
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
keywords='mozilla',
|
||||
author='Mozilla Automation and Tools team',
|
||||
author_email='tools@lists.mozilla.org',
|
||||
url='https://wiki.mozilla.org/Auto-tools/Projects/MozBase',
|
||||
license='MPL',
|
||||
packages=['moznetwork'],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=deps
|
||||
)
|
Loading…
Reference in New Issue
Block a user