Skip to content

Files

Latest commit

9739d4d · Mar 2, 2025

History

History

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 4, 2024
Mar 16, 2007
Feb 17, 2015
Nov 1, 2010
Oct 6, 2006
May 9, 2014
Jan 31, 2025
Jan 30, 2025
Jan 30, 2025
Oct 22, 2009
Apr 19, 2014
Nov 1, 2010
Jan 11, 2024
Aug 14, 2022
Jan 11, 2024
Mar 27, 2024
Feb 2, 2025
Sep 2, 2021
Sep 2, 2021
Jun 18, 2016
Oct 29, 2020
Nov 4, 2024
Nov 4, 2024
Jan 30, 2025
Apr 10, 2017
Jan 8, 2024
Feb 12, 2025
Nov 4, 2024
Nov 4, 2024
Feb 16, 2022
Feb 2, 2025
Feb 2, 2025
Feb 16, 2019
Sep 10, 2015
Jan 31, 2025
Jan 30, 2025
Nov 4, 2024
Mar 2, 2025
Nov 4, 2024
Feb 2, 2025
Jan 30, 2025
Dec 15, 2013
Jan 30, 2025
Feb 12, 2025
Jan 30, 2025
Nov 4, 2024
Dec 23, 2012
Dec 5, 2018
Oct 25, 2010
Feb 2, 2025
Jan 30, 2025
Sep 2, 2021
Jul 27, 2024
Aug 8, 2022
Jan 30, 2025
Nov 4, 2024
Jul 16, 2022
Feb 2, 2025
Jan 11, 2024
Oct 30, 2006
Nov 4, 2024
Nov 1, 2010
Nov 25, 2024
Nov 4, 2024
Nov 1, 2010
Jan 30, 2025
Jan 30, 2025
Jan 30, 2025
Jan 30, 2025
Feb 2, 2025
Jun 10, 2020
Sep 2, 2021
Jan 30, 2025
Dec 31, 2007
Nov 4, 2024
Nov 4, 2024
Feb 2, 2025
Jan 30, 2025
Feb 2, 2025
Apr 22, 2020
Apr 22, 2020
Jul 16, 2022
Dec 23, 2015
Jul 16, 2022
Jun 10, 2020
The HAL test suite
~~~~~~~~~~~~~~~~~~~
The tests in these directories serve to test the behavior of HAL components.

Each subdirectory of this directory may contain a test item.  The runtests
script recurses through the directory structure, so multiple tests could
be structured as
	tests/
		xyz.0
		xyz.1
		xyz.2
or
	tests/
		xyz/
			0	
			1	
			2	


Two types of tests are supported: Regression tests, in which the output is
tested against a "known good" output, and functional tests, in which the
output is fed to a program that can determine whether it is correct or not


Running the tests
~~~~~~~~~~~~~~~~~
Currently, tests only work with the "run in place" configuration.  They
can be run by executing (from the top emc2 directory)
	scripts/runtests tests
A subset of the tests can also be run:
	scripts/runtests tests/xyz tests/a*

To only run the tests that do not require root or sudo access, use the
-u option:

	scripts/runtests -u tests

The directories named on the commandline are searched recursively for
'test.hal' or 'test.sh' files, and a directory with such a file is
assumed to contain a regression test or a functional test.

Tests may contain files other than the ones specified below.  For instance,
when using 'streamer' data as test input, a shell script with
"halstreamer<<EOF" and a "here document" will generally be present.
(see and-or-not-mux.0/runstreamer for an example)

Regression Tests
~~~~~~~~~~~~~~~~
A regression test should consist of these three files:
	README
		A human-readable file describing the test
	test.hal *or* test.sh *or* test
		The test script to execute.  test.hal is executed with
		'halrun -f', test.sh is executed with 'bash -x', and
		test is executed as ./test
	expected
		A file whose contents are compared with the stdout of
			halrun -f test.hal

A typical regression test will load several components, usually including
'threads' and 'sampler', and often including 'streamer', then collect samples
from some number of calls to the realtime thread, then exit.

Regression test "test.hal" files will almost always include the line
	setexact_for_test_suite_only
which causes HAL to act as though the requested base_period was available.
Otherwise, results will differ slightly depending on the actual base_period
and regression tests will fail.

The test passes if the expected and actual output are identical.
Otherwise, the test fails.


Functional Tests
~~~~~~~~~~~~~~~~
A functional test should consist of three files:
	README
		A human-readable file describing the test
	test.hal *or* test.sh *or* test
		The test script to execute.  test.hal is executed with
		'halrun -f', test.sh is executed with 'bash -x', and
		test is executed as ./test
	checkresult
		An executable file (such as a shell or python script)
		which determines if the stdout of
			halrun -f test.hal
		indicates success or failure

Regression test "test.hal" files will often include the line
	setexact_for_test_suite_only
which causes HAL to act as though the requested base_period was available.
Otherwise, results will differ slightly depending on the actual base_period,
which could affect whether 'checkresult' gives an accurate result.

A typical regression test will load several components, usually including
'threads' and 'sample', then collect samples from some number of calls
to the realtime thread, then exit.  'checkresult' will look at the output
and see if it indicates success.

The test passes if the command "checkresult actual" returns a shell
success value (exit code 0).  Otherwise, the test fails.

Tests requiring root or sudo access are flagged by creating a file
named control in the test directory, with the 'sudo' flag in the
Restrictions field:

  Restrictions: sudo

Other restrictions might be added in the future