Debian Codegraph @

tests/scripts/run-simple-server-test

raw
1 #!/bin/bash
2 # GDBus++ - glib2 GDBus C++ wrapper
3 #
4 # SPDX-License-Identifier: AGPL-3.0-only
5 #
6 # Copyright (C) OpenVPN Inc <[email protected]>
7 # Copyright (C) David Sommerseth <[email protected]>
8 #
9
10 set -eu
11
12 ##
13 # @file tests/scripts/run-simple-server-test
14 #
15 # @brief Runs a test script provided via the command line
16 # after start the test_simple-service D-Bus service
17 #
18 # This is used to run tests through meson and other
19 # automated testing frameworks
20 #
21
22 export SERVICE_PID=""
23 export FAILED_RESULT=0
24
25 start_service()
26 {
27 echo "Starting simple-server: ${BUILD_DIR:-.}/test_simple-service"
28 ${BUILD_DIR:-.}/test_simple-service &
29 SERVICE_PID=$!
30 if [ ! -d /proc/${SERVICE_PID} ]; then
31 echo "** FATAL ** test_simple-service didn't start"
32 FAILED_RESULT=100
33 exit 2
34 fi
35 }
36
37 stop_service()
38 {
39 kill -INT $SERVICE_PID
40 }
41
42 run_test()
43 {
44 echo "-----------------------------------------------------------"
45 echo "### Running test: $@"
46 echo
47 # Do not fail the test driver when the test fails
48 set +e
49 eval $@
50 ec=$?
51 set -e
52 echo
53 echo ".."
54 if [ ${ec} -ne 0 ]; then
55 echo ".. ## Result: FAIL"
56 FAILED_RESULT=$(($FAILED_RESULT + 1))
57 else
58 echo ".. Result: Pass"
59 fi
60 echo ".."
61 echo
62 echo "-----------------------------------------------------------"
63 echo
64 }
65
66
67 start_service
68 sleep 1
69 echo "Simple Service PID: $SERVICE_PID"
70
71 # Run tests
72 run_test $@
73
74 sleep 1
75 stop_service
76
77 echo "$0: Test failed: $FAILED_RESULT"
78 if [ $FAILED_RESULT -gt 0 ]; then
79 exit 1
80 fi