Codebase list ngs-sdk / 0b229e0
Rewriting the autopkgtest to test the as-installed package Previously the autopkgtest rebuilt the libs in the source tree. Pierre Gruet 2 years ago
1 changed file(s) with 36 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
00 #!/bin/sh
11
22 # Author: Lance Lin <LQi254@protonmail.com>
3 # Pierre Gruet <pgt@debian.org>
34 # Date: 18 February 2022
5 # 3 May 2022
46 # File: run-unit-test
57 # Purpose: run a simple-unit test for the ngs-sdk package
68 #
79 # Details:
8 # Run the built-in test (make test) for the ngs-sdk package
10 # Run the tests after building them against the libs in the -dev package.
911
1012 set -e
1113
12 cd ngs-sdk
13 echo "run-unit-test: running configure"
14 ./configure
15 echo "run-unit-test: making test"
16 make test
17 echo "run-unit-test: done"
14 pkg=ngs-sdk
15
16 export LC_ALL=C.UTF-8
17 if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
18 AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
19 trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
20 fi
21
22 cp -a ngs-sdk/test/ "${AUTOPKGTEST_TMP}"
23 cd "${AUTOPKGTEST_TMP}/test"
24
25 # Building the test-engine lib
26 cd test_engine
27 g++ -c -I/usr/include/ngs/unix/generic -Wall -fpic *.cpp
28 g++ -shared -o libtest_engine.so *.o
29
30 # Building the test file against the lib and the test-engine lib.
31 cd ../ngs-test
32 g++ -I../../ -I/usr/include/ngs/unix/generic -L../test_engine -Wall -o test main.cpp -ltest_engine -lngs-c++ -lngs-adapt-c++
33
34 # Running the tests and collecting the results in outputTest
35 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:../test_engine" ./test > outputTest
36
37 # Now outputTest should contain something like
38 # "Test cases run: 107
39 # Test cases passed: 107"
40 # So we remove everything before the colons, remove duplicates and check there
41 # remains only one line in the file (i.e. the count of passing tests is the
42 # same as the count of tests).
43 sed 's/.*: //' outputTest | uniq | wc -l | grep -q "1"
44 if [ $? -eq 0 ]; then
45 echo "All tests PASSED"
46 fi