User Tools

Site Tools


test

Usage

There are several levels of testing done on iotivity. The most commonly used is the unit tests, which are required for new code developments, and run automatically by several of the Jenkins jobs kicked off for each proposed change.

To run the full supported unit test suite on Linux, do the following. Will run twice, first unsecured build, then secured build.

./autobuild.py unit_tests

To run a specific test on a specific configuration:

scons LOGGING=1 VERBOSE=1 TEST=1 RELEASE=false SECURED=1 resource/csdk/stack/test/

You can use the –gtest_filter option to selectively turn on or off tests. Example:

$ export LD_LIBRARY_PATH=<the out folder on you system>
$ cd out/linux/x86_64/debug/resource/csdk/stack/test # <-- as an example
$ ./stacktest --gtest_filter=OCIpv6*
# will only run the tests that start with OCIpv6 
$ ./stacktest --gtest_filter=-*StackStartSuccessClient:*CreateResrouceWithClientStackMode
# run all but the two tests listed (':' is a separator) note the '-' minus sign at the start. 
$ ./stacktest --gtest_filter=*DISABLED* --gtest_also_run_disabled_tests
# run tests that have been disabled in the code.

Googletest gives a lot of control over what you run and don't run using command line options. Run the test with a -h option to see more gtest options.

Status Reports

master branch scan (2017-11-15)

$ find * -iname "SConscript" -exec grep -H 'TODO' {} \; | grep -i test

resource/csdk/security/provisioning/unittest/SConscript:        # TODO: remove this workaround needed for g++-4.7
resource/csdk/security/unittest/SConscript:    # TODO: Implement feature check.
resource/unittests/SConscript:# TODO: IOT-2039: Fix errors in the following Windows tests.
service/easy-setup/enrollee/unittests/SConscript:            '',  # TODO enable previous line when valigrind error resolved in resource layer
service/easy-setup/mediator/richsdk/unittests/SConscript:            '',  # TODO: fix this test and enable previous line
service/notification/cpp-wrapper/unittest/SConscript:# TODO: Fix this test for more configs and remove this commented line
service/notification/unittest/SConscript:            '',  # TODO: Fix this test for MLK and enable previous line
service/notification/unittest/SConscript:            '',  # TODO: Fix this test for MLK and enable previous line
service/resource-container/unittests/SConscript:# TODO: fix this test and edit commented lines and target_os
service/resource-container/unittests/SConscript:    if target_os in ['TODO/linux'
service/resource-encapsulation/src/resourceBroker/unittest/SConscript:            '',  # TODO: fix this test on linux and enable previous line

2016-12-14

Jenkins (CI) will run unit_tests on linux with SECURED=0 and SECURED=1 on master branch on all subsystems (currently service and resource https://gerrit.iotivity.org/gerrit/#/c/15291/).

Some tests have been bypassed because they are failing, leaking memory or not terminating, so they need to be fixed by developers. Let's try to fix “resource” codebase first in master branch first, then pick patches to 1.2-rel branch, for “service” codebase it can be more relaxed (bypass) in shorter term.

All unit tests should support all CI configurations flags (or most, ie: SECURED=0 and SECURED=1 modes). If not possible then they need to be bypassed in code or better in scons file, please comment explicitly why a configuration can't be supported (or report bug and link it).

Current UT issues to be investigated can be found easily using this simple command:

master branch

On master branch (1.2-rel as well):

find . -iname "SConscript" -exec grep -H 'TODO' {} \; | grep -i test

./resource/unittests/SConscript:# TODO: Fix errors in the following Windows tests.
./resource/csdk/SConscript:    # TODO: Switch Linux to use a Static library for testing like every other OS.
./resource/csdk/connectivity/test/SConscript:# TODO: fix test in supported configurations
./resource/csdk/resource-directory/unittests/SConscript:# TODO: fix test for all supported configurations
./resource/csdk/security/provisioning/unittest/SConscript:# TODO: fix test for all supported configurations
./resource/csdk/security/unittest/SConscript:   # TODO: Implement feature check.
./resource/csdk/stack/test/SConscript:# TODO: fix test in all supported configurations
./service/...

If your module is in this list, then you're welcome to “take” this task and let it know on this “temporary” wiki page: https://wiki.iotivity.org/wiki/test

Once done remove TODO and related commented lines and make sure to pass memcheck file to valgrind to track memory leaks.

Unit tests fail on Darwin build when built SECURED=1

Darwin build failure due to deadman timer timing out.

test.txt · Last modified: 2017/11/22 11:59 by Phil Coval