Skip to content

Running macchina.io Unit Tests

Günter Obiltschnig edited this page Mar 15, 2019 · 1 revision

Running macchina.io Unit Tests

macchina.io comes with a number of unit tests for the various libraries and components. In order to speed up the build, these tests are normally not built from the top-level Makefile. In order to build and run the tests, the following steps must be done (it's assumed macchina.io has already been built using the top-level Makefile):

1. Set-Up the macchina.io Build Environment

Run the env.bash script in the top-level macchina.io directory.

guenter@Darkstar:/ws/git/macchina-io/macchina.io> . env.bash 
macchina.io build environment set.

$MACCHINA_BASE     = /ws/git/macchina-io/macchina.io
$PROJECT_BASE      = /ws/git/macchina-io/macchina.io
$POCO_BASE         = /ws/git/macchina-io/macchina.io/platform
$MACCHINA_VERSION  = 0.10.0
$DYLD_LIBRARY_PATH = /ws/git/macchina-io/macchina.io/platform/lib/Darwin/x86_64::/usr/local/mysql/lib/

2. Build the CppUnit Library

$ cd platform/CppUnit
$ make -s -j4

3. Find the Unit Tests

Unit tests are always in a directory named testsuite within the specific library or component directory.

guenter@Darkstar:/ws/git/macchina-io/macchina.io> find . -name testsuite
./platform/RemotingNG/testsuite
./platform/RemotingNG/TCP/testsuite
./platform/Crypto/testsuite
./platform/Net/testsuite
./platform/OSP/Web/testsuite
./platform/OSP/testsuite
./platform/Util/testsuite
./platform/Redis/testsuite
./platform/CodeGeneration/testsuite
./platform/NetSSL_OpenSSL/testsuite
./platform/Geo/testsuite
./platform/Foundation/testsuite
./platform/XML/testsuite
./platform/Zip/testsuite
./platform/JSON/testsuite
./platform/CppParser/testsuite
./platform/Data/testsuite
./platform/Data/SQLite/testsuite
./protocols/Modbus/testsuite
./services/UnitsOfMeasure/testsuite
./devices/CAN/testsuite
./devices/GNSS/NMEA/testsuite
./devices/Devices/testsuite

4. Build and Run a Specific Test

In this example we'll run the Devices tests.

First, building the test suite:

guenter@Darkstar:/ws/git/macchina-io/macchina.io/devices/Devices/testsuite> make -s -j4
** Creating dependency info for src/Driver.cpp
** Creating dependency info for src/DevicesTestSuite.cpp
** Creating dependency info for src/EventModerationPolicyTest.cpp
** Compiling src/EventModerationPolicyTest.cpp (debug, shared)
** Compiling src/DevicesTestSuite.cpp (debug, shared)
** Compiling src/Driver.cpp (debug, shared)
** Compiling src/EventModerationPolicyTest.cpp (release, shared)
** Compiling src/DevicesTestSuite.cpp (release, shared)
** Compiling src/Driver.cpp (release, shared)
** Building shared executable (debug) /ws/git/macchina-io/macchina.io/devices/Devices/testsuite/bin/Darwin/x86_64/testrunnerd
** Building shared executable (release) /ws/git/macchina-io/macchina.io/devices/Devices/testsuite/bin/Darwin/x86_64/testrunner

Then, running it:

guenter@Darkstar:/ws/git/macchina-io/macchina.io/devices/Devices/testsuite> bin/Darwin/x86_64/testrunner -all

testNoModerationPolicy: 
testMinimumDeltaModerationPolicy: 
testMaximumRateModerationPolicy: 

OK (3 tests)