]>
iEval git - linux-seccomp.git/blob - libseccomp/tests/testgen
4 # libseccomp test output generator
6 # Copyright (c) 2013 Red Hat <pmoore@redhat.com>
7 # Author: Paul Moore <paul@paul-moore.com>
11 # This library is free software; you can redistribute it and/or modify it
12 # under the terms of version 2.1 of the GNU Lesser General Public License as
13 # published by the Free Software Foundation.
15 # This library is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
20 # You should have received a copy of the GNU Lesser General Public License
21 # along with this library; if not, see <http://www.gnu.org/licenses>.
28 # Dependency verification
31 # 1 Dependency to check for
33 function verify_deps
() {
34 [[ -z "$1" ]] && return
35 if ! which "$1" >& /dev
/null
; then
36 echo "error: install \"$1\" and include it in your \$PATH"
42 # Print out script usage details
46 usage: regression [-h] [-d] [-l LABEL]
48 libseccomp test output generator script
50 -h show this help message and exit
51 -b generate BPF output
52 -d generate disassembled BPF output
53 -p generate PFC output
54 -v perform valgrind checks
55 -l [LABEL] specifies label for the test output
60 # Print the test result
63 # 1 string containing generated test number
64 # 2 string containing the test result
66 function print_result
() {
67 printf "Test %s result: %s\n" "$1" "$2"
74 # 1 string containing output label
76 function run_tests
() {
87 for file in *-sim-*.tests
; do
88 # extract the batch name from the file name
89 batch_name
=$
(basename $file .tests
)
91 if [[ -x "$batch_name" ]]; then
92 if [[ $opt_pfc -eq 1 ]]; then
93 .
/$batch_name > ${batch_name}${label}.pfc
95 stats_all
=$
(($stats_all + 1))
96 if [[ $rc -eq 0 ]]; then
97 print_result
"$batch_name [pfc]" "SUCCESS"
99 stats_failure
=$
(($stats_failure + 1))
100 print_result
"$batch_name [pfc]" "FAILURE"
104 if [[ $opt_bpf -eq 1 ]]; then
105 .
/$batch_name -b > ${batch_name}${label}.bpf
107 stats_all
=$
(($stats_all + 1))
108 if [[ $rc -eq 0 ]]; then
109 print_result
"$batch_name [bpf]" "SUCCESS"
111 stats_failure
=$
(($stats_failure + 1))
112 print_result
"$batch_name [bpf]" "FAILURE"
116 if [[ $opt_disasm -eq 1 ]]; then
118 ..
/tools
/scmp_bpf_disasm
> ${batch_name}${label}.bpfd
120 stats_all
=$
(($stats_all + 1))
121 if [[ $rc -eq 0 ]]; then
122 print_result
"$batch_name [bpfd]" "SUCCESS"
124 stats_failure
=$
(($stats_failure + 1))
125 print_result
"$batch_name [bpfd]" "FAILURE"
129 if [[ $opt_valgrind -eq 1 ]]; then
130 valgrind
--tool=memcheck \
131 --quiet --error-exitcode=1 \
133 --read-var-info=yes \
134 --track-origins=yes \
135 --suppressions=valgrind_test.supp \
136 -- .
/$batch_name -b > /dev
/null
138 stats_all
=$
(($stats_all + 1))
139 if [[ $rc -eq 0 ]]; then
140 print_result
"$batch_name [valgrind]" "SUCCESS"
142 stats_failure
=$
(($stats_failure + 1))
143 print_result
"$batch_name [valgrind]" "FAILURE"
147 stats_failure
=$
(($stats_failure + 1))
148 print_result
"$batch_name" "FAILURE"
164 while getopts "bphdl:v" opt
; do
189 [[ $opt_valgrind -eq 1 ]] && verify_deps valgrind
194 # display the test output and run the requested tests
195 echo "=============== $(date) ==============="
196 echo "Collecting Test Output (\"testgen $*\")"
197 run_tests
"$opt_label"
199 echo " tests run: $stats_all"
200 echo " tests failed: $stats_failure"
201 echo "============================================================"
205 [[ $stats_failure -gt 0 ]] && rc
=$
(($rc + 2))
This page took 0.055335 seconds and 4 git commands to generate.