client Package

autotest_local Module

class autotest.client.autotest_local.AutotestLocalApp[source]

Autotest local app runs tests locally

Point it to a control file and let it rock

main()[source]
parse_cmdline()[source]
usage()[source]

base_sysinfo Module

class autotest.client.base_sysinfo.base_sysinfo(job_resultsdir)[source]

Bases: object

deserialize(serialized)[source]
log_after_each_iteration(*args, **dargs)
log_after_each_test(*args, **dargs)
log_before_each_iteration(*args, **dargs)
log_before_each_test(*args, **dargs)
log_per_reboot_data(*args, **dargs)
log_test_keyvals(test_sysinfodir)[source]

Logging hook called by log_after_each_test to collect keyval entries to be written in the test keyval.

serialize()[source]
class autotest.client.base_sysinfo.command(cmd, logf=None, log_in_keyval=False, compress_log=False)[source]

Bases: autotest.client.base_sysinfo.loggable

run(logdir)[source]
class autotest.client.base_sysinfo.logfile(path, logf=None, log_in_keyval=False)[source]

Bases: autotest.client.base_sysinfo.loggable

run(logdir)[source]
class autotest.client.base_sysinfo.loggable(logf, log_in_keyval)[source]

Bases: object

Abstract class for representing all things “loggable” by sysinfo.

readline(logdir)[source]

base_utils Module

DO NOT import this file directly - import client/bin/utils.py, which will mix this in

Convenience functions for use by tests or whomever.

Note that this file is mixed in by utils.py - note very carefully the precedence order defined there

autotest.client.base_utils.append_path(oldpath, newpath)[source]

append newpath to oldpath

autotest.client.base_utils.avgtime_print(dir)[source]

Calculate some benchmarking statistics. Input is a directory containing a file called ‘time’. File contains one-per-line results of /usr/bin/time. Output is average Elapsed, User, and System time in seconds, and average CPU percentage.

autotest.client.base_utils.cat_file_to_cmd(file, command, ignore_status=0, return_output=False)[source]

equivalent to ‘cat file | command’ but knows to use zcat or bzcat if appropriate

autotest.client.base_utils.check_for_kernel_feature(feature)[source]
autotest.client.base_utils.check_glibc_ver(ver)[source]
autotest.client.base_utils.check_kernel_ver(ver)[source]
autotest.client.base_utils.count_cpus()[source]

number of CPUs in the local machine according to /proc/cpuinfo

autotest.client.base_utils.cpu_has_flags(flags)[source]

Check if a list of flags are available on current CPU info

Parameters:flags (list) – A list of cpu flags that must exists on the current CPU.
Returns:bool True if all the flags were found or False if not
Return type:list
autotest.client.base_utils.cpu_online_map()[source]

Check out the available cpu online map

autotest.client.base_utils.difflist(list1, list2)[source]

returns items in list2 that are not in list1

autotest.client.base_utils.disk_block_size(path)[source]

Return the disk block size, in bytes

autotest.client.base_utils.dump_object(object)[source]

Dump an object’s attributes and methods

kind of like dir()

autotest.client.base_utils.environ(env_key)[source]

return the requested environment variable, or ‘’ if unset

autotest.client.base_utils.extract_all_time_results(results_string)[source]

Extract user, system, and elapsed times into a list of tuples

autotest.client.base_utils.extract_tarball(tarball)[source]

Returns the directory extracted by the tarball.

autotest.client.base_utils.extract_tarball_to_dir(tarball, dir)[source]

Extract a tarball to a specified directory name instead of whatever the top level of a tarball is - useful for versioned directory names, etc

autotest.client.base_utils.file_contains_pattern(file, pattern)[source]

Return true if file contains the specified egrep pattern

autotest.client.base_utils.force_copy(src, dest)[source]

Replace dest with a new copy of src, even if it exists

Link src to dest, overwriting it if it exists

autotest.client.base_utils.freespace(path)[source]

Return the disk free space, in bytes

autotest.client.base_utils.get_cc()[source]
autotest.client.base_utils.get_cpu_arch()[source]

Work out which CPU architecture we’re running on

autotest.client.base_utils.get_cpu_family()[source]
autotest.client.base_utils.get_cpu_info()[source]

Reads /proc/cpuinfo and returns a list of file lines

Returns:list of lines from /proc/cpuinfo file
Return type:list
autotest.client.base_utils.get_cpu_stat(key)[source]

Get load per cpu from /proc/stat :return: list of values of CPU times

autotest.client.base_utils.get_cpu_vendor()[source]
autotest.client.base_utils.get_cpu_vendor_name()[source]

Get the current cpu vendor name

Returns:string ‘intel’ or ‘amd’ or ‘power7’ depending on the current CPU architecture.
Return type:string
autotest.client.base_utils.get_current_kernel_arch()[source]

Get the machine architecture

autotest.client.base_utils.get_disks()[source]
autotest.client.base_utils.get_file_arch(filename)[source]
autotest.client.base_utils.get_hwclock_seconds(utc=True)[source]

Return the hardware clock in seconds as a floating point value. Use Coordinated Universal Time if utc is True, local time otherwise. Raise a ValueError if unable to read the hardware clock.

autotest.client.base_utils.get_loaded_modules()[source]
autotest.client.base_utils.get_modules_dir()[source]

Return the modules dir for the running kernel version

autotest.client.base_utils.get_os_vendor()[source]

Try to guess what’s the os vendor.

autotest.client.base_utils.get_submodules(module_name)[source]

Get all submodules of the module.

Parameters:module_name (str) – Name of module to search for
Returns:List of the submodules
Return type:list
autotest.client.base_utils.get_systemmap()[source]

Return the full path to System.map

Ahem. This is crap. Pray harder. Bad Martin.

autotest.client.base_utils.get_uptime()[source]
Returns:return the uptime of system in secs in float in error case return ‘None’
autotest.client.base_utils.get_vmlinux()[source]

Return the full path to vmlinux

Ahem. This is crap. Pray harder. Bad Martin.

autotest.client.base_utils.grep(pattern, file)[source]

This is mainly to fix the return code inversion from grep Also handles compressed files.

returns 1 if the pattern is present in the file, 0 if not.

autotest.client.base_utils.hash_file(filename, size=None, method='md5')[source]

Calculate the hash of filename. If size is not None, limit to first size bytes. Throw exception if something is wrong with filename. Can be also implemented with bash one-liner (assuming size%1024==0): dd if=filename bs=1024 count=size/1024 | sha1sum -

Parameters:
  • filename – Path of the file that will have its hash calculated.
  • method – Method used to calculate the hash. Supported methods: * md5 * sha1
Returns:

Hash of the file, if something goes wrong, return None.

autotest.client.base_utils.human_format(number)[source]
autotest.client.base_utils.list_grep(list, pattern)[source]

True if any item in list matches the specified pattern.

autotest.client.base_utils.load_module(module_name)[source]
autotest.client.base_utils.loaded_module_info(module_name)[source]

Get loaded module details: Size and Submodules.

Parameters:module_name (str) – Name of module to search for
Returns:Dictionary of module info, name, size, submodules if present
Return type:dict
autotest.client.base_utils.locate(pattern, root='/home/docs/checkouts/readthedocs.org/user_builds/autotest/checkouts/stable/documentation/source')[source]
autotest.client.base_utils.module_is_loaded(module_name)[source]

Is module loaded

Parameters:module_name (str) – Name of module to search for
Returns:True is module is loaded
Return type:bool
autotest.client.base_utils.parse_lsmod_for_module(l_raw, module_name, escape=True)[source]

Use a regexp to parse raw lsmod output and get module information :param l_raw: raw output of lsmod :type l_raw: str :param module_name: Name of module to search for :type module_name: str :param escape: Escape regexp tokens in module_name, default True :type escape: bool :return: Dictionary of module info, name, size, submodules if present :rtype: dict

autotest.client.base_utils.pickle_load(filename)[source]
autotest.client.base_utils.ping_default_gateway()[source]

Ping the default gateway.

autotest.client.base_utils.prepend_path(newpath, oldpath)[source]

prepend newpath to oldpath

autotest.client.base_utils.print_to_tty(string)[source]

Output string straight to the tty

autotest.client.base_utils.process_is_alive(name_pattern)[source]

‘pgrep name’ misses all python processes and also long process names. ‘pgrep -f name’ gets all shell commands with name in args. So look only for command whose initial pathname ends with name. Name itself is an egrep pattern, so it can use | etc for variations.

autotest.client.base_utils.running_config()[source]

Return path of config file of the currently running kernel

autotest.client.base_utils.running_os_full_version()[source]
autotest.client.base_utils.running_os_ident()[source]
autotest.client.base_utils.running_os_release()[source]
autotest.client.base_utils.set_power_state(state)[source]

Set the system power state to ‘state’.

autotest.client.base_utils.set_wake_alarm(alarm_time)[source]

