Rewriting the autopkgtest to test the as-installed package
Previously the autopkgtest rebuilt the libs in the source tree.
Pierre Gruet
2 years ago
0 | 0 | #!/bin/sh |
1 | 1 | |
2 | 2 | # Author: Lance Lin <LQi254@protonmail.com> |
3 | # Pierre Gruet <pgt@debian.org> | |
3 | 4 | # Date: 18 February 2022 |
5 | # 3 May 2022 | |
4 | 6 | # File: run-unit-test |
5 | 7 | # Purpose: run a simple-unit test for the ngs-sdk package |
6 | 8 | # |
7 | 9 | # 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. | |
9 | 11 | |
10 | 12 | set -e |
11 | 13 | |
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 |