Debian Codegraph @

debian/tests/run-unit-test

raw
1 #!/bin/bash
2 set -e
3
4 pkg=odin
5
6 export LC_ALL=C.UTF-8
7 if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
8 AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
9 trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
10 fi
11
12 check_n_cleanup () {
13 local process="$1"
14 local pids="$(
15 ps aux \
16 | awk "/^$USER"'.*bin[/]'"$process"'/ {print$2}' \
17 | xargs
18 )"
19
20 local xvfb_pids="$(
21 ps aux \
22 | awk -vORS=' ' "/^$USER"'.*[X]vfb/ {print$2}' \
23 | xargs
24 )"
25
26 if [ -n "$pids" ]
27 then
28 kill $pids
29 else
30 echo "error: $process crashed before the end of the test" >&2
31 exit 1
32 fi
33 test -n "$xvfb_pids" && kill $xvfb_pids
34 }
35
36
37 cd "${AUTOPKGTEST_TMP}"
38 mkdir home
39 export HOME="${AUTOPKGTEST_TMP}/home"
40
41 set -x
42
43 # Generate a radially inhomogenous coil
44 gencoil -rad -n 16 -fov 90 -R 50% -o coil1.out
45 # Generate an array coil by rotating pre-existing image file
46 gencoil -rot -n 16 -fov 90 -nc 1 -i coil1.out -sl 1 -o coil2.out
47 # Generate an array coil consisting of simple loops
48 gencoil -arr -n 16 -nc 16 -fov 90 -R 16 -o coil3.out
49 # Generate coil with a B1 gradient
50 gencoil -grad -n 16 -fov 90 -g 1 -o coil4.out
51
52 # Generate makefile for odin methods
53 genmakefile src > Makefile
54 file Makefile | grep -q 'Makefile: makefile script'
55
56 # Create a point-spread function
57 gensample -psf -t1 1 -t2 2 -o sample1.out
58 # Create rectangle of uniform spin distribution about origin in all 3 spatial
59 # dimensions
60 gensample -uni -n 16 -f 9 -o sample2.out
61 # Create an isochromat distribution
62 gensample -iso -n 16 -df 20 -t1 1 -t2 2 -o sample3.out
63 # Create a homogenous disk with given radius
64 gensample -dsk -n 16 -f 90 -R 16 -o sample4.out
65 # Create coaxial cylinder
66 gensample -cyl -n 16 -f 90 -Xi 200 -Xo 400 -Ri 4 -Ro 32 -o sample5.out
67
68 # Mirror bytes
69 printf '12345678' > bytes1.out
70 swab 2 bytes1.out bytes2.out
71 swab 4 bytes1.out bytes4.out
72 swab 8 bytes1.out bytes8.out
73 test "$(cat bytes1.out)" = 12345678
74 test "$(cat bytes2.out)" = 21436587
75 test "$(cat bytes4.out)" = 43218765
76 test "$(cat bytes8.out)" = 87654321
77
78 # Superficial GUI checks
79 xvfb-run --auto-servernum /usr/bin/odin &
80 sleep 10
81 check_n_cleanup odin
82
83 xvfb-run --auto-servernum /usr/bin/geoedit &
84 sleep 10
85 check_n_cleanup geoedit
86
87 xvfb-run --auto-servernum /usr/bin/pulsar &
88 sleep 10
89 check_n_cleanup pulsar