-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtest.sh
executable file
·137 lines (120 loc) · 6.59 KB
/
test.sh
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#
# COPYRIGHT AND PERMISSION NOTICE
#
# Copyright (C) 2016 CESNET, z.s.p.o.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the distribution.
# 3. Neither the name of the Company nor the names of its contributors may
# be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# ALTERNATIVELY, provided that this notice is retained in full, this product
# may be distributed under the terms of the GNU General Public License (GPL)
# version 2 or later, in which case the provisions of the GPL apply INSTEAD OF
# those given above.
#
# This software is provided "as is", and any express or implied warranties,
# including, but not limited to, the implied warranties of merchantability
# and fitness for a particular purpose are disclaimed. In no event shall the
# company or contributors be liable for any direct, indirect, incidental,
# special, exemplary, or consequential damages (including, but not limited to,
# procurement of substitute goods or services; loss of use, data, or profits;
# or business interruption) however caused and on any theory of liability,
# whether in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even if
# advised of the possibility of such damage.
#
# ===========================================================================
#
test -z "$srcdir" && export srcdir=.
test -z "$builddir" && export builddir=.
if [ "$srcdir" != "$builddir" ]; then
exit 77
fi
# Check import pytrap, skip this test on import error
python3 -c 'import pytrap' 2>/dev/null || exit 77
python3 $srcdir/setup.py test || exit $?
path_to_logger="$srcdir"/../../modules/logger/logger
input="
H4sIAOwfilcAA8WW24/bRBSHJ0VIqKjcKqBcCqZUgKDxzozHM56uBM0m6WJtuvHaTukCxfgWiNRu
lm5a1KpQKt5AQoLCC0gIVPWZv6G0qhAPwAuqEFJB4q3ioiL1GY6deOO46e4iluKRc3LO+DLfOfOb
8QaUHKX3Oot+FB1Sao7rmdaOgefY1cQ73FnocaZMzbt1J3Ma5uyMN2W63m6z3qjt6HUOxopr7qmD
bztuzm9UwE1u0qhiVaozdbf/DMLTl1lN2818x7S8Pc60585b9XzMcStuy/GqzdowDCNbvtVQaqad
G0w/ZtlNt1ltNgauW7W83Y3KtJP5zeV/bmPHUu9QZ+GV9G3VSqNRr3lWxXbni3Fzdnp8h2fWRkJO
fS7v2/W5Vh1oW7aZD7ecuu1Vpuuzbj6616wgtOkyuoQGxwfty92/4Mj8H6Y+T/3NG9DI8eDz0WT1
103PZbYEsfObQ/R+6fxmdGd6yd1pexLdj2poE5qDSP9U0FJncScVzCBSYLGrFy/11PDY2CDDnHCD
cm7sIox7BFOPaswjhBhCZ4pdnzYdt24DygRV8USrZilwnQrXqXCdCtft1DHHq/NdKo3ynfyoOpNw
ZTbj+wrdOD597Xx/ZON+9ezGEb5TX9ipf6ZQv4unF7ceAq7MJnzfAN+Hw/op0B5Ak/D7AroFhRDp
nw+nfBgzwphOsSQsGbxQidBVgyZjSvqF4Dg5C10Sh7oIua/jiAVt0U74KaFS4jgIfKNNFHN2rwni
zxNjIJUaUA+ABUa/LwNfjUeBFS31jxUK+suZT7YnoJkdA/wotHuQBOB5APYh0j/7BSWGzobQgsuU
TKOqTjJmgjEZjWrYYO0Ah2EUyJhhKrnGiUYT1ohwqV0PlzIdcMmQ98/rFvj7c6n/RoG3+u6BxxPO
zI7hfQTaVvQ08L0EvG2I9M9BgZ8qFpgSqIHU8xVWlkuc6yRcD3yNBCKMo9hIyqvrNBZaO+A4ph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N5cO99snH
dQR46G4E7cAbxw15mwj3nQ8FBnitPhk260ZW6yu+gBKMpNY21VSlIpU2E5BjhYs17XL5AoQcVzas
6ZV/eXUomrq1qHkbcmrZcK/VIZegcpoWGSBEUwZDUmjIciJTyaA4/DF142y4ufvKZd52yYYADXmb
CN8Qb1UgN3TfxUlH8lpkibf/AfgoaPqlIgAA
"
data="`mktemp`"
out="`mktemp`"
echo -n "$input" | base64 -d | gunzip > "$data"
errors=0
$srcdir/../examples/python/python_example.py -i "f:$data,f:$out:w" | sed 's/ \([0-9]*\)L,/ \1,/g' > orig-data-parsed.txt
$srcdir/../examples/python/python_example.py -i "f:$out,b:" | sed 's/ \([0-9]*\)L,/ \1,/g' > processed-data-parsed.txt
diff orig-data-parsed.txt <(echo -n "$expected" | base64 -d | gunzip) || {
echo "Historically stored expected output does not match with the current one. Test failed."
((errors++))
}
diff orig-data-parsed.txt processed-data-parsed.txt || {
echo "Python returns different output. Test failed."
((errors++))
}
if [ -x "$path_to_logger" ]; then
"$path_to_logger" -t -i "f:$data" > logger-orig.txt
"$path_to_logger" -t -i "f:$out" > logger-processed.txt
diff -u logger-orig.txt logger-processed.txt || {
echo "Logger verification of python output data failed. Test failed."
((errors++))
}
else
echo "Logger was not found, skipping test!!! The test should be repeated with $path_to_logger present."
fi
rm -f "$data" "$out" logger-orig.txt logger-processed.txt orig-data-parsed.txt processed-data-parsed.txt
exit $errors