Set the hardware RTC-based wake alarm to ‘alarm_time’.

autotest.client.base_utils.standby()[source]

Power-on suspend (S1)

autotest.client.base_utils.suspend_to_disk()[source]

Suspend the system to disk (S4)

autotest.client.base_utils.suspend_to_ram()[source]

Suspend the system to RAM (S3)

autotest.client.base_utils.sysctl(key, value=None)[source]

Generic implementation of sysctl, to read and write.

Parameters:
  • key – A location under /proc/sys
  • value – If not None, a value to write into the sysctl.
Returns:

The single-line sysctl value as a string.

autotest.client.base_utils.sysctl_kernel(key, value=None)[source]

(Very) partial implementation of sysctl, for kernel params

autotest.client.base_utils.to_seconds(time_string)[source]

Converts a string in M+:SS.SS format to S+.SS

autotest.client.base_utils.unload_module(module_name)[source]

Removes a module. Handles dependencies. If even then it’s not possible to remove one of the modules, it will throw an error.CmdError exception.

Parameters:module_name (str) – Name of the module we want to remove.
autotest.client.base_utils.unmap_url_cache(cachedir, url, expected_hash, method='md5')[source]

Downloads a file from a URL to a cache directory. If the file is already at the expected position and has the expected hash, let’s not download it again.

Parameters:
  • cachedir – Directory that might hold a copy of the file we want to download.
  • url – URL for the file we want to download.
  • expected_hash – Hash string that we expect the file downloaded to have.
  • method – Method used to calculate the hash string (md5, sha1).
autotest.client.base_utils.where_art_thy_filehandles()[source]

Dump the current list of filehandles

bkr_proxy Module

bkr_proxy - class used to talk to beaker

class autotest.client.bkr_proxy.BkrProxy(recipe_id, labc_url=None)[source]

Bases: object

get_recipe()[source]
recipe_abort()[source]
recipe_stop()[source]
recipe_upload_file(localfile, remotepath='')[source]
result_upload_file(task_id, result_id, localfile, remotepath='')[source]
task_abort(task_id)[source]
task_result(task_id, result_type, result_path, result_score, result_summary)[source]
task_start(task_id, kill_time=0)[source]
task_stop(task_id)[source]
task_upload_file(task_id, localfile, remotepath='')[source]
update_watchdog(task_id, kill_time)[source]
exception autotest.client.bkr_proxy.BkrProxyException(text)[source]

Bases: exceptions.Exception

autotest.client.bkr_proxy.copy_data(data, dest, header=None, use_put=None)[source]

Copy data to a destination

To aid in debugging, copy a file locally to verify the contents. Attempts to write the same data that would otherwise be sent remotely.

Parameters:
  • data – data string to copy
  • dest – destination path
  • header – header info item to return
  • use_put – dictionary of items for PUT method
Returns:

nothing or header info if requested

autotest.client.bkr_proxy.copy_local(data, dest, use_put=None)[source]

Copy data locally to a file

To aid in debugging, copy a file locally to verify the contents. Attempts to write the same data that would otherwise be sent remotely.

Parameters:
  • data – encoded data string to copy locally
  • dest – local file path
  • use_put – chooses to write in binary or text
Returns:

nothing

autotest.client.bkr_proxy.copy_remote(data, dest, use_put=None)[source]

Copy data to a remote server using http calls POST or PUT

Using http POST and PUT methods, copy data over http. To use PUT method, provide a dictionary of values to be populated in the Content-Range and Content-Length headers. Otherwise default is to use POST method.

Traps on HTTPError 500 and 400

Parameters:
  • data – encoded data string to copy remotely
  • dest – remote server URL
  • use_put – dictionary of items if using PUT method
Returns:

html header info for post processing

autotest.client.bkr_proxy.make_path_bkrcache(r)[source]

Converts a recipe id into an internal path for cache’ing recipe

Parameters:r – recipe id
Returns:a path to the internal recipe cache file
autotest.client.bkr_proxy.make_path_cmdlog(r)[source]

Converts a recipe id into an internal path for logging purposes

Parameters:r – recipe id
Returns:a path to the internal command log
autotest.client.bkr_proxy.make_path_log(r, t=None, i=None)[source]

Converts id into a beaker path to log file

Given a recipe id, a task id, and/or result id, translate them into the proper beaker path to the log file. Depending on which log file is needed, provide the appropriate params. Note the dependency, a result id needs a task id and recipe id, while a task id needs a recipe id.

Parameters:
  • r – recipe id
  • t – task id
  • i – result id
Returns:

a beaker path of the task’s result file

autotest.client.bkr_proxy.make_path_recipe(r)[source]

Converts a recipe id into a beaker path

Parameters:r – recipe id
Returns:a beaker path to the recipe id
autotest.client.bkr_proxy.make_path_result(r, t)[source]

Converts task id into a beaker path to result file

Given a recipe id and a task id, translate them into the proper beaker path to the result file.

Parameters:
  • r – recipe id
  • t – task id
Returns:

a beaker path of the task’s result file

autotest.client.bkr_proxy.make_path_status(r, t=None)[source]

Converts id into a beaker path to status file

Given a recipe id and/or a task id, translate them into the proper beaker path to the status file. Recipe only, returns the path to the recipe’s status, whereas including a task returns the path to the task’s status.

Parameters:
  • r – recipe id
  • t – task id
Returns:

a beaker path of the recipe’s/task’s status file

autotest.client.bkr_proxy.make_path_watchdog(r)[source]

Converts a recipe id into a beaker path for the watchdog

Parameters:r – recipe id
Returns:a beaker path of the recipe’s watchdog file

bkr_xml Module

module to parse beaker xml recipe

class autotest.client.bkr_xml.BeakerXMLParser[source]

Bases: object

Handles parsing of beaker job xml

handle_recipe(recipe_node)[source]
handle_recipes(recipe_nodes)[source]
handle_task(recipe, task_node)[source]
handle_task_param(task, param_node)[source]
handle_task_params(task, param_nodes)[source]
handle_tasks(recipe, task_nodes)[source]
parse_from_file(file_name)[source]
parse_xml(xml)[source]

Returns dict, mapping hostname to recipe

class autotest.client.bkr_xml.Recipe[source]

Bases: object

class autotest.client.bkr_xml.Task[source]

Bases: object

Simple record to store task properties

get_param(key, default=None)[source]
autotest.client.bkr_xml.xml_attr(node, key, default=None)[source]
autotest.client.bkr_xml.xml_get_nodes(node, tag)[source]

client_logging_config Module

class autotest.client.client_logging_config.ClientLoggingConfig(use_console=True)[source]

Bases: autotest.client.shared.logging_config.LoggingConfig

add_debug_file_handlers(log_dir, log_name=None)[source]
configure_logging(results_dir=None, verbose=False)[source]

cmdparser Module

Autotest command parser

copyright:Don Zickus <dzickus@redhat.com> 2011
class autotest.client.cmdparser.CmdParserLoggingConfig(use_console=True)[source]

Bases: autotest.client.shared.logging_config.LoggingConfig

Used with the sole purpose of providing convenient logging setup for the KVM test auxiliary programs.

configure_logging(results_dir=None, verbose=False)[source]
class autotest.client.cmdparser.CommandParser[source]

Bases: object

A client-side command wrapper for the autotest client.

COMMAND_LIST = ['help', 'list', 'run', 'fetch', 'bootstrap']
bootstrap(args, options)[source]

Bootstrap autotest by fetching the control file first and pass it back

Currently this relies on a harness to retrieve the file

fetch(args, options)[source]

fetch a remote control file or packages

classmethod help()[source]

List the commands and their usage strings.

:param args is not used here.

classmethod list_tests()[source]

List the available tests for users to choose from

parse_args(args, options)[source]

Process a client side command.

Parameters:args – Command line args.
run(args, options)[source]

Wrap args with a path and send it back to autotest.

common Module

config Module

The Job Configuration

The job configuration, holding configuration variable supplied to the job.

The config should be viewed as a hierarchical namespace. The elements of the hierarchy are separated by periods (.) and where multiple words are required at a level they should be separated by underscores (_). Please no StudlyCaps.

For example:
boot.default_args
class autotest.client.config.config(job)[source]

Bases: object

The BASIC job configuration

Properties:
job
The job object for this job
config
The job configuration dictionary
get(name)[source]
set(name, value)[source]

cpuset Module

autotest.client.cpuset.abbrev_list(vals)[source]

Condense unsigned (0,4,5,6,7,10) to ‘0,4-7,10’.

