Debian Codegraph @

debian/tests/run-unit-test

raw
1 #!/bin/bash
2 set -e
3
4 pkg="gdpc"
5
6 if [ "$AUTOPKGTEST_TMP" = "" ] ; then
7 AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
8 trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
9 fi
10
11 check_n_cleanup () {
12 local gdpc_pids="$(
13 ps aux \
14 | awk "/^$USER"'.*bin[/]gdpc/ {print$2}' \
15 | xargs
16 )"
17
18 local xvfb_pids="$(
19 ps aux \
20 | awk -vORS=' ' "/^$USER"'.*[X]vfb/ {print$2}' \
21 | xargs
22 )"
23
24 if [ -n "$gdpc_pids" ]
25 then
26 kill $gdpc_pids
27 else
28 printf -- 'error: gdpc crashed before the end of the test\n' >&2
29 exit 1
30 fi
31 test -n "$xvfb_pids" && kill $xvfb_pids
32 }
33
34 cp -a /usr/share/doc/${pkg}/examples/* $AUTOPKGTEST_TMP
35
36 cd $AUTOPKGTEST_TMP
37
38 gunzip *.gz
39
40 rm -f test.log
41 set -v
42 #test recipe from README file
43 xvfb-run --auto-servernum \
44 /usr/bin/gdpc 2>&1 \
45 | tee --append test.log &
46 sleep 10
47 check_n_cleanup
48
49 xvfb-run --auto-servernum \
50 /usr/bin/gdpc cube 30 m 2 d 20 erase 1 2 3 4 liquid.test 2>&1 \
51 | tee --append test.log &
52 sleep 10
53 check_n_cleanup
54
55 xvfb-run --auto-servernum \
56 /usr/bin/gdpc m 2 d 10 erase xyz 2 3 4 5 md.test 2>&1 \
57 | tee --append test.log &
58 sleep 10
59 check_n_cleanup
60
61 xvfb-run --auto-servernum \
62 /usr/bin/gdpc m 2 d 10 erase usetypes xyz 2 3 4 5 manytypes.test 2>&1 \
63 | tee --append test.log &
64 sleep 10
65 check_n_cleanup
66 set +v
67
68 ls -l test.log
69 cat test.log
70
71 echo "PASS"