-
Notifications
You must be signed in to change notification settings - Fork 2
Write and run a simple test script
A test is just a script contained in a file with extension ".vvt". Any executable script can be run under vvtest, but there are convenient utility functions available for the Python and sh/bash languages. If the script file is not executable, then Python is assumed.
In an empty directory, create a file called one.vvt with these contents:
#!/bin/sh
echo "this test will pass"and make it executable with chmod +x one.vvt. Create another file called two.vvt with these contents:
import sys
print ( "this test will fail" )
sys.exit(1)You now have two tests that can be run with vvtest.
Change directory to where the test files are located and run vvtest.
ews01212% ls
one.vvt two.vvt
ews01212% vvtest
==================================================
Test list:
completed: 0
notrun: 2
total: 2
Start time: Fri Dec 31 13:13:31 2021
Platform ceelan, num cores = 4, max cores = 4, max devices = 0
Starting: TestResults.ceelan/two
Starting: TestResults.ceelan/one
Finished: pass 0:01 12/31 13:13:31 TestResults.ceelan/one
Finished: fail 0:01 12/31 13:13:31 TestResults.ceelan/two
Progress: 2/2 = %100.0, time = 1s
==================================================
fail 0:01 12/31 13:13:31 TestResults.ceelan/two
==================================================
Summary:
completed: 2
1 pass
1 fail
total: 2
Finish date: Fri Dec 31 13:13:32 2021 (elapsed time 1s)
Test directory: TestResults.ceelan
ews01212% ls
one.vvt TestResults.ceelan two.vvt
In this test sequence, one test passed and the other failed, as expected. To rerun the tests, make sure to rm -rf TestResults.* first, otherwise previous results will change the behavior.
The test scripts are run in a sub-directory of the current working directory, the name of which is printed at the very end. In this example, the execution directory is TestResults.ceelan.
The name of a test is the name of the test file without the extension. In this case, the test names are "one" and "two".
Within the execution directory is a separate sub-directory for each test, which contains the working files and output files for the test.
TestResults.ceelan/
test.cache
testlist
testlist.2021-12-31_13h13m32s
one/
one.vvt # a soft link back to the original
vvtest_util.py
vvtest_util.sh
execute.log
two/
two.vvt # a soft link back to the original
vvtest_util.py
vvtest_util.sh
execute.log
Note that the test scripts themselves are soft linked back to the originals. The output from each of the tests is contained in the file called execute.log (which contains both stdout and stderr).
ews01212% cat one/execute.log
Cleaning execute directory for execution...
Linking and copying working files...
ln -s /home/rrdrake/Projects/vvtest/temp/one.vvt one.vvt
Starting test: one
Directory : /home/rrdrake/Projects/vvtest/temp/TestResults.ceelan/one
Command : ./one.vvt
Timeout : 3600
this test will pass