Page History
...
- Any file without an extension is treated as a test script. This script will be installed and run.
- Any file with a that looks like C or C++ code (.c, .cpp extension, etc) is treated as a C++ test program. It will be compiled, installed, and run.
- If a test script or program returns non-zero, it failed and scons will report this.
Simple Examples
Other files in the test directory are ignoredBelow we go over a few simple examples of unit tests.
Python Unit Test
Add the file MyPkg/test/myfirst
Code Block | ||
---|---|---|
| ||
#!@PYTHON@ |
...
import sys |
...
if __name__ == '__main__': |
...
print "Running my test." |
...
sys.exit(1) |
When you do scons test, you will get the output
Code Block |
---|
Running UnitTest: "build/x86_64-rhel5-gcc41-opt/MyPkg/myfirst" |
...
************************************************************************************ |
...
*** Unit test failed, check log file build/x86_64-rhel5-gcc41-opt/MyPkg/myfirst.utest *** |
...
************************************************************************************ |
If
...
you
...
look at the file build/x86_64-rhel5-gcc41-opt/MyPkg/myfirst.utest you see the output of the script.
The syntax @PYTHON@ is explaied explained in the SConsTools page.
C++ Unit Test
...
Overview
Content Tools