The UML test suiteThe tests to be done during a particular test run are specified by the parent directory, if you want all of the tests in that directory to run, an individual test, or any combination of directories and files. The tests are able to specify the properties of the UML in which they are to run. The test harness compiles and runs UMLs according to the test requirements, trying to minimize the number of builds and boots required to satisfy all of the tests' requirements. The tests vary widely in what they test and how they work. The simplest ones run a command (which they may have compiled themselves) and check the return value. Others run gdb and make it step through a test program to check that breakpoints work correctly. These use an already-booted UML, and don't need any special setup of the UML. In contrast, there are tests which have requirements of the UML. For example, the boot_filesystems test checks that a user-specified set of filesystems boots correctly. So, it requests an unbooted UML for its use, but puts no more requirements on it. Others test various configurable options, and request a UML with certain options enabled, which they boot. Finally, there are tests which stress the kernel generally in order to make sure that it is stable under a hard workload. The kbuild test, which runs a kernel build, is an example of this.
The main reason would be to do a sanity-check on UML when compiled locally, with whatever unusual config options you favor, and run on your hardware. UML is somewhat sensitive to toolchain changes, and, to a less extent, to the host hardware. Users regularly shake out bugs that don't appear during development, and these are often exposed by different toolchains and hardware.
First, download the latest version from the test suite section of the UML download page.host% wget http://www.user-mode-linux.org/mirror/uml_tests_20040726.tar.bz2Uncompress and extract ithost% bunzip2 uml_tests_20040726.tar.bz2host% tar xf uml_tests_20040726.tarSet up a ~/.umltest, which is the config file needed to tell the harness about the external resources, such as filesystems, and other information it will need in order to run. The file contains a perl hash, with different types of information under different keys. If you don't know perl, don't panic, because the syntax is simple enough. Mine looks like this:{ kernel_pool => "/home/jdike/linux/2.4/um", uml => { ubd => { 0 => "/home/jdike/roots/debian_22" }, mem => "64M", cow_ubds => 1, prompts => { "/home/jdike/roots/debian_22" => "usermode:.*#" }, }, tests => { "filesystems/boot_filesystems" => { filesystems => [ "/home/jdike/roots/debian_22" ], time => 0 }, "stress/kbuild" => { kernel_pool => "/home/jdike/roots/kernel", time => 0 }, }, }The kernel_pool tells the harness the location of a UML source pool. This will be where it builds whatever UMLs it needs.
The tests are all under the "tests" directory, each in a separate perl file. Here is a very simple test, commented:# Virtually all tests will need these two modules. The first defines # the Test object, an instance of which is returned from here. The # second is a library of useful utilities which essentially all of the # tests use. use UML::Test; use UML::Testlib; # strict is good use strict; # This function is the actual test. It will be run inside a booted # UML, at the shell. run_exit_0 is from TestLib. It runs the dd # command within the UML object given to the test, returning if the # command had an exit status of 0, and dying if not. In this case, # the harness will trap that and report the failure. sub run { my $test = shift; my $uml = shift; run_exit_0($uml, "dd if=/dev/mem of=/dev/null"); } # This constructs the Test object and returns it. This specifies that # this test be run in a booted UML (state => "up") and that the test # is contained in the 'run' function. UML::Test->new(state => "up", run => \&run);This illustrates the two essential features of a test |