This repository allows building and checking smews. The main script is the smews_test script. It takes one mandatory parameter, the smews folder.
When run, for each test suites in the test_suites folder it will generate all possible configuration for all available smews targets and for an ipv4 and an ipv6. For each configuration, it will:
- Build smews
- Run smews
- Perform all test in the tests folder of the test suite
- Perform all target dependent tests in the
tests/targets/<target>folder of the test suite
The general form for invoking the script is the following:
smews_test <smews_folder> [logfile=<file>] [targets=<target1,...,targetN] [test_suites=ts1,...,tsN] [tests=test1,...,testN] [disable=<configuration>] [ips=ip1,...,ipN]
The first parameter must always be the smews folder (relative or absolute). All other parameters are optionals
logfilea file name where to ouput the test reports. This output is done in csv format. Defaults totest.csv. Warning the script does not overwrite the log file, it always append at the end of the file,targetsis a comma separated list of targets. Only those targets will be tested. Defaults to all targets,test_suitesis a comma separated list of test suites to perform. Defaults to all test suites,testsis a comma separated list of tests to perform. Defaults to all tests,disableis a value for disable options. Thus, only this configuration willl be tested. Warning it completly overrides alldisableandnodisablefiles of the test suites. Defaults to test all possible combinations,ipsis a list of ips to build. If the{}string is included in an IP address, it will be replaced by a number between11and11 + #targetswhere#targetsis the number of smews targets. This allows multiple targets to be connected to the same test platform without getting same IPs on the same LAN. Defaults to192.168.100.{}andfc23::{}
Test suites are available in the test_suites folder. All the tests of a test suites are run on the same running instance of smews. Thus, for each configuration, smews is built and run, then all the tests are performed (including target dependent). Then, smews is killed and another configuration is tested. You can tweak a test suite by following means:
-
You can develop specific applications that needs to be included in the smews build for your test suite to work. Any folder in the
<test_suite>/appsfolder will be considered as a smews application, copied to the smews folder and included in its build. -
Any application (of the
smews/appsfolder) can be included in the build by listing its name in anuseappsfile in the test suite folder. One application per line. -
A test suite may be designed only for given targets. To do so, list the targets in the
targetfile, again one target per line. -
A test suite may be designed for all targets except some. To do so, list the targets to exclude in the
notargetfile, one target per line. Warning, this is combined with the previous file. Thus, if a target is listed in thenotargetfile, it will not be tested, even if it is present in thetargetfile. -
By default, suites are tested for every possible combination of disable options. You may force an option to be disabled or to be activated using
disableandnodisablefile. For example, if we suppose that the options that can be disabled in smews arecometandpost, by default, the test suite will be run for each of the following build (thedisable=...thing is the scons parameter for building smews):disable=disable=cometdisable=postdisable=comet,post
If the
disablefile containscomet, then the test will be with:disable=cometdisable=comet,post
If the
nodisablefile containscometand there is nodisablefile, the builds will be:disable=disable=post
A test can be any kind of executable for example a shell or python script (must
have the x bit though and the right usual #!... comment in first line):
- It will be called with two parameters: the ip address of the tested smews and the target name,
- It must exit with code 0 if test worked as expected or any positive value otherwise,
- If the test is generic, it must be added in the tests folder,
- If the test is target dependent, it must be added in the
<test_suite>/tests/target/<target>folder, - The test are run in lexical sort order but all the generic tests will be performed before the target dependant tests
- a
test_download.shscript is available in the tools folder. You can consider that this script is in the PATH environment variable when your test is run, This script takes 3 parameters: the ip from which to download, the url and optionaly the expected http response code (200 is used if no value is given). The script returns true if all goes well.
To add a target, you must implement 4 scripts in the tools/<target>
folder. The folder name is the one used by smews in its target folder
(for example linux,mbed_ethernet...).
programThis script is called with the smews folder as the first parameter. When called, smews has been successfuly built for your target (and thus available in$1/bin/<target>with$1beeing the smews folder). You must program the device with the built image.is_alivereturns true if the smews server is still running. It is not used by the test framework but may be used by some tests to check if smews has crashedkillstops the smews server on the target,runrun smews on the target
Advanced filters can be used to validate and modify a configuration before it is built and tested. You can have a global filter and per test suites filters.
The main goal behind is to avoid tests that fail not because of an error, but
because of a normal incompatible configuration. For example, the
mbed_ethernet target needs the icmpv6 app to be built when the ip is set
to an IPv6 one. The provided advanced filter will automatically add this
application if the test framework generates a configuration for mbed_ethernet
target with IPv6. Furthermore, if the icmpv6 application has to be included,
then Smews can not be built without support for generic purpose ip
handler. Thus, the provided global filter will tell the framework to discard a
configuration where the icmpv6 application is included and the
general_purpose_ip_handler disable option is set.
An advanced filter consist in a python script called filter.py that defines a
function filter(build_options), the build_options parameter beeing a
associative array (dict) of build configuration value. The key of the array
is the scons option name (i.e. disable, ipaddr, target...) and the
value is a string representing the value of the option (if the option is
multivalued, the string is a comma separated list). The function can manipulate
the build_options array (i.e. modify values, remove values, add values) and
must return True if the build configuration is valid (and should be tested)
and False if it is incompatible by design and thus not to be tested.
The filter.py scripts must be located at the root of a test suite folder to
be loaded and run for this particular test suite. A global filter is provided
and is located at the root of the test_suites folder. The global filter is
always called before the test suite specific one.
How can I use an application only for some targets ?
One way is to create a dedicated test suite with the application and the corresponding targets listed in the
targetornotarget. If needed, you can simlink tests from other test suites to avoid re-writing them.
A better way would be to use an advanced filter that checks the target and adds or removes a particular application for a given target.