autotest.client.cpuset.all_drive_names()[source]
autotest.client.cpuset.avail_mbytes(parent='')[source]
autotest.client.cpuset.available_exclusive_mem_nodes(parent_container)[source]
autotest.client.cpuset.container_bytes(name)[source]
autotest.client.cpuset.container_exists(name)[source]
autotest.client.cpuset.container_mbytes(name)[source]
autotest.client.cpuset.cpus_path(container_name)[source]
autotest.client.cpuset.cpuset_attr(container_name, attr)[source]
autotest.client.cpuset.create_container_directly(name, mbytes, cpus)[source]
autotest.client.cpuset.create_container_via_memcg(name, parent, bytes, cpus)[source]
autotest.client.cpuset.create_container_with_mbytes_and_specific_cpus(name, mbytes, cpus=None, root='', io={}, move_in=True, timeout=0)[source]

Create a cpuset container and move job’s current pid into it Allocate the list “cpus” of cpus to that container

Parameters:
  • name – arbitrary string tag
  • mbytes – reqested memory for job in megabytes
  • (None) (cpus) – list of cpu indices to associate with the cpuset defaults to all cpus avail with given root
  • root – the parent cpuset to nest this new set within, ‘’ unnested top-level container
  • io – arguments for proportional IO containers
  • (True) (move_in) – Move current process into the new container now.
  • (must be 0) (timeout) – persist until explicitly deleted.
autotest.client.cpuset.create_container_with_specific_mems_cpus(name, mems, cpus)[source]
autotest.client.cpuset.delete_leftover_test_containers()[source]
autotest.client.cpuset.discover_container_style()[source]
autotest.client.cpuset.full_path(container_name)[source]
autotest.client.cpuset.get_boot_numa()[source]
autotest.client.cpuset.get_cpus(container_name)[source]
autotest.client.cpuset.get_mem_nodes(container_name)[source]
autotest.client.cpuset.get_tasks(container_name)[source]
autotest.client.cpuset.inner_containers_of(parent)[source]
autotest.client.cpuset.io_attr(container_name, attr)[source]
autotest.client.cpuset.mbytes_per_mem_node()[source]
autotest.client.cpuset.memory_path(container_name)[source]
autotest.client.cpuset.mems_path(container_name)[source]
autotest.client.cpuset.move_self_into_container(name)[source]
autotest.client.cpuset.move_tasks_into_container(name, tasks)[source]
autotest.client.cpuset.my_available_exclusive_mem_nodes()[source]
autotest.client.cpuset.my_container_name()[source]
autotest.client.cpuset.my_lock(lockname)[source]
autotest.client.cpuset.my_mem_nodes()[source]
autotest.client.cpuset.my_unlock(lockfile)[source]
autotest.client.cpuset.need_fake_numa()[source]
autotest.client.cpuset.need_mem_containers()[source]
autotest.client.cpuset.node_avail_kbytes(node)[source]
autotest.client.cpuset.nodes_avail_mbytes(nodes)[source]
autotest.client.cpuset.rangelist_to_set(rangelist)[source]
autotest.client.cpuset.release_container(container_name=None)[source]
autotest.client.cpuset.remove_empty_prio_classes(prios)[source]
autotest.client.cpuset.set_io_controls(container_name, disks=[], ioprio_classes=[2], io_shares=[95], io_limits=[0])[source]
autotest.client.cpuset.tasks_path(container_name)[source]
autotest.client.cpuset.unpath(container_path)[source]

fsdev_disks Module

autotest.client.fsdev_disks.finish_fsdev(force_cleanup=False)[source]

This method can be called from the test file to optionally restore all the drives used by the test to a standard ext2 format. Note that if use_fsdev_lib() was invoked with ‘reinit_disks’ not set to True, this method does nothing. Note also that only fsdev “server-side” dynamic control files should ever set force_cleanup to True.

class autotest.client.fsdev_disks.fsdev_disks(job)[source]

Disk drive handling class used for file system development

config_sched_tunables(desc_file)[source]
get_fsdev_mgr()[source]
load_sched_tunable_values(val_file)[source]
set_sched_tunables(disks)[source]

Given a list of disks in the format returned by get_disk_list() above, set the I/O scheduler values on all the disks to the values loaded earlier by load_sched_tunables().

set_tunable(disk, name, path, val)[source]

Given a disk name, a path to a tunable value under _TUNE_PATH and the new value for the parameter, set the value and verify that the value has been successfully set.

autotest.client.fsdev_disks.get_disk_list(std_mounts_only=True, get_all_disks=False)[source]

Get a list of dictionaries with information about disks on this system.

Parameters:
  • std_mounts_only – Whether the function should return only disks that have a mount point defined (True) or even devices that doesn’t (False).
  • get_all_disks – Whether the function should return only partitioned disks (False) or return every disk, regardless of being partitioned or not (True).
Returns:

List of dictionaries with disk information (see more below).

The ‘disk_list’ array returned by get_disk_list() has an entry for each disk drive we find on the box. Each of these entries is a map with the following 3 string values:

‘device’ disk device name (i.e. the part after /dev/) ‘mountpt’ disk mount path ‘tunable’ disk name for setting scheduler tunables (/sys/block/sd??)

The last value is an integer that indicates the current mount status of the drive:

‘mounted’ 0 = not currently mounted
1 = mounted r/w on the expected path

-1 = mounted readonly or at an unexpected path

When the ‘std_mounts_only’ argument is True we don’t include drives mounted on ‘unusual’ mount points in the result. If a given device is partitioned, it will return all partitions that exist on it. If it’s not, it will return the device itself (ie, if there are /dev/sdb1 and /dev/sdb2, those will be returned but not /dev/sdb. if there is only a /dev/sdc, that one will be returned).

autotest.client.fsdev_disks.match_fs(disk, dev_path, fs_type, fs_makeopt)[source]

Matches the user provided fs_type and fs_makeopt with the current disk.

autotest.client.fsdev_disks.mkfs_all_disks(job, disk_list, fs_type, fs_makeopt, fs_mnt_opt)[source]

Prepare all the drives in ‘disk_list’ for testing. For each disk this means unmounting any mount points that use the disk, running mkfs with ‘fs_type’ as the file system type and ‘fs_makeopt’ as the ‘mkfs’ options, and finally remounting the freshly formatted drive using the flags in ‘fs_mnt_opt’.

autotest.client.fsdev_disks.prepare_disks(job, fs_desc, disk1_only=False, disk_list=None)[source]

Prepare drive(s) to contain the file system type / options given in the description line ‘fs_desc’. When ‘disk_list’ is not None, we prepare all the drives in that list; otherwise we pick the first available data drive (which is usually hdc3) and prepare just that one drive.

Args:
fs_desc: A partition.FsOptions instance describing the test -OR- a
legacy string describing the same in ‘/’ separated format:
‘fstype / mkfs opts / mount opts / short name’.
disk1_only: Boolean, defaults to False. If True, only test the first
disk.
disk_list: A list of disks to prepare. If None is given we default to
asking get_disk_list().
Returns:
(mount path of the first disk, short name of the test, list of disks) OR (None, ‘’, None) if no fs_desc was given.
autotest.client.fsdev_disks.prepare_fsdev(job)[source]

Called from the test file to get the necessary drive(s) ready; return a pair of values: the absolute path to the first drive’s mount point plus the complete disk list (which is useful for tests that need to use more than one drive).

autotest.client.fsdev_disks.restore_disks(job, restore=False, disk_list=None)[source]

Restore ext2 on the drives in ‘disk_list’ if ‘restore’ is True; when disk_list is None, we do nothing.

autotest.client.fsdev_disks.use_fsdev_lib(fs_desc, disk1_only, reinit_disks)[source]

Called from the control file to indicate that fsdev is to be used.

autotest.client.fsdev_disks.wipe_disks(job, disk_list)[source]

Wipe all of the drives in ‘disk_list’ using the ‘wipe’ functionality in the filesystem class.

fsdev_mgr Module

This module defines the BaseFsdevManager Class which provides an implementation of the ‘fsdev’ helper API; site specific extensions to any of these methods should inherit this class.

class autotest.client.fsdev_mgr.BaseFsdevManager[source]

Bases: object

check_mount_point(part_name, mount_point)[source]
Parameters:
  • part_name – A partition name such as ‘sda3’ or similar.
  • mount_point – A mount point such as ‘/usr/local’ or an empty string if no mount point is known.
Returns:

The expected mount point for part_name or a false value (None or ‘’) if the client should not mount this partition.

include_partition(part_name)[source]
map_drive_name(part_name)[source]
use_partition(part_name)[source]
Parameters:part_name – A partition name such as ‘sda3’ or similar.
Returns:bool, should we use this partition for testing?
class autotest.client.fsdev_mgr.FsdevManager[source]

Bases: autotest.client.fsdev_mgr.BaseFsdevManager

autotest.client.fsdev_mgr.SiteFsdevManager

alias of BaseFsdevManager

fsinfo Module

This module gives the mkfs creation options for an existing filesystem.

tune2fs or xfs_growfs is called according to the filesystem. The results, filesystem tunables, are parsed and mapped to corresponding mkfs options.

autotest.client.fsinfo.compare_features(needed_feature, current_feature)[source]

Compare two ext* feature lists.

autotest.client.fsinfo.convert_conf_opt(default_opt)[source]
autotest.client.fsinfo.ext_mkfs_options(tune2fs_dict, mkfs_option)[source]

Map the tune2fs options to mkfs options.

autotest.client.fsinfo.ext_tunables(dev)[source]

Call tune2fs -l and parse the result.

autotest.client.fsinfo.match_ext_options(fs_type, dev, needed_options)[source]

Compare the current ext* filesystem tunables with needed ones.

autotest.client.fsinfo.match_mkfs_option(fs_type, dev, needed_options)[source]

Compare the current filesystem tunables with needed ones.

autotest.client.fsinfo.match_xfs_options(dev, needed_options)[source]

Compare the current ext* filesystem tunables with needed ones.

autotest.client.fsinfo.merge_ext_features(conf_feature, user_feature)[source]
autotest.client.fsinfo.opt_string2dict(opt_string)[source]

Breaks the mkfs.ext* option string into dictionary.

autotest.client.fsinfo.parse_mke2fs_conf(fs_type, conf_file='/etc/mke2fs.conf')[source]

Parses mke2fs config file for default settings.

autotest.client.fsinfo.xfs_mkfs_options(tune2fs_dict, mkfs_option)[source]

Maps filesystem tunables to their corresponding mkfs options.

autotest.client.fsinfo.xfs_tunables(dev)[source]

Call xfs_grow -n to get filesystem tunables.

harness Module

The harness interface

The interface between the client and the server when hosted.

class autotest.client.harness.harness(job)[source]

Bases: object

The NULL server harness

Properties:
job
The job object for this job
run_abort()[source]

A run within this job is aborting. It all went wrong

run_complete()[source]

A run within this job is completing (all done)

run_pause()[source]

A run within this job is completing (expect continue)

run_reboot()[source]

A run within this job is performing a reboot (expect continue following reboot)

run_start()[source]

A run within this job is starting

run_test_complete()[source]

A test run by this job is complete. Note that if multiple tests are run in parallel, this will only be called when all of the parallel runs complete.

setup(job)[source]
job
The job object for this job
test_status(status, tag)[source]

A test within this job is completing

test_status_detail(code, subdir, operation, status, tag, optional_fields)[source]

A test within this job is completing (detail)

autotest.client.harness.select(which, job, harness_args)[source]

harness_autoserv Module

class autotest.client.harness_autoserv.AutoservFetcher(package_manager, job_harness)[source]

Bases: autotest.client.shared.base_packages.RepositoryFetcher

fetch_pkg_file(filename, dest_path)[source]
class autotest.client.harness_autoserv.harness_autoserv(job, harness_args)[source]

Bases: autotest.client.harness.harness

The server harness for running from autoserv

Properties:
job
The job object for this job
fetch_package(pkg_name, dest_path)[source]

Request a package from the remote autoserv.

Parameters:
  • pkg_name – The name of the package, as generally used by the client.shared.packages infrastructure.
  • dest_path – The path the package should be copied to.
run_start()[source]
run_test_complete()[source]

A test run by this job is complete, signal it to autoserv and wait for it to signal to continue

test_status(status, tag)[source]

A test within this job is completing

harness_beaker Module

The harness interface The interface between the client and beaker lab controller.

exception autotest.client.harness_beaker.HarnessException(text)[source]

Bases: exceptions.Exception

autotest.client.harness_beaker.get_beaker_code(at_code)[source]
class autotest.client.harness_beaker.harness_beaker(job, harness_args)[source]

Bases: autotest.client.harness.harness

bootstrap(fetchdir)[source]

How to kickstart autotest when you have no control file? You download the beaker XML, convert it to a control file and pass it back to autotest. Much like bootstrapping.. :-)

convert_task_to_control(fetchdir, control, task)[source]

Tasks are really just: # yum install $TEST # cd /mnt/tests/$TEST # make run

Convert that into a test module with a control file

find_recipe(recipes_dict)[source]
get_processed_tests()[source]
get_recipe_from_LC()[source]
get_test_name(task)[source]
init_recipe_from_beaker()[source]
init_task_params(task)[source]
kill_watchdog()[source]
parse_args(args, is_bootstrap)[source]
parse_quickcmd(args)[source]
run_abort()[source]

A run within this job is aborting. It all went wrong

run_complete()[source]

A run within this job is completing (all done)

run_pause()[source]

A run within this job is completing (expect continue)

run_reboot()[source]

A run within this job is performing a reboot (expect continue following reboot)

run_start()[source]

A run within this job is starting

run_test_complete()[source]

A test run by this job is complete. Note that if multiple tests are run in parallel, this will only be called when all of the parallel runs complete.

start_watchdog(heartbeat)[source]
tear_down()[source]

called from complete and abort. clean up and shutdown

test_status(status, tag)[source]

A test within this job is completing

test_status_detail(code, subdir, operation, status, tag, optional_fields)[source]

A test within this job is completing (detail)

upload_recipe_files()[source]
upload_result_files(task_id, resultid, subdir)[source]
upload_task_files(task_id, subdir)[source]
watchdog_loop(heartbeat)[source]
write_processed_tests(subdir, t_id='0')[source]

harness_simple Module

The simple harness interface

class autotest.client.harness_simple.harness_simple(job, harness_args)[source]

Bases: autotest.client.harness.harness

The simple server harness

Properties:
job
The job object for this job
test_status(status, tag)[source]

A test within this job is completing

harness_standalone Module

The standalone harness interface

The default interface as required for the standalone reboot helper.

class autotest.client.harness_standalone.harness_standalone(job, harness_args)[source]

Bases: autotest.client.harness.harness

The standalone server harness

Properties:
job
The job object for this job

job Module

The main job wrapper

This is the core infrastructure.

Copyright Andy Whitcroft, Martin J. Bligh 2006

exception autotest.client.job.NotAvailableError[source]

Bases: autotest.client.shared.error.AutotestError

exception autotest.client.job.StepError[source]

Bases: autotest.client.shared.error.AutotestError

class autotest.client.job.base_client_job(control, options, drop_caches=True, extra_copy_cmdline=None)[source]

Bases: autotest.client.shared.base_job.base_job

The client-side concrete implementation of base_job.

Optional properties provided by this implementation: - control - bootloader - harness

add_repository(repo_urls)[source]

Adds the repository locations to the job so that packages can be fetched from them when needed. The repository list needs to be a string list Ex: job.add_repository([‘http://blah1’,’http://blah2‘])

add_sysinfo_command(command, logfile=None, on_every_test=False)[source]
add_sysinfo_logfile(file, on_every_test=False)[source]
barrier(*args, **kwds)[source]

Create a barrier object

complete(status)[source]

Write pending TAP reports, clean up, and exit

config_get(name)[source]
config_set(name, value)[source]
control_get()[source]
control_set(control)[source]
cpu_count()[source]
disable_external_logging()[source]
disable_warnings(warning_type)[source]
enable_external_logging()[source]
enable_warnings(warning_type)[source]
end_reboot(subdir, kernel, patches, running_id=None)[source]
end_reboot_and_verify(expected_when, expected_id, subdir, type='src', patches=[])[source]

Check the passed kernel identifier against the command line and the running kernel, abort the job on missmatch.

filesystem(*args, **dargs)

Same as partition

Deprecated:Use partition method instead
handle_persistent_option(options, option_name)[source]

Select option from command line or persistent state. Store selected option to allow standalone client to continue after reboot with previously selected options. Priority: 1. explicitly specified via command line 2. stored in state file (if continuing job ‘-c’) 3. default is None

harness_select(which, harness_args)[source]
install_pkg(name, pkg_type, install_dir)[source]

This method is a simple wrapper around the actual package installation method in the Packager class. This is used internally by the profilers, deps and tests code.

Parameters:
  • name – name of the package (ex: sleeptest, dbench etc.)
  • pkg_type – Type of the package (ex: test, dep etc.)
  • install_dir – The directory in which the source is actually

untarred into. (ex: client/profilers/<name> for profilers)

kernel(base_tree, results_dir='', tmp_dir='', leave=False)[source]

Summon a kernel object

monitor_disk_usage(max_rate)[source]

Signal that the job should monitor disk space usage on / and generate a warning if a test uses up disk space at a rate exceeding ‘max_rate’.

Parameters:
max_rate - the maximium allowed rate of disk consumption
during a test, in MB/hour, or 0 to indicate no limit.
next_step(fn, *args, **dargs)[source]

Create a new step and place it after any steps added while running the current step but before any steps added in previous steps

next_step_append(fn, *args, **dargs)[source]

Define the next step and place it at the end

next_step_prepend(fn, *args, **dargs)[source]

Insert a new step, executing first

noop(text)[source]
parallel(*args, **dargs)[source]

Run tasks in parallel

partition(device, loop_size=0, mountpoint=None)[source]

Work with a machine partition

param device:e.g. /dev/sda2, /dev/sdb1 etc...
param mountpoint:
 Specify a directory to mount to. If not specified autotest tmp directory will be used.
param loop_size:
 Size of loopback device (in MB). Defaults to 0.
return:A L{client.partition.partition} object
quit()[source]
reboot(tag=<object object>)[source]
reboot_setup()[source]
relative_path(path)[source]

Return a patch relative to the job results directory

require_gcc()[source]

Test whether gcc is installed on the machine.

run_group(function, tag=None, **dargs)[source]

Run a function nested within a group level.

Parameters:
  • function – Callable to run.
  • tag – An optional tag name for the group. If None (default)

function.__name__ will be used. :param dargs: Named arguments for the function.

run_test(*args, **dargs)[source]

Summon a test object and run it.

:param url A url that identifies the test to run. :param tag An optional keyword argument that will be added to the test and subdir name. :param subdir_tag An optional keyword argument that will be added to the subdir name.

Returns:True if the test passes, False otherwise.
run_test_detail(*args, **dargs)[source]

Summon a test object and run it, returning test status.

:param url A url that identifies the test to run. :param tag An optional keyword argument that will be added to the test and subdir name. :param subdir_tag An optional keyword argument that will be added to the subdir name.

Returns:Test status
See:client/shared/error.py, exit_status
setup_dep(deps)[source]

Set up the dependencies for this test. deps is a list of libraries required for this test.

setup_dirs(results_dir, tmp_dir)[source]
start_reboot()[source]
step_engine()[source]

The multi-run engine used when the control file defines step_init.

Does the next step.

xen(base_tree, results_dir='', tmp_dir='', leave=False, kjob=None)[source]

Summon a xen object

class autotest.client.job.disk_usage_monitor(logging_func, device, max_mb_per_hour)[source]
start()[source]
stop()[source]
classmethod watch(*monitor_args, **monitor_dargs)[source]

Generic decorator to wrap a function call with the standard create-monitor -> start -> call -> stop idiom.

class autotest.client.job.job(control, options, drop_caches=True, extra_copy_cmdline=None)[source]

Bases: autotest.client.job.base_client_job

autotest.client.job.runjob(control, drop_caches, options)[source]

Run a job using the given control file.

This is the main interface to this module.

See:base_job.__init__ for parameter info.
autotest.client.job.site_job

alias of base_client_job

class autotest.client.job.status_indenter(job)[source]

Bases: autotest.client.shared.base_job.status_indenter

Provide a status indenter that is backed by job._record_prefix.

decrement()[source]
increment()[source]
indent

kernel Module

class autotest.client.kernel.BootableKernel(job)[source]

Bases: object

add_to_bootloader(args='')[source]
autotest.client.kernel.auto_kernel(job, path, subdir, tmp_dir, build_dir, leave=False)[source]

Create a kernel object, dynamically selecting the appropriate class to use based on the path provided.

class autotest.client.kernel.kernel(job, base_tree, subdir, tmp_dir, build_dir, leave=False)[source]

Bases: autotest.client.kernel.BootableKernel

Class for compiling kernels.

Data for the object includes the src files used to create the kernel, patches applied, config (base + changes), the build directory itself, and logged output

Properties:
job
Backpointer to the job object we’re part of
autodir
Path to the top level autotest dir (see global_config.ini, session COMMON/autotest_top_path)
src_dir
<tmp_dir>/src/
build_dir
<tmp_dir>/linux/
config_dir
<results_dir>/config/
log_dir
<results_dir>/debug/
results_dir
<results_dir>/results/
apply_patches(local_patches)[source]

apply the list of patches, in order

autodir = ''
boot(args='', ident=True)[source]

install and boot this kernel, do not care how just make it happen.

build(*args, **dargs)
build_timed(threads, timefile='/dev/null', make_opts='', output='/dev/null')[source]

time the bulding of the kernel

clean(*args, **dargs)
config(*args, **dargs)
extract(*args, **dargs)
extraversion(tag, append=True)[source]
get_kernel_build_arch(arch=None)[source]

Work out the current kernel architecture (as a kernel arch)

get_kernel_build_ident()[source]
get_kernel_build_release()[source]
get_kernel_build_ver()[source]

Check Makefile and .config to return kernel version

get_kernel_tree(base_tree)[source]

Extract/link base_tree to self.build_dir

get_patches(patches)[source]

fetch the patches to the local src_dir

install(*args, **dargs)
kernelexpand(kernel)[source]
mkinitrd(*args, **dargs)
patch(*args, **dargs)
pickle_dump(filename)[source]

dump a pickle of ourself out to the specified filename

we can’t pickle the backreference to job (it contains fd’s), nor would we want to. Same for logfile (fd’s).

set_build_image(image)[source]
set_build_target(build_target)[source]
set_cross_cc(target_arch=None, cross_compile=None, build_target='bzImage')[source]

Set up to cross-compile. This is broken. We need to work out what the default compile produces, and if not, THEN set the cross compiler.

autotest.client.kernel.preprocess_path(path)
class autotest.client.kernel.rpm_kernel(job, rpm_package, subdir)[source]

Bases: autotest.client.kernel.BootableKernel

Class for installing a binary rpm kernel package

boot(args='', ident=True)[source]

install and boot this kernel

build(*args, **dargs)[source]

Dummy function, binary kernel so nothing to build.

install(*args, **dargs)
kernel_string = '/boot/vmlinuz'
class autotest.client.kernel.rpm_kernel_suse(job, rpm_package, subdir)[source]

Bases: autotest.client.kernel.rpm_kernel

Class for installing openSUSE/SLE rpm kernel package

add_to_bootloader(args='')[source]

Set parameters of this kernel in bootloader

install()[source]
kernel_string = '/boot/vmlinux'
autotest.client.kernel.rpm_kernel_vendor(job, rpm_package, subdir)[source]
class autotest.client.kernel.srpm_kernel(job, rpm_package, subdir)[source]

Bases: autotest.client.kernel.kernel

apply_patches(local_patches)[source]
binrpm_pattern = <_sre.SRE_Pattern object>
boot(args='')[source]
build(tag='autotest')[source]
config(*args, **kwargs)[source]
consume_one_config(config_option)[source]
finish_init()[source]
install(tag='autotest')[source]
prefix = '/root/rpmbuild'
prep(tag='autotest')[source]
setup_source()[source]
update_spec(tag)[source]
update_spec_line(line, outspec, tag)[source]
class autotest.client.kernel.srpm_kernel_suse(job, rpm_package, subdir)[source]

Bases: autotest.client.kernel.srpm_kernel

finish_init()[source]
prefix = '/usr/src/packages'
setup_source()[source]
update_spec_line(line, outspec, tag)[source]
autotest.client.kernel.srpm_kernel_vendor(job, rpm_package, subdir)[source]
autotest.client.kernel.tee_output_logdir_mark(fn)[source]

kernel_config Module

autotest.client.kernel_config.apply_overrides(orig_file, changes_file, output_file)[source]
autotest.client.kernel_config.config_by_name(name, s)[source]
autotest.client.kernel_config.diff_configs(old, new)[source]
autotest.client.kernel_config.feature_enabled(feature, config)[source]

Verify whether a given kernel option is enabled.

Parameters:
  • feature – Kernel feature, such as “CONFIG_DEFAULT_UIMAGE”.
  • config – Config file path, such as /tmp/config.
class autotest.client.kernel_config.kernel_config(job, build_dir, config_dir, orig_file, overrides, defconfig=False, name=None, make=None)[source]

Bases: object

Build directory must be ready before init’ing config.

Stages:
  1. Get original config file

  2. Apply overrides

  3. Do ‘make oldconfig’ to update it to current source code

    (gets done implicitly during the process)

You may specifiy the defconfig within the tree to build, or a custom config file you want, or None, to get machine’s default config file from the repo.

config_record(name)[source]

Copy the current .config file to the config.<name>[.<n>]

update_config(old_config, new_config=None)[source]
autotest.client.kernel_config.modules_needed(config)[source]

kernel_versions Module

autotest.client.kernel_versions.is_release_candidate(version)[source]
autotest.client.kernel_versions.is_released_kernel(version)[source]
autotest.client.kernel_versions.version_choose_config(version, candidates)[source]
autotest.client.kernel_versions.version_encode(version)[source]
autotest.client.kernel_versions.version_len(version)[source]
autotest.client.kernel_versions.version_limit(version, n)[source]

kernelexpand Module

Program and API used to expand kernel versions, trying to match them with the URL of the correspondent package on kernel.org or a mirror. Example:

$ ./kernelexpand.py 3.1 http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.1.tar.bz2

author:Andy Whitcroft (apw@shadowen.org)
copyright:IBM 2008
license:GPL v2
see:Inspired by kernelexpand by Martin J. Bligh, 2003
autotest.client.kernelexpand.decompose_kernel(kernel)[source]
autotest.client.kernelexpand.decompose_kernel_2x_once(kernel)[source]

Generate the parameters for the patches (2.X version):

full => full kernel name base => all but the matches suffix minor => 2.n.m major => 2.n minor-prev => 2.n.m-1

Parameters:kernel – String representing a kernel version to be expanded.
autotest.client.kernelexpand.decompose_kernel_post_2x_once(kernel)[source]

Generate the parameters for the patches (post 2.X version):

full => full kernel name base => all but the matches suffix minor => o.n.m major => o.n minor-prev => o.n.m-1

Parameters:kernel – String representing a kernel version to be expanded.
autotest.client.kernelexpand.expand_classic(kernel, mirrors)[source]
autotest.client.kernelexpand.get_mappings_2x()[source]
autotest.client.kernelexpand.get_mappings_post_2x()[source]
autotest.client.kernelexpand.mirror_kernel_components(mirrors, components)[source]
autotest.client.kernelexpand.select_kernel_components(components)[source]
autotest.client.kernelexpand.url_accessible(url)[source]

kvm_control Module

Utilities useful to client control files that test KVM.

autotest.client.kvm_control.get_kvm_arch()[source]

Get the kvm kernel module to be loaded based on the CPU architecture

Raises:error.TestError if no vendor name or cpu flags are found
Returns:‘kvm_amd’ or ‘kvm_intel’ or ‘kvm_power7’
Return type:string
autotest.client.kvm_control.load_kvm()[source]

Loads the appropriate KVM kernel modules depending on the current CPU architecture

Returns:0 on success or 1 on failure
Return type:int
autotest.client.kvm_control.unload_kvm()[source]

Unloads the current KVM kernel modules ( if loaded )

Returns:0 on success or 1 on failure
Return type:int

local_host Module

This file contains the implementation of a host object for the local machine.

class autotest.client.local_host.LocalHost(*args, **dargs)[source]

Bases: autotest.client.shared.hosts.base_classes.Host

list_files_glob(path_glob)[source]

Get a list of files on a remote host given a glob pattern path.

run(command, timeout=3600, ignore_status=False, stdout_tee=<object object>, stderr_tee=<object object>, stdin=None, args=())[source]
See:shared.hosts.Host.run()

Given a sequence of path strings, return the set of all paths that can be reached from the initial set by following symlinks.

Parameters:paths – sequence of path strings.
Returns:a sequence of path strings that are all the unique paths that can be reached from the given ones after following symlinks.
wait_up(timeout=None)[source]

lv_utils Module

Utility for taking shapshots from existing logical volumes or creates such.

author:Plamen Dimitrov
copyright:Intra2net AG 2012
license:GPL v2
param vg_name:Name of the volume group.
param lv_name:Name of the logical volume.
param lv_size:Size of the logical volume as string in the form “#G” (for example 30G).
param lv_snapshot_name:
 Name of the snapshot with origin the logical volume.
param lv_snapshot_size:
 Size of the snapshot with origin the logical volume also as “#G”.
param ramdisk_vg_size:
 Size of the ramdisk virtual group.
param ramdisk_basedir:
 Base directory for the ramdisk sparse file.
param ramdisk_sparse_filename:
 Name of the ramdisk sparse file.

Sample ramdisk params: - ramdisk_vg_size = “40000” - ramdisk_basedir = “/tmp” - ramdisk_sparse_filename = “virtual_hdd”

Sample general params: - vg_name=’autotest_vg’, - lv_name=’autotest_lv’, - lv_size=‘1G’, - lv_snapshot_name=’autotest_sn’, - lv_snapshot_size=‘1G’ The ramdisk volume group size is in MB.

autotest.client.lv_utils.lv_check(vg_name, lv_name)[source]

Check whether provided logical volume exists.

autotest.client.lv_utils.lv_list()[source]

List available group volumes.

autotest.client.lv_utils.thin_lv_create(vg_name, thinpool_name='lvthinpool', thinpool_size='1.5G', thinlv_name='lvthin', thinlv_size='1G')[source]

Create a thin volume from given volume group.

Parameters:
  • vg_name – An exist volume group
  • thinpool_name – The name of thin pool
  • thinpool_size – The size of thin pool to be created
  • thinlv_name – The name of thin volume
  • thinlv_size – The size of thin volume
autotest.client.lv_utils.vg_check(vg_name)[source]

Check whether provided volume group exists.

autotest.client.lv_utils.vg_list()[source]

List available volume groups.

autotest.client.lv_utils.vg_ramdisk_cleanup(ramdisk_filename=None, vg_ramdisk_dir=None, vg_name=None, loop_device=None)[source]

Inline cleanup function in case of test error.

optparser Module

Autotest client/local option parser

class autotest.client.optparser.AutotestLocalOptionParser[source]

Bases: optparse.OptionParser

Default autotest option parser

os_dep Module

class autotest.client.os_dep.Ldconfig[source]

Bases: object

class DirEntry(path, flag, ino, dev)[source]

Bases: object

Ldconfig.LD_SO_CONF = '/etc/ld.so.conf'
Ldconfig.MAX_RECURSION_DEPTH = 20
Ldconfig.ldconfig(ld_so_conf_filename='/etc/ld.so.conf', extra_dirs=('/lib', '/usr/lib', '/lib64', '/usr/lib64', '/lib/tls', '/usr/lib/tls', '/lib64/tls', '/usr/lib64/tls'))[source]

Read and parse /etc/ld.so.conf to generate a list of directories that ldconfig would search. Pre-seed the search directory list with (‘/lib’, ‘/usr/lib’, ‘/lib64’, ‘/usr/lib64’)

Parameters:
  • ld_so_conf_filename (str) – path to /etc/ld.so.conf
  • extra_dirs (iterable) –
Returns:

iterator over the directories found

Return type:

iterable

Ldconfig.parse_conf(filename='/etc/ld.so.conf', recursion=0)[source]
autotest.client.os_dep.command(target, *args, **kwargs)

Find a program by searching in the environment path and in common binary paths.

check both if it is a file and executable which always returns the abspath return ‘’ if failure because ‘’ is well-defined NULL path, so it is better than None or ValueError

Parameters:
  • program (str) – command name or path to command
  • extra_dirs (iterable) – iterable of extra paths to search
Returns:

abspath of command if found

Return type:

str

Raises:

ValueError – when program not found

autotest.client.os_dep.commands(*cmds)[source]
autotest.client.os_dep.exception_when_false_wrapper(func, exception_class, value_error_message_template)[source]

Wrap a function to raise an exception when the return value is not True.

Parameters:
  • func (function) – function to wrap
  • exception_class (Exception) – exception class to raise
  • value_error_message_template (str) – string to pass to exception
Returns:

wrapped function

Return type:

function

Raises:

exception_class – when func returns not true

autotest.client.os_dep.generate_bin_search_paths(program, extra_dirs)[source]

Generate full paths of potential locations of a given binary file based on COMMON_BIN_PATHS.

Use the enviroment variable $PATH seed the list of search directories.

Parameters:
  • program (str) – library filename to join with all search directories
  • extra_dirs (str) – extra directories to append to the directory search list
Returns:

iterator over all generated paths

Return type:

iter

autotest.client.os_dep.generate_include_search_paths(hdr, extra_dirs)[source]

Generate full paths of potential locations of a given header file based on COMMON_HEADER_PATHS.

Parameters:
  • hdr (str) – header filename to join with all search directories
  • extra_dirs (iterable) – extra directories to append to the directory search list
Returns:

iterator over all generated paths

Return type:

iterable

autotest.client.os_dep.generate_library_search_paths(lib, extra_dirs=('/lib', '/usr/lib', '/lib64', '/usr/lib64', '/lib/tls', '/usr/lib/tls', '/lib64/tls', '/usr/lib64/tls'), ld_so_conf_filename='/etc/ld.so.conf')[source]

Generate full paths of potential locations of a given library file based on COMMON_LIB_PATHS.

Parameters:
  • lib (str) – library filename to join with all search directories
  • extra_dirs (iterable) – extra directories to append to the directory search list
  • ld_so_conf_filename (str) – location of /etc/ld.so.conf to parse to find all system library locations
Returns:

iterator over all generated paths

Return type:

iterable

autotest.client.os_dep.header(target, *args, **kwargs)

Find a header file by searching in the common include search paths, (‘/usr/include’, ‘/usr/local/include’)

Check both if the header is a file and readable.

Parameters:
  • hdr (str) – header file or path to header file, e.g. stdio.h
  • extra_dirs (iterable) – iterable of extra paths to search
Returns:

abspath of header if found

Return type:

str

Raises:

ValueError – when header is not found

autotest.client.os_dep.headers(*hdrs)[source]
autotest.client.os_dep.is_file_and_readable(pth)[source]
Parameters:pth – path to check
Returns:true if the path is a file and R_OK
Return type:bool
autotest.client.os_dep.is_file_and_rx(pth)[source]
Parameters:pth – path to check
Returns:true if the path is a file and R_OK & X_OK
Return type:bool
autotest.client.os_dep.libraries(*libs)[source]
autotest.client.os_dep.library(target, *args, **kwargs)

Find a library file by parsing /etc/ld.so.conf and also searcing in the common library search paths, (‘/lib’, ‘/usr/lib’, ‘/lib64’, ‘/usr/lib64’, ‘/lib/tls’, ‘/usr/lib/tls’, ‘/lib64/tls’, ‘/usr/lib64/tls’)

Check both if the library is a file and readable.

Parameters:
  • lib (str) – library file or path to library file, e.g. libc.so.6
  • extra_dirs (iterable) – iterable of extra paths to search
Returns:

abspath of library if found

Return type:

str

Raises:

ValueError – when library is not found

autotest.client.os_dep.make_path_searcher(path_generator, target_predicate, target_normalizer, extra_paths, **kwargs)[source]

Universal search function generator using lazy evaluation.

Generate a function that will iterate over all the paths from path_generator using target_predicate to filter matching paths. Each matching path is then noramlized by target_predicate. Only the first match is returned.

Parameters:
  • path_generator (iterator) – all paths to test with target_predicate
  • target_predicate (function) – boolean function that tests a given path
  • target_normalizer (function) – function that transforms a matching path to some noramlized form
  • extra_paths (iterator) – extra paths to pass to the path_generator
Returns:

the path searching function

Return type:

function

autotest.client.os_dep.path_joiner(target, search_paths)[source]

Create a generator that joins target to each search path

Parameters:
  • target (str) – filename to join to each search path
  • search_paths (iterator) – iterator over all the search paths
Returns:

iterator over all the joined paths

Return type:

iterator

autotest.client.os_dep.unique_not_false_list(arg_paths)[source]
autotest.client.os_dep.which(target, extra_dirs=('/usr/libexec', '/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin'))

Find a program by searching in the environment path and in common binary paths.

check both if it is a file and executable which always returns the abspath return ‘’ if failure because ‘’ is well-defined NULL path, so it is better than None or ValueError

Parameters:
  • program (str) – command name or path to command
  • extra_dirs (iterble) – iterable of extra paths to search
Returns:

abspath of command if found, else ‘’

Return type:

str

autotest.client.os_dep.which_header(target, extra_dirs=frozenset([]))

Find a header file by searching in the common include search paths, (‘/usr/include’, ‘/usr/local/include’)

Check both if the header is a file and readable.

Parameters:
  • hdr (str) – header file or path to header file, e.g. stdio.h
  • extra_dirs (iterable) – iterable of extra paths to search
Returns:

abspath of header if found, else ‘’

Return type:

str

autotest.client.os_dep.which_library(target, extra_dirs=('/lib', '/usr/lib', '/lib64', '/usr/lib64', '/lib/tls', '/usr/lib/tls', '/lib64/tls', '/usr/lib64/tls'))

Find a library file by parsing /etc/ld.so.conf and also searcing in the common library search paths, (‘/lib’, ‘/usr/lib’, ‘/lib64’, ‘/usr/lib64’, ‘/lib/tls’, ‘/usr/lib/tls’, ‘/lib64/tls’, ‘/usr/lib64/tls’)

Check both if the library is a file and readable.

Parameters:
  • lib (str) – library file or path to library file, e.g. libc.so.6
  • extra_dirs (iterable) – iterable of extra paths to search
Returns:

abspath of library if found, else ‘’

Return type:

str

parallel Module

Parallel execution management

autotest.client.parallel.fork_nuke_subprocess(tmp, pid)[source]
autotest.client.parallel.fork_start(tmp, l)[source]
autotest.client.parallel.fork_waitfor(tmp, pid)[source]
autotest.client.parallel.fork_waitfor_timed(tmp, pid, timeout)[source]

Waits for pid until it terminates or timeout expires. If timeout expires, test subprocess is killed.

partition Module

APIs to write tests and control files that handle partition creation, deletion and formatting.

copyright:Google 2006-2008
author:Martin Bligh (mbligh@google.com)
class autotest.client.partition.FsOptions(fstype, fs_tag, mkfs_flags=None, mount_options=None)[source]

Bases: object

A class encapsulating a filesystem test’s parameters.

fs_tag
fstype
mkfs_flags
mount_options
autotest.client.partition.filesystems()[source]

Return a list of all available filesystems

autotest.client.partition.filter_partition_list(partitions, devnames)[source]

Pick and choose which partition to keep.

filter_partition_list accepts a list of partition objects and a list of strings. If a partition has the device name of the strings it is returned in a list.

Parameters:
  • partitions – A list of L{partition} objects
  • devnames – A list of devnames of the form ‘/dev/hdc3’ that specifies which partitions to include in the returned list.
Returns:

A list of L{partition} objects specified by devnames, in the order devnames specified

autotest.client.partition.get_iosched_path(device_name, component)[source]
autotest.client.partition.get_mount_info(partition_list)[source]

Picks up mount point information about the machine mounts. By default, we try to associate mount points with UUIDs, because in newer distros the partitions are uniquely identified using them.

autotest.client.partition.get_partition_list(job, min_blocks=0, filter_func=None, exclude_swap=True, open_func=<built-in function open>)[source]

Get a list of partition objects for all disk partitions on the system.

Loopback devices and unnumbered (whole disk) devices are always excluded.

Parameters:
  • job – The job instance to pass to the partition object constructor.
  • min_blocks – The minimum number of blocks for a partition to be considered.
  • filter_func – A callable that returns True if a partition is desired. It will be passed one parameter: The partition name (hdc3, etc.). Some useful filter functions are already defined in this module.
  • exclude_swap – If True any partition actively in use as a swap device will be excluded.
  • __open – Reserved for unit testing.
Returns:

A list of L{partition} objects.

autotest.client.partition.get_unmounted_partition_list(root_part, job=None, min_blocks=0, filter_func=None, exclude_swap=True, open_func=<built-in function open>)[source]

Return a list of partition objects that are not mounted.

Parameters:
  • root_part

    The root device name (without the ‘/dev/’ prefix, example ‘hda2’) that will be filtered from the partition list.

    Reasoning: in Linux /proc/mounts will never directly mention the root partition as being mounted on / instead it will say that /dev/root is mounted on /. Thus require this argument to filter out the root_part from the ones checked to be mounted.

  • min_blocks, filter_func, exclude_swap, open_func (job,) – Forwarded to get_partition_list().
Returns:

List of L{partition} objects that are not mounted.

autotest.client.partition.is_linux_fs_type(device)[source]

Checks if specified partition is type 83

Parameters:device – the device, e.g. /dev/sda3
Returns:False if the supplied partition name is not type 83 linux, True otherwise
autotest.client.partition.is_valid_disk(device)[source]

Checks if a disk is valid

Parameters:device – e.g. /dev/sda, /dev/hda
autotest.client.partition.is_valid_partition(device)[source]

Checks if a partition is valid

Parameters:device – e.g. /dev/sda1, /dev/hda1
autotest.client.partition.list_mount_devices()[source]
autotest.client.partition.list_mount_points()[source]
autotest.client.partition.parallel(partitions, method_name, *args, **dargs)[source]

Run a partition method (with appropriate arguments) in parallel, across a list of partition objects

class autotest.client.partition.partition(job, device, loop_size=0, mountpoint=None)[source]

Bases: object

Class for handling partitions and filesystems

fsck(args='-fy', record=True)[source]

Run filesystem check

Parameters:args – arguments to filesystem check tool. Default is “-n” which works on most tools.
get_fsck_exec()[source]

Return the proper mkfs executable based on self.fstype

get_io_scheduler(device_name)[source]
get_io_scheduler_list(device_name)[source]
get_mountpoint(open_func=<built-in function open>, filename=None)[source]

Find the mount point of this partition object.

Parameters:
  • open_func – the function to use for opening the file containing the mounted partitions information
  • filename – where to look for the mounted partitions information (default None which means it will search /proc/mounts and/or /etc/mtab)
Returns:

a string with the mount point of the partition or None if not mounted

mkfs(fstype=None, args='', record=True)[source]

Format a partition to filesystem type

Parameters:
  • fstype – the filesystem type, e.g.. “ext3”, “ext2”
  • args – arguments to be passed to mkfs command.
  • record – if set, output result of mkfs operation to autotest output
mkfs_exec(fstype)[source]

Return the proper mkfs executable based on fs

mount(mountpoint=None, fstype=None, args='', record=True)[source]

Mount this partition to a mount point

Parameters:
  • mountpoint – If you have not provided a mountpoint to partition object or want to use a different one, you may specify it here.
  • fstype – Filesystem type. If not provided partition object value will be used.
  • args – Arguments to be passed to “mount” command.
  • record – If True, output result of mount operation to autotest output.
run_test(test, **dargs)[source]
run_test_on_partition(test, mountpoint_func, **dargs)[source]

Executes a test fs-style (umount,mkfs,mount,test)

Here we unmarshal the args to set up tags before running the test. Tests are also run by first umounting, mkfsing and then mounting before executing the test.

Parameters:
  • test – name of test to run
  • mountpoint_func – function to return mount point string
set_fs_options(fs_options)[source]

Set filesystem options

param fs_options:
 A L{FsOptions} object
set_io_scheduler(device_name, name)[source]
setup_before_test(mountpoint_func)[source]

Prepare a partition for running a test. Unmounts any filesystem that’s currently mounted on the partition, makes a new filesystem (according to this partition’s filesystem options) and mounts it where directed by mountpoint_func.

Parameters:mountpoint_func – A callable that returns a path as a string, given a partition instance.
unmount(ignore_status=False, record=True)[source]

Umount this partition.

It’s easier said than done to umount a partition. We need to lock the mtab file to make sure we don’t have any locking problems if we are umounting in paralllel.

If there turns out to be a problem with the simple umount we end up calling umount_force to get more aggressive.

Parameters:
  • ignore_status – should we notice the umount status
  • record – if True, output result of umount operation to autotest output
unmount_force()[source]

Kill all other jobs accessing this partition. Use fuser and ps to find all mounts on this mountpoint and unmount them.

Returns:true for success or false for any errors
wipe()[source]

Delete all files of a given partition filesystem.

autotest.client.partition.partname_to_device(part)[source]

Converts a partition name to its associated device

autotest.client.partition.run_test_on_partitions(job, test, partitions, mountpoint_func, tag, fs_opt, do_fsck=True, **dargs)[source]

Run a test that requires multiple partitions. Filesystems will be made on the partitions and mounted, then the test will run, then the filesystems will be unmounted and optionally fsck’d.

Parameters:
  • job – A job instance to run the test
  • test – A string containing the name of the test
  • partitions – A list of partition objects, these are passed to the test as partitions=
  • mountpoint_func – A callable that returns a mountpoint given a partition instance
  • tag – A string tag to make this test unique (Required for control files that make multiple calls to this routine with the same value of ‘test’.)
  • fs_opt – An FsOptions instance that describes what filesystem to make
  • do_fsck – include fsck in post-test partition cleanup.
  • dargs – Dictionary of arguments to be passed to job.run_test() and eventually the test
autotest.client.partition.unmount_partition(device)[source]

Unmount a mounted partition

Parameters:device – e.g. /dev/sda1, /dev/hda1
class autotest.client.partition.virtual_partition(file_img, file_size)[source]

Handles block device emulation using file images of disks. It’s important to note that this API can be used only if we have the following programs present on the client machine:

  • sfdisk
  • losetup
  • kpartx
destroy()[source]

Removes the virtual partition from /dev/mapper, detaches the image file from the loopback device and removes the image file.

autotest.client.partition.wipe_filesystem(job, mountpoint)[source]

profiler Module

class autotest.client.profiler.profiler(job)[source]
initialize(*args, **dargs)[source]
preserve_srcdir = False
report(test)[source]
setup(*args, **dargs)[source]
start(test)[source]
stop(test)[source]
supports_reboot = False

setup Module

autotest.client.setup.get_data_files()[source]
autotest.client.setup.get_filelist()[source]
autotest.client.setup.get_package_data()[source]
autotest.client.setup.get_package_dir()[source]
autotest.client.setup.get_packages()[source]
autotest.client.setup.get_scripts()[source]
autotest.client.setup.run()[source]

setup_job Module

autotest.client.setup_job.init_test(options, testdir)[source]

Instantiate a client test object from a given test directory.

:param options Command line options passed in to instantiate a setup_job
which associates with this test.

:param testdir The test directory. :return: A test object or None if failed to instantiate.

autotest.client.setup_job.load_all_client_tests(options)[source]

Load and instantiate all client tests.

This function is inspired from runtest() on client/shared/test.py.

Parameters:options – an object passed in from command line OptionParser. See all options defined on client/autotest.
Returns:a tuple containing the list of all instantiated tests and a list of tests that failed to instantiate.
class autotest.client.setup_job.setup_job(options)[source]

Bases: autotest.client.job.job

setup_job is a job which runs client test setup() method at server side.

This job is used to pre-setup client tests when development toolchain is not available at client.

autotest.client.setup_job.setup_test(client_test)[source]

Direct invoke test.setup() method.

Returns:A boolean to represent success or not.
autotest.client.setup_job.setup_tests(options)[source]

Load and instantiate all client tests.

This function is inspired from runtest() on client/shared/test.py.

Parameters:options – an object passed in from command line OptionParser. See all options defined on client/autotest.

setup_modules Module

Module used to create the autotest namespace for single dir use case.

Autotest programs can be used and developed without requiring it to be installed system-wide. In order for the code to see the library namespace:

from autotest.client.shared import error from autotest.server import hosts ...

Without system wide install, we need some hacks, that are performed here.

author:John Admanski (jadmanski@google.com)
autotest.client.setup_modules.import_module(module, from_where)[source]

Equivalent to ‘from from_where import module’.

Parameters:
  • module – Module name.
  • from_where – Package from where the module is being imported.
Returns:

The corresponding module.

autotest.client.setup_modules.setup(base_path, root_module_name='autotest')[source]

Setup a library namespace, with the appropriate top root module name.

Perform all the necessary setup so that all the packages at ‘base_path’ can be imported via “import root_module_name.package”.

Parameters:
  • base_path – Base path for the module.
  • root_module_name – Top level name for the module.

sysinfo Module

test Module

autotest.client.test.runtest(job, url, tag, args, dargs)[source]
class autotest.client.test.test(job, bindir, outputdir)[source]

Bases: autotest.client.shared.test.base_test

configure_crash_handler()[source]
Configure the crash handler by:
  • Setting up core size to unlimited
  • Putting an appropriate crash handler on /proc/sys/kernel/core_pattern
  • Create files that the crash handler will use to figure which tests are active at a given moment

The crash handler will pick up the core file and write it to self.debugdir, and perform analysis on it to generate a report. The program also outputs some results to syslog.

If multiple tests are running, an attempt to verify if we still have the old PID on the system process table to determine whether it is a parent of the current test execution. If we can’t determine it, the core file and the report file will be copied to all test debug dirs.

crash_handler_report()[source]

If core dumps are found on the debugdir after the execution of the test, let the user know.

test_config Module

Wrapper around ConfigParser to manage testcases configuration.

author:rsalveti@linux.vnet.ibm.com (Ricardo Salveti de Araujo)
class autotest.client.test_config.config_loader(cfg, tmpdir='/tmp', raise_errors=False)[source]

Base class of the configuration parser

check(section)[source]

Check if the config file has valid values

check_parameter(param_type, parameter)[source]

Check if a option has a valid value

get(section, option, default=None)[source]

Get the value of a option.

Section of the config file and the option name. You can pass a default value if the option doesn’t exist.

Parameters:
  • section – Configuration file section.
  • option – Option we’re looking after.
Default:

In case the option is not available and raise_errors is set to False, return the default.

remove(section, option)[source]

Remove an option.

save()[source]

Save the configuration file with all modifications

set(section, option, value)[source]

Set an option.

This change is not persistent unless saved with ‘save()’.

utils Module

Convenience functions for use by tests or whomever.

NOTE: this is a mixin library that pulls in functions from several places Note carefully what the precendece order is

There’s no really good way to do this, as this isn’t a class we can do inheritance with, just a collection of static methods.

xen Module

class autotest.client.xen.xen(job, base_tree, results_dir, tmp_dir, build_dir, leave=False, kjob=None)[source]

Bases: autotest.client.kernel.kernel

add_to_bootloader(tag='autotest', args='')[source]

add this kernel to bootloader, taking an optional parameter of space separated parameters e.g.: kernel.add_to_bootloader(‘mykernel’, ‘ro acpi=off’)

build(make_opts='', logfile='', extraversion='autotest')[source]

build xen

make_opts
additional options to make, if any
build_timed(*args, **kwds)[source]
config(config_file, config_list=None)[source]
fix_up_xen_kernel_makefile(kernel_dir)[source]

Fix up broken EXTRAVERSION in xen-ified Linux kernel Makefile

get_xen_build_ver()[source]

Check Makefile and .config to return kernel version

get_xen_kernel_build_ver()[source]

Check xen buildconfig for current kernel version

install(tag='', prefix='/', extraversion='autotest')[source]

make install in the kernel tree

log(msg)[source]

Subpackages