File: run-simple-server-test

package info (click to toggle)
gdbuspp 3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,116 kB
  • sloc: cpp: 9,462; python: 477; sh: 215; makefile: 6
file content (80 lines) | stat: -rwxr-xr-x 1,594 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#  GDBus++ - glib2 GDBus C++ wrapper
#
#  SPDX-License-Identifier: AGPL-3.0-only
#
#  Copyright (C)  OpenVPN Inc <sales@openvpn.net>
#  Copyright (C)  David Sommerseth <davids@openvpn.net>
#

set -eu

##
# @file tests/scripts/run-simple-server-test
#
# @brief Runs a test script provided via the command line
#        after start the test_simple-service D-Bus service
#
#        This is used to run tests through meson and other
#        automated testing frameworks
#

export SERVICE_PID=""
export FAILED_RESULT=0

start_service()
{
    echo "Starting simple-server: ${BUILD_DIR:-.}/test_simple-service"
    ${BUILD_DIR:-.}/test_simple-service &
    SERVICE_PID=$!
    if [ ! -d /proc/${SERVICE_PID} ]; then
        echo "** FATAL ** test_simple-service didn't start"
        FAILED_RESULT=100
        exit 2
    fi
}

stop_service()
{
    kill -INT $SERVICE_PID
}

run_test()
{
    echo "-----------------------------------------------------------"
    echo "###  Running test: $@"
    echo
    # Do not fail the test driver when the test fails
    set +e
    eval $@
    ec=$?
    set -e
    echo
    echo ".."
    if [ ${ec} -ne 0 ]; then
        echo "..     ## Result: FAIL"
        FAILED_RESULT=$(($FAILED_RESULT + 1))
    else
        echo "..     Result: Pass"
    fi
    echo ".."
    echo
    echo "-----------------------------------------------------------"
    echo
}


start_service
sleep 1
echo "Simple Service PID: $SERVICE_PID"

# Run tests
run_test $@

sleep 1
stop_service

echo "$0: Test failed: $FAILED_RESULT"
if [ $FAILED_RESULT -gt 0 ]; then
    exit 1
fi