rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def makeGlossBox(parent, gloss, child=False): box = wx.BoxSizer(wx.VERTICAL) tb = GlossButton(self, -1, u'{0} ({1})\n{2}'.format(gloss.form, '/'.join(gloss.ps), gloss.gloss)) tb.Bind(wx.EVT_TOGGLEBUTTON, tb.onToggled) box.Add(tb, 0) if gloss.morphemes: morphemes = wx.BoxSizer(wx.HORIZONTAL) for morph in gloss.m...
def makeGlossItem(parent, text): text = wx.StaticText(parent, -1, text) text.SetFont(wx.Font(18, None, None, None)) return text
box.Add(gbox, 0, wx.SUNKEN_BORDER)
box.Add(gbox, 0, wx.TOP | wx.BOTTOM, 4)
def makeGlossSizer(parent, glosslist): if self.vertical: box = wx.BoxSizer(wx.HORIZONTAL) else: box = wx.BoxSizer(wx.VERTICAL) for gloss in glosslist: gbox = GlossButton(parent, gloss) box.Add(gbox, 0, wx.SUNKEN_BORDER) #box.Add(wx.StaticLine(self, wx.HORIZONTAL), 0, wx.EXPAND) return box
self.SetAutoLayout(1) self.Sizer.Fit(self) self.Show()
self.parent.OnUpdate()
def makeSent(parent, text): return wx.StaticText(parent, -1, text)
Sizer = wx.BoxSizer(wx.HORIZONTAL) Sizer.Add(self.sentpanel, 2, wx.EXPAND) Sizer.Add(self.filepanel, 1, wx.EXPAND) self.SetSizer(Sizer) self.Fit()
self.Sizer = wx.BoxSizer(wx.HORIZONTAL) self.Sizer.Add(self.sentpanel, 2, wx.EXPAND) self.Sizer.Add(self.filepanel, 1, wx.EXPAND) self.SetSizer(self.Sizer) self.Show() def OnUpdate(self): self.SetSizerAndFit(self.Sizer)
def __init__(self, parent, *args, **kwargs): wx.Frame.__init__(self, parent, *args, **kwargs)
directives += " -C \"TypesConfig " + os.path.join("/etc", "mime.types") + "\""
directives += " -C \"TypesConfig " + \ os.path.join(android_tree_root, http_conf_path, "mime.types") + "\""
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] # Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") re...
cmd_template = export_envvars_cmd + " && " + apache2_restart_template + directives + conf_file_cmd
def main(options, args): if len(args) < 1: run_cmd = "" else: run_cmd = args[0] # Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart...
execute_cmd(cmd_template % ('stop'))
execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % ('stop')) + directives + conf_file_cmd)
def main(options, args): if len(args) < 1: run_cmd = "" else: run_cmd = args[0] # Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart...
execute_cmd(cmd_template % (run_cmd))
execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % (run_cmd)) + directives + conf_file_cmd)
def main(options, args): if len(args) < 1: run_cmd = "" else: run_cmd = args[0] # Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart...
webkit_path = os.path.join("external", "webkit") http_conf_path = os.path.join(webkit_path, "LayoutTests", "http", "conf")
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] #Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") ret...
directives += " -c \"DocumentRoot " + os.path.join("external", "webkit") + "\""
directives += " -c \"DocumentRoot " + webkit_path + "\""
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] #Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") ret...
directives += " -c \"SSLCertificateFile " + os.path.join ("external", "webkit", "LayoutTests", "http", "conf", "webkit-httpd.pem") + "\""
directives += " -c \"SSLCertificateFile " + os.path.join(http_conf_path, "webkit-httpd.pem") + \ "\""
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] #Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") ret...
conf_file_cmd = " -f " + os.path.join(android_tree_root, "external", "webkit", "LayoutTests", "http", "conf", "apache2-debian-httpd.conf")
conf_file_cmd = " -f " + \ os.path.join(android_tree_root, http_conf_path, "apache2-debian-httpd.conf")
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] #Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") ret...
def main(options, args): if args: path = " ".join(args); else: path = ""; logging.basicConfig(level=logging.INFO, format='%(message)s')
def main(path, options):
def main(options, args): if args: path = " ".join(args); else: path = ""; logging.basicConfig(level=logging.INFO, format='%(message)s') tmpdir = tempfile.gettempdir() # Restart the server if run_apache2.main("restart", options) == False: return # Run the tests in path adb_cmd = "adb" if options.serial: adb_cmd += "...
main(options, args);
logging.basicConfig(level=logging.INFO, format='%(message)s') if len(args) > 1: logging.fatal("Usage: run_layout_tests.py [options] test-relative-path") else: if len(args) < 1: path = ""; else: path = args[0] main(path, options);
def main(options, args): if args: path = " ".join(args); else: path = ""; logging.basicConfig(level=logging.INFO, format='%(message)s') tmpdir = tempfile.gettempdir() # Restart the server if run_apache2.main("restart", options) == False: return # Run the tests in path adb_cmd = "adb" if options.serial: adb_cmd += "...
timeout_ms = '30000'
timeout_ms = '15000'
def main(options, args): """Run the tests. Will call sys.exit when complete. Args: options: a dictionary of command line options args: a list of sub directories or files to test """ # Set up logging format. log_level = logging.INFO if options.verbose: log_level = logging.DEBUG logging.basicConfig(level=log_level, for...
http_conf_path = os.path.join(webkit_path, "LayoutTests", "http", "conf")
layout_tests_path = os.path.join(webkit_path, "LayoutTests") http_conf_path = os.path.join(layout_tests_path, "http", "conf")
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] # Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") re...
directives += " -c \"DocumentRoot " + webkit_path + "\""
directives += " -c \"DocumentRoot " + os.path.join(layout_tests_path, "http", "tests/") + "\"" directives += " -c \"Alias /LayoutTests " + layout_tests_path + "\"" directives += " -c \"Alias /WebKitTools/DumpRenderTree/android " + \ os.path.join(webkit_path, "WebKitTools", "DumpRenderTree", "android") + "\""
def main(): if len(sys.argv) < 2: run_cmd = "" else: run_cmd = sys.argv[1] # Setup logging class logging.basicConfig(level=logging.INFO, format='%(message)s') if not run_cmd in ("start", "stop", "restart"): logging.info("illegal argument: " + run_cmd) logging.info("Usage: python run_apache2.py start|stop|restart") re...
subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
(stdoutdata, stderrdata) = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if re.search("^INSTRUMENTATION_STATUS_CODE: -1", stdoutdata, re.MULTILINE) != None: logging.info("Failed to run the tests. Is DumpRenderTree2 installed on the device?") return
def main(options, args): if args: path = " ".join(args); else: path = ""; logging.basicConfig(level=logging.INFO, format='%(message)s') tmpdir = tempfile.gettempdir() if options.tests_root_directory != None: # if options.tests_root_directory is absolute, os.getcwd() is discarded! tests_root_directory = os.path.normp...
subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
subprocess.Popen(cmd, shell=True).wait()
def main(options, args): if args: path = " ".join(args); else: path = ""; logging.basicConfig(level=logging.INFO, format='%(message)s') tmpdir = tempfile.gettempdir() if options.tests_root_directory != None: # if options.tests_root_directory is absolute, os.getcwd() is discarded! tests_root_directory = os.path.normp...
if 'id' in row:
try:
def generate(self, contents, columns, sortable=False, selected=(None,None), css_mapping={}, translations=[], template=None, options={}, output='html', meta_data=None): self.sortable = sortable self.selected = selected self.columns = self.process_columns(columns) self.contents = contents self.options = options self.grou...
if self.contents and len(self.contents) and \ isinstance(self.contents[0], tuple): self.grouping_enabled = True else: self.grouping_enabled = False
def generate(self, contents, columns, sortable=False, selected=(None,None), css_mapping={}, translations=[], template=None, options={}, output='html', meta_data=None): self.sortable = sortable self.selected = selected self.columns = self.process_columns(columns) self.contents = contents self.options = options
if self.grouping_enabled:
if isinstance(content, tuple):
def generate(self, contents, columns, sortable=False, selected=(None,None), css_mapping={}, translations=[], template=None, options={}, output='html', meta_data=None): self.sortable = sortable self.selected = selected self.columns = self.process_columns(columns) self.contents = contents self.options = options
link = u'<a href="%s">%s%s</a>' % (url_method(), img, value)
link = u'<a href="%s">%s%s</a>' % (url_method(), img, value.decode('utf8'))
def linked(item, value): url_method = lambda: '#' #item = hasattr(item, 'aq_explicit') and item.aq_explicit or item if hasattr(item, 'getURL'): url_method = item.getURL elif hasattr(item, 'absolute_url'): url_method = item.absolute_url img = u'<img src="%s/%s"/>' % (item.portal_url(), item.getIcon) link = u'<a href="%s...
elif content.has_key(attr):
elif hasattr(content,'__iter__') and attr in content:
def get_value(self, content, column): attr = column['attr'] sort_index = column['sort_index'] transform = column['transform'] value = u'' if hasattr(content, attr): value = getattr(content, attr) elif content.has_key(attr): value = content[attr] return transform(content, value)
meta_data['config'] ={} meta_data['config']['sort'] = selected[0] sort_order = selected[1] if sort_order is None: sort_order = 'asc' meta_data['config']['dir'] = sort_order.upper() if self.options and 'auto_expand_column' in self.options: aecolumn = self.options['auto_expand_column'] meta_data['config']['auto_expand_co...
meta_data['config'] ={} meta_data['config']['sort'] = selected[0] sort_order = selected[1] if sort_order is None: sort_order = 'asc' elif sort_order == 'reverse': sort_order = 'desc' meta_data['config']['dir'] = sort_order.upper() if self.options and 'auto_expand_column' in self.options: aecolumn = self.options['auto_e...
def generate(self, contents, columns, sortable=False, selected=(None,None), css_mapping={}, template=None, options=None, output='html', meta_data=None): self.sortable = sortable self.selected = selected self.columns = self.process_columns(columns) self.contents = contents self.options = options # TODO: implement json s...
template=None, options=None, output='html', meta_data=None):
template=None, options={}, output='html', meta_data=None):
def generate(self, contents, columns, sortable=False, selected=(None,None), css_mapping={}, translations=[], template=None, options=None, output='html', meta_data=None): self.sortable = sortable self.selected = selected self.columns = self.process_columns(columns) self.contents = contents self.options = options # TODO:...
cmp=lambda aa, bb: cmp(getattr(aa, sort_on), getattr(bb, sort_on)),
cmp=datetime_compare,
def default_custom_sort(results, sort_on, reverse): """Default custom sort method wich gets value to sort for by getting the attribute `sort_on` from the record. """ return sorted(results, cmp=lambda aa, bb: cmp(getattr(aa, sort_on), getattr(bb, sort_on)), reverse=reverse)
self._custom_sort_method = \
self.config._custom_sort_method = \
def extend_query_with_ordering(self, query): """Extends the given `query` with ordering information and returns the new query. """
if getattr(self, '_custom_sort_method', None) is not None: results = self._custom_sort_method(results, self.config.sort_on, self.config.sort_reverse)
def search_results(self, query): """Executes the query and returns a tuple of `results`. """
def linked(item, value):
def linked(item, value, show_icon=True):
def linked(item, value): url_method = lambda: '#' #item = hasattr(item, 'aq_explicit') and item.aq_explicit or item if hasattr(item, 'getURL'): url_method = item.getURL elif hasattr(item, 'absolute_url'): url_method = item.absolute_url img = u'<img src="%s/%s"/>' % (item.portal_url(), item.getIcon) # Replace < and > w...
img = u'<img src="%s/%s"/>' % (item.portal_url(), item.getIcon) value = value.decode('utf8').replace('<', '&lt;').replace('<', '&gt;').replace('&', '&amp;') link = u'<a href="%s">%s%s</a>' % (url_method(), img, value)
if show_icon: img = u'<img src="%s/%s"/>' % (item.portal_url(), item.getIcon) else: img = u'' value = value.decode('utf8').replace( '<', '&lt;').replace('<', '&gt;').replace('&', '&amp;') href = url_method() if hasattr(item, 'portal_type'): props = getToolByName(getSite(), 'portal_properties') types_using_view = ...
def linked(item, value): url_method = lambda: '#' #item = hasattr(item, 'aq_explicit') and item.aq_explicit or item if hasattr(item, 'getURL'): url_method = item.getURL elif hasattr(item, 'absolute_url'): url_method = item.absolute_url img = u'<img src="%s/%s"/>' % (item.portal_url(), item.getIcon) # Replace < and > w...
def run_once(self, args_list = ''): if len(args_list) != 0:
def run_once(self, args_list=''): if args_list:
def run_once(self, args_list = ''): if len(args_list) != 0: args = args_list else: args = '--mode rotate'
unittest_cfg = os.path.join(userspace_srcdir, 'kvm', 'test', 'x86', 'unittests.cfg')
if test_repo: test_srcdir = os.path.join(self.srcdir, "kvm-unit-tests") kvm_utils.get_git_branch(test_repo, test_branch, test_srcdir, test_commit, test_lbranch) unittest_cfg = os.path.join(test_srcdir, 'x86', 'unittests.cfg') self.test_srcdir = test_srcdir else: unittest_cfg = os.path.join(userspace_srcdir, 'kvm', 'tes...
def __init__(self, test, params): """ Initialize class parameters and retrieves code from git repositories.
utils.system('patch -p1 < ../lmbench3.diff')
p1 = 'patch -p1 < ../0001-Fix-build-issues-with-lmbench.patch' p2 = 'patch -p1 < ../0002-Changing-shebangs-on-lmbench-scripts.patch' utils.system(p1) utils.system(p2)
def setup(self, tarball = 'lmbench3.tar.bz2', fsdir=None, file=None): """ Uncompresses the original lmbench tarball, applies a patch to fix some build issues, configures lmbench and then modifies the config files to use appropriate directory and file locations.
if params.get("post_command"): process_command(test, params, env, params.get("post_command"), int(params.get("post_command_timeout", "600")), params.get("post_command_noncritical") == "yes")
if params.get("keep_screendumps") != "yes": logging.debug("'keep_screendumps' not specified; removing screendump " "dirs...") for d in glob.glob(os.path.join(test.debugdir, "screendumps_*")): if os.path.isdir(d) and not os.path.islink(d): shutil.rmtree(d, ignore_errors=True)
def postprocess(test, params, env): """ Postprocess all VMs and images according to the instructions in params. @param test: An Autotest test object. @param params: Dict containing all VM and image parameters. @param env: The environment (a dict-like object). """ process(test, params, env, postprocess_image, postproce...
cmd = " -net nic,vlan=%d" % vlan
def add_nic(help, vlan, model=None, mac=None, netdev_id=None): cmd = " -net nic,vlan=%d" % vlan if has_option(help, "netdev"): cmd +=",netdev=%s" % netdev_id if model: cmd += ",model=%s" % model if mac: cmd += ",macaddr='%s'" % mac return cmd
cmd +=",netdev=%s" % netdev_id
cmd = " -net nic,netdev=%s" % netdev_id else: cmd = " -net nic,vlan=%d" % vlan
def add_nic(help, vlan, model=None, mac=None, netdev_id=None): cmd = " -net nic,vlan=%d" % vlan if has_option(help, "netdev"): cmd +=",netdev=%s" % netdev_id if model: cmd += ",model=%s" % model if mac: cmd += ",macaddr='%s'" % mac return cmd
@param obj: The object to send
@param cmd: Command to send @param args: A dict containing command arguments, or None @param id: An id for the command, or None
def cmd_qmp(self, cmd, args=None, id=None, timeout=20): """ Build a QMP command from the passed arguments, send it to the monitor and return the response. Unlike cmd(), return the raw response dict without performing any checks on it.
cdrom_iso = os.environ.get('KVM_TEST_cdrom')
cdrom_iso = os.environ.get('KVM_TEST_cdrom_cd1')
def __init__(self): """ Gets params from environment variables and sets class attributes. """ script_dir = os.path.dirname(sys.modules[__name__].__file__) kvm_test_dir = os.path.abspath(os.path.join(script_dir, "..")) images_dir = os.path.join(kvm_test_dir, 'images') self.deps_dir = os.path.join(kvm_test_dir, 'deps') s...
def setup(self, tarball='iozone3_283.tar'):
def setup(self, tarball='iozone3_347.tar'): """ Builds the given version of IOzone from a tarball. @param tarball: Tarball with IOzone @see: http://www.iozone.org/src/current/iozone3_347.tar """
def initialize(self): self.job.require_gcc()
if has_qemu_dir and not has_kvm_dir:
if has_qemu_dir:
def check_kvm_source_dir(source_dir): """ Inspects the kvm source directory and verifies its disposition. In some occasions build may be dependant on the source directory disposition. The reason why the return codes are numbers is that we might have more changes on the source directory layout, so it's not scalable to j...
logging.debug("The following pci_ids were found: %s" % self.pci_ids)
logging.debug("The following pci_ids were found: %s", self.pci_ids)
def request_devs(self): """ Implement setup process: unbind the PCI device and then bind it to the pci-stub driver.
logging.debug("Binding device %s to stub" % full_id)
logging.debug("Binding device %s to stub", full_id)
def request_devs(self): """ Implement setup process: unbind the PCI device and then bind it to the pci-stub driver.
utils.open_write_close(content, file)
utils.open_write_close(file, content)
def request_devs(self): """ Implement setup process: unbind the PCI device and then bind it to the pci-stub driver.
logging.debug("Failed to write %s to file %s" % (content, file))
logging.debug("Failed to write %s to file %s", content, file)
def request_devs(self): """ Implement setup process: unbind the PCI device and then bind it to the pci-stub driver.
logging.error("Binding device %s to stub failed" % pci_id)
logging.error("Binding device %s to stub failed", pci_id)
def request_devs(self): """ Implement setup process: unbind the PCI device and then bind it to the pci-stub driver.
logging.debug("Device %s already binded to stub" % pci_id)
logging.debug("Device %s already binded to stub", pci_id)
def request_devs(self): """ Implement setup process: unbind the PCI device and then bind it to the pci-stub driver.
iso = params.get("cdrom") if iso: iso = kvm_utils.get_path(root_dir, iso) qemu_cmd += add_cdrom(help, iso, 2) iso_extra = params.get("cdrom_extra") if iso_extra: iso_extra = kvm_utils.get_path(root_dir, iso_extra) qemu_cmd += add_cdrom(help, iso_extra, 3)
cdroms = kvm_utils.get_sub_dict_names(params, "cdroms") for cdrom in cdroms: cdrom_params = kvm_utils.get_sub_dict(params, cdrom) iso = cdrom_params.get("cdrom") if iso: qemu_cmd += add_cdrom(help, kvm_utils.get_path(root_dir, iso), cdrom_params.get("drive_index"))
def add_no_hpet(help): if has_option(help, "no-hpet"): return " -no-hpet" else: return ""
logging.info("Logged into guest %s using %s connection" % vm.name, type)
logging.info("Logged into guest %s using %s connection", vm.name, type)
def wait_for_login(vm, nic_index=0, timeout=240, start=0, step=2, serial=None): """ Try logging into a VM repeatedly. Stop on success or when timeout expires. @param vm: VM object. @param nic_index: Index of NIC to access in the VM. @param timeout: Time to wait before giving up. @param serial: Whether to use a serial...
logging.info("Extracting %s..." % basename)
logging.info("Extracting %s...", basename)
def extract(vm, remote_path, dest_dir="."): """ Extract a .tar.bz2 file on the guest.
raise error.TestFail("Could not extract % on guest")
raise error.TestFail("Could not extract %s on guest" % basename)
def extract(vm, remote_path, dest_dir="."): """ Extract a .tar.bz2 file on the guest.
logging.info("Running test '%s'..." % test_name)
logging.info("Running test '%s'...", test_name)
def extract(vm, remote_path, dest_dir="."): """ Extract a .tar.bz2 file on the guest.
logging.info("--------------End of test output ------------")
logging.info("------------- End of test output ------------")
def extract(vm, remote_path, dest_dir="."): """ Extract a .tar.bz2 file on the guest.
raise error.TestFail("Could not log into guest %s using %s connection" %
raise error.TestFail("Could not log into guest %s using %s connection",
def wait_for_login(vm, nic_index=0, timeout=240, start=0, step=2, serial=None): """ Try logging into a VM repeatedly. Stop on success or when timeout expires. @param vm: VM object. @param nic_index: Index of NIC to access in the VM. @param timeout: Time to wait before giving up. @param serial: Whether to use a serial...
parser = optparse.OptionParser() parser.add_option('-f', '--file', dest="filename", action='store', help='path to a config file that will be parsed. ' 'If not specified, will parse tests.cfg located ' 'inside the kvm test dir.')
parser = optparse.OptionParser("usage: %prog [options] [filename]")
def _array_get_all(a, object_cache): """ Return a 4-tuple containing all the data stored in a given array, in a format that is easy to turn into an actual dictionary. @param a: Array representing a dictionary. @param object_cache: A list of strings referenced by elements in the array. @return: A 4-tuple: (name, shortn...
filename = options.filename
def _array_get_all(a, object_cache): """ Return a 4-tuple containing all the data stored in a given array, in a format that is easy to turn into an actual dictionary. @param a: Array representing a dictionary. @param object_cache: A list of strings referenced by elements in the array. @return: A 4-tuple: (name, shortn...
if not filename:
if args: filename = args[0] else:
def _array_get_all(a, object_cache): """ Return a 4-tuple containing all the data stored in a given array, in a format that is easy to turn into an actual dictionary. @param a: Array representing a dictionary. @param object_cache: A list of strings referenced by elements in the array. @return: A 4-tuple: (name, shortn...
i = 0 for dict in dicts:
for i, dict in enumerate(dicts):
def _array_get_all(a, object_cache): """ Return a 4-tuple containing all the data stored in a given array, in a format that is easy to turn into an actual dictionary. @param a: Array representing a dictionary. @param object_cache: A list of strings referenced by elements in the array. @return: A 4-tuple: (name, shortn...
i += 1
def _array_get_all(a, object_cache): """ Return a 4-tuple containing all the data stored in a given array, in a format that is easy to turn into an actual dictionary. @param a: Array representing a dictionary. @param object_cache: A list of strings referenced by elements in the array. @return: A 4-tuple: (name, shortn...
port=11920)
listen_server=barrier_server)
def execute(self, timeout_sync, timeout_start, timeout_stop, hostid, masterid, all_ids): profilers = self.job.profilers
self.extra_modules = params.get("extra_modules", None)
self.extra_modules = eval(params.get("extra_modules", "None"))
def __init__(self, test, params): """ Initialize class parameters and retrieves code from git repositories.
utils.system('patch -p0 < ../fix_netperf_build.patch')
def setup(self, tarball = 'netperf-2.4.4.tar.gz'): self.job.require_gcc() tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir)
self.build = self.__get_build()
self.build = self._get_build()
def __init__(self, test, params): """ Class constructor. Sets default paths, and sets up class attributes
def __get_build(self):
def _get_build(self):
def __get_build(self): """ Get the source package build name, according to the appropriate tag. """ latest_cmd = "%s latest-pkg %s %s" % (self.koji_cmd, self.tag, self.src_pkg) latest_raw = utils.system_output(latest_cmd, ignore_status=True).split("\n") for line in latest_raw: if line.startswith(self.src_pkg): build_na...
def __clean_previous_installs(self):
def _clean_previous_installs(self):
def __clean_previous_installs(self): """ Remove all rpms previously installed. """ kill_qemu_processes() removable_packages = "" for pkg in self.pkg_list: removable_packages += " %s" % pkg
def __get_packages(self):
def _get_packages(self):
def __get_packages(self): """ Downloads the entire build for the specific build name. It's inefficient, but it saves the need of having an NFS share set.
def __install_packages(self):
def _install_packages(self):
def __install_packages(self): """ Install all relevant packages from the build that was just downloaded. """ os.chdir(self.srcdir) installable_packages = "" rpm_list = glob.glob("*.rpm") arch = utils.get_arch() for rpm in rpm_list: for pkg in self.pkg_list: # Pass to yum only appropriate packages (ie, non-source and # ...
def __check_installed_binaries(self):
def _check_installed_binaries(self):
def __check_installed_binaries(self): """ Make sure the relevant binaries installed actually come from the build that was installed. """ source_rpm = "%s.src.rpm" % self.build for bin in self.qemu_bin_paths: origin_source_rpm = utils.system_output( "rpm -qf --queryformat '%{sourcerpm}' " + bin) if origin_source_rpm != ...
self.__clean_previous_installs() self.__get_packages() self.__install_packages() self.__check_installed_binaries()
self._clean_previous_installs() self._get_packages() self._install_packages() self._check_installed_binaries()
def install(self): self.__clean_previous_installs() self.__get_packages() self.__install_packages() self.__check_installed_binaries() create_symlinks(test_bindir=self.test_bindir, bin_list=self.qemu_bin_paths) if self.load_modules: load_kvm_modules(load_stock=True, extra_modules=self.extra_modules)
def __build(self):
def _build(self):
def __build(self): make_jobs = utils.count_cpus() os.chdir(self.srcdir) # For testing purposes, it's better to build qemu binaries with # debugging symbols, so we can extract more meaningful stack traces. cfg = "./configure --prefix=%s" % self.prefix if "--disable-strip" in self.configure_options: cfg += " --disable-st...
def __install(self):
def _install(self):
def __install(self): os.chdir(self.srcdir) logging.info("Installing KVM userspace") if self.repo_type == 1: utils.system("make -C qemu install") elif self.repo_type == 2: utils.system("make install") create_symlinks(self.test_bindir, self.prefix)
def __load_modules(self):
def _load_modules(self):
def __load_modules(self): load_kvm_modules(module_dir=self.srcdir, extra_modules=self.extra_modules)
self.__build() self.__install()
self._build() self._install()
def install(self): self.__build() self.__install() if self.load_modules: self.__load_modules()
self.__load_modules()
self._load_modules()
def install(self): self.__build() self.__install() if self.load_modules: self.__load_modules()
if not kernel_repo: message = "KVM git repository path not specified" logging.error(message) raise error.TestError(message)
def __init__(self, test, params): """ Initialize class parameters and retrieves code from git repositories.
kernel_srcdir = os.path.join(srcdir, "kvm") kvm_utils.get_git_branch(kernel_repo, kernel_branch, kernel_srcdir, kernel_tag, kernel_lbranch) self.kernel_srcdir = kernel_srcdir
def __init__(self, test, params): """ Initialize class parameters and retrieves code from git repositories.
def __build(self):
def _build(self):
def __build(self): # Number of concurrent build tasks make_jobs = utils.count_cpus() if self.kmod_srcdir: logging.info('Building KVM modules') os.chdir(self.kmod_srcdir) utils.system('./configure') utils.system('make clean') utils.system('make sync LINUX=%s' % self.kernel_srcdir) utils.system('make -j %s' % make_jobs)
utils.system('./configure') utils.system('make clean') utils.system('make sync LINUX=%s' % self.kernel_srcdir) utils.system('make -j %s' % make_jobs) logging.info('Building KVM userspace code') os.chdir(self.userspace_srcdir) cfg = './configure --prefix=%s' % self.prefix if "--disable-strip" in self.configure_options:...
module_build_steps = [cfg, 'make clean', 'make sync LINUX=%s' % self.kernel_srcdir, 'make'] elif self.kernel_srcdir:
def __build(self): # Number of concurrent build tasks make_jobs = utils.count_cpus() if self.kmod_srcdir: logging.info('Building KVM modules') os.chdir(self.kmod_srcdir) utils.system('./configure') utils.system('make clean') utils.system('make sync LINUX=%s' % self.kernel_srcdir) utils.system('make -j %s' % make_jobs)
cfg = './configure --kerneldir=%s' % self.host_kernel_srcdir utils.system(cfg) utils.system('make clean') utils.system('make -j %s -C kernel LINUX=%s sync' % (make_jobs, self.kernel_srcdir)) logging.info('Building KVM userspace code') cfg += ' --prefix=%s' % self.prefix if "--disable-strip" in self.configure_options...
cfg += ' --kerneldir=%s' % self.host_kernel_srcdir module_build_steps = [cfg, 'make clean', 'make -C kernel LINUX=%s sync' % self.kernel_srcdir] else: module_build_steps = [] try: if module_build_steps: for step in module_build_steps: utils.run(step) self.modules_build_succeed = True except error.CmdError, e: logging....
def __build(self): # Number of concurrent build tasks make_jobs = utils.count_cpus() if self.kmod_srcdir: logging.info('Building KVM modules') os.chdir(self.kmod_srcdir) utils.system('./configure') utils.system('make clean') utils.system('make sync LINUX=%s' % self.kernel_srcdir) utils.system('make -j %s' % make_jobs)
def __load_modules(self): if self.kmod_srcdir:
def _load_modules(self): if self.kmod_srcdir and self.modules_build_succeed:
def __load_modules(self): if self.kmod_srcdir: load_kvm_modules(module_dir=self.kmod_srcdir, extra_modules=self.extra_modules) else: load_kvm_modules(module_dir=self.userspace_srcdir, extra_modules=self.extra_modules)
else:
elif self.kernel_srcdir and self.modules_build_succeed:
def __load_modules(self): if self.kmod_srcdir: load_kvm_modules(module_dir=self.kmod_srcdir, extra_modules=self.extra_modules) else: load_kvm_modules(module_dir=self.userspace_srcdir, extra_modules=self.extra_modules)
utils.system('cc -lpthread hackbench.c -o hackbench')
if 'CC' in os.environ: cc = '$CC' else: cc = 'cc' utils.system('%s -lpthread hackbench.c -o hackbench' % cc)
def setup(self): os.chdir(self.srcdir) utils.system('cc -lpthread hackbench.c -o hackbench')
raw_output_file = open(path, 'w') raw_output_file.write(raw_output) raw_output_file.close()
utils.open_write_close(path, raw_output)
def run_once(self, num_groups=90): """ Run hackbench, store the output in raw output files per iteration and also in the results list attribute.
return int(commands.getoutput(cmd)) / 2
return int(commands.getoutput(cmd))
def get_vfs_count(self): """ Get VFs count number according to lspci. """ cmd = "lspci | grep 'Virtual Function' | wc -l" # For each VF we'll see 2 prints of 'Virtual Function', so let's # divide the result per 2 return int(commands.getoutput(cmd)) / 2
return (self.get_vfs_count == self.devices_requested)
expected_count = int((re.findall("(\d)", self.driver_option)[0])) * 2 return (self.get_vfs_count == expected_count)
def check_vfs_count(self): """ Check VFs count number according to the parameter driver_options. """ return (self.get_vfs_count == self.devices_requested)
return False if not self.check_vfs_count():
def sr_iov_setup(self): """ Ensure the PCI device is working in sr_iov mode.
def run_guest(cmd): s, o = session.get_command_status_output(cmd) if s: logging.warning('Command %s executed in guest returned exit code ' '%s, output: %s', cmd, s, o.strip())
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for i in range(mgroup_count): mcast = prefix + "." + str(suffix + i) try: mreq = struct.pack("4sl", socket.inet_aton(mcast), socket.INADDR_ANY) s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) except: s.close() print "Could not join multicast: %s" % mc...
def run_guest(cmd): s, o = session.get_command_status_output(cmd) if s: logging.warning('Command %s executed in guest returned exit code ' '%s, output: %s', cmd, s, o.strip())
def run_host_guest(cmd): run_guest(cmd) utils.system(cmd, ignore_status=True) cmd_flush = "iptables -F" cmd_selinux = ("if [ -e /selinux/enforce ]; then setenforce 0; " "else echo 'no /selinux/enforce file present'; fi") run_host_guest(cmd_flush) run_host_guest(cmd_selinux) cmd_broadcast = "echo 0 > /proc/sys/net/ip...
print "join_mcast_pid:%s" % os.getpid() os.kill(os.getpid(), signal.SIGSTOP) s.close()
def run_host_guest(cmd): run_guest(cmd) utils.system(cmd, ignore_status=True)
name_width = max(name_width, max(len(r[0]) for r in results))
name_width = max([name_width] + [len(r[0]) for r in results])
def main(resfiles): result_lists = [] name_width = 40 for resfile in resfiles: try: text = open(resfile).read() except IOError: print "Bad result file: %s" % resfile continue results = parse_results(text) result_lists.append((resfile, results)) name_width = max(name_width, max(len(r[0]) for r in results)) print_resul...
for index, label in zip(range(1, 14), _LABELS[2:]):
for index, label in zip(range(2, 15), _LABELS[2:]):
def plot_2d_graphs(self): """ For each one of the throughput parameters, generate a set of gnuplot commands that will create a parametric surface with file size vs. record size vs. throughput. """ datasource_2d = os.path.join(self.output_dir, '2d-datasource-file') for index, label in zip(range(1, 14), _LABELS[2:]): com...
return self.thread.is_alive()
return self.thread.isAlive()
def is_alive(self): """ Check whether the test is still alive. """ return self.thread.is_alive()
slot_id = "0" + add_output.split(",")[2].split()[1] cmd = "pci_del pci_addr=%s" % slot_id
if cmd_type == "pci_add": slot_id = "0" + add_output.split(",")[2].split()[1] cmd = "pci_del pci_addr=%s" % slot_id elif cmd_type == "device_add": cmd = "device_del %s" % id
def pci_del(ignore_failure=False): slot_id = "0" + add_output.split(",")[2].split()[1] cmd = "pci_del pci_addr=%s" % slot_id # This should be replaced by a proper monitor method call vm.monitor.cmd(cmd)
"Hypervisor command: %s" % (tested_model, cmd))
"Monitor command: %s" % (tested_model, cmd))
def device_removed(): after_del = vm.monitor.info("pci") return after_del != after_add
"hypervisor command: 'info pci'")
"monitor command: 'info pci'")
def device_removed(): after_del = vm.monitor.info("pci") return after_del != after_add
def setup(self, tarball = 'ltp-full-20080229.tar.bz2'):
def setup(self, tarball = 'ltp-full-20091231.tar.bz2'):
def initialize(self): self._import_site_config() self.job.require_gcc()
utils.system('make -j %d' % utils.count_cpus()) utils.system('yes n | make install')
utils.system('make autotools') utils.system('./configure --prefix=%s' % ltpbin_dir) utils.system('make -j %d all' % utils.count_cpus()) utils.system('yes n | make SKIP_IDCHECK=1 install')
def setup(self, tarball = 'ltp-full-20080229.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir)
cmd = os.path.join(self.srcdir, script) + ' ' + args
ltpbin_dir = os.path.join(self.srcdir, 'bin') cmd = os.path.join(ltpbin_dir, script) + ' ' + args
def run_once(self, args = '', script = 'runltp', ignore_tests=[]):
elif pa_type and pa_type != "no":
elif pa_type is not None and pa_type != "no":
def create(self, name=None, params=None, root_dir=None, for_migration=False, timeout=5.0): """ Start the VM by running a qemu command. All parameters are optional. The following applies to all parameters but for_migration: If a parameter is not supplied, the corresponding value stored in the class attributes is used, a...
def transfer_test(vm, host_path, guest_path, timeout=120): """ vm.copy_files_to does not raise exception, so we need a wrapper in order to make it to be used by BackgroundTest. """ if not vm.copy_files_to(host_path, guest_path, timeout=timeout):
def transfer_test(address, client, username, password, port, local_path, remote_path, log_filename, timeout): if not kvm_utils.copy_files_to(address, client, username, password, port, local_path, remote_path, log_filename, timeout):
def transfer_test(vm, host_path, guest_path, timeout=120): """ vm.copy_files_to does not raise exception, so we need a wrapper in order to make it to be used by BackgroundTest. """ if not vm.copy_files_to(host_path, guest_path, timeout=timeout): raise error.TestError("Fail to do the file transfer!")
(vm, "/tmp/file", guest_path, transfer_timeout))
(address, client, username, password, port, "/tmp/file", guest_path, log_filename, transfer_timeout))
def transfer_test(vm, host_path, guest_path, timeout=120): """ vm.copy_files_to does not raise exception, so we need a wrapper in order to make it to be used by BackgroundTest. """ if not vm.copy_files_to(host_path, guest_path, timeout=timeout): raise error.TestError("Fail to do the file transfer!")