client Package¶
autotest_local
Module¶
base_sysinfo
Module¶
-
class
autotest.client.base_sysinfo.
base_sysinfo
(job_resultsdir)[source]¶ Bases:
object
-
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)¶
-
-
class
autotest.client.base_sysinfo.
command
(cmd, logf=None, log_in_keyval=False, compress_log=False)[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.
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.
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 – A list of cpu flags that must exists on the current CPU. :type flags: list :returns: bool True if all the flags were found or False if not :rtype: list
-
autotest.client.base_utils.
difflist
(list1, list2)[source]¶ returns items in list2 that are not in list1
-
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
-
autotest.client.base_utils.
force_link
(src, dest)[source]¶ Link src to dest, overwriting it if it exists
-
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_name
()[source]¶ Get the current cpu vendor name
Returns: string ‘intel’ or ‘amd’ or ‘power7’ depending on the current CPU architecture. :rtype: string
-
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_modules_dir
()[source]¶ Return the modules dir for the running kernel version
-
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.
list_grep
(list, pattern)[source]¶ True if any item in list matches the specified pattern.
-
autotest.client.base_utils.
locate
(pattern, root='/home/docs/checkouts/readthedocs.org/user_builds/autotest/checkouts/0.16.0/documentation/source')[source]¶
-
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.
set_wake_alarm
(alarm_time)[source]¶ Set the hardware RTC-based wake alarm to ‘alarm_time’.
-
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 trhow an error.CmdError exception.
Parameters: module_name – 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).
bkr_proxy
Module¶
bkr_proxy - class used to talk to beaker
-
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
bkr_xml
Module¶
module to parse beaker xml recipe
-
class
autotest.client.bkr_xml.
BeakerXMLParser
[source]¶ Bases:
object
Handles parsing of beaker job xml
client_logging_config
Module¶
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.
-
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
-
classmethod
help
()[source]¶ List the commands and their usage strings.
:param args is not used here.
-
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
cpuset
Module¶
-
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
name = arbitrary string tag mbytes = reqested memory for job in megabytes 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 move_in = True: Move current process into the new container now. timeout = must be 0: persist until explicitly deleted.
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
-
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.
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.
-
-
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.
ext_mkfs_options
(tune2fs_dict, mkfs_option)[source]¶ Map the tune2fs options to mkfs options.
-
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.
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.
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_reboot
()[source]¶ A run within this job is performing a reboot (expect continue following reboot)
harness_ABAT
Module¶
harness_autoserv
Module¶
-
class
autotest.client.harness_autoserv.
AutoservFetcher
(package_manager, job_harness)[source]¶ Bases:
autotest.client.shared.base_packages.RepositoryFetcher
-
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.
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
-
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
-
run_reboot
()[source]¶ A run within this job is performing a reboot (expect continue following reboot)
-
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.
-
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
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
-
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‘])
-
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
-
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. 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)
-
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
-
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
-
run_group
(function, tag=None, **dargs)[source]¶ Run a function nested within a group level.
- function:
- Callable to run.
- tag:
- An optional tag name for the group. If None (default) function.__name__ will be used.
- **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.
-
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
kernel
Module¶
-
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/
-
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)¶
-
get_kernel_build_arch
(arch=None)[source]¶ Work out the current kernel architecture (as a kernel arch)
-
install
(*args, **dargs)¶
-
mkinitrd
(*args, **dargs)¶
-
patch
(*args, **dargs)¶
-
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
-
install
(*args, **dargs)¶
-
-
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
kernel_config
Module¶
-
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:
Get original config file
Apply overrides
- 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.
kernel_versions
Module¶
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_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.
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 foundReturns: ‘kvm_amd’ or ‘kvm_intel’ or ‘kvm_power7’ Return type: string
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
-
run
(command, timeout=3600, ignore_status=False, stdout_tee=<object object>, stderr_tee=<object object>, stdin=None, args=())[source]¶ @see shared.hosts.Host.run()
-
symlink_closure
(paths)[source]¶ 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.
-
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.
optparser
Module¶
Autotest client/local option parser
-
class
autotest.client.optparser.
AutotestLocalOptionParser
[source]¶ Bases:
optparse.OptionParser
Default autotest option parser
os_dep
Module¶
parallel
Module¶
Parallel execution management
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.
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_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.
- root_part –
-
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.
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_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
-
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_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
-
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
-
-
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
profiler
Module¶
setup
Module¶
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.
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¶
-
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.
-
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
-
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.
-
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
-
Subpackages¶
- net Package
- profilers Package
profilers
Package- Subpackages
- shared Package
autotemp
Modulebarrier
Modulebase_barrier
Modulebase_check_version
Modulebase_job
Modulebase_packages
Modulebase_syncdata
Moduleboottool
Modulecheck_version
Modulecommon
Modulecontrol_data
Moduledistro
Moduledistro_def
Moduleenum
Moduleerror
Modulegit
Modulehost_protections
Modulehost_queue_entry_states
Moduleiscsi
Moduleiso9660
Modulejsontemplate
Modulekernel_versions
Modulelog
Modulelogging_config
Modulelogging_manager
Modulemagic
Modulemail
Modulemock
Moduleopenvswitch
Modulepackages
Modulepexpect
Modulepidfile
Moduleprofiler_manager
Moduleprogressbar
Modulepxssh
Modulereport
Moduleservice
Modulesettings
Modulesoftware_manager
Modulessh_key
Modulesyncdata
Moduletest
Moduleutils
Moduleutils_cgroup
Moduleutils_koji
Moduleutils_memory
Moduleversion
Module- Subpackages
- tools Package