]> git.ipfire.org Git - thirdparty/glibc.git/blob - support/tst-support_record_failure-2.sh
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / support / tst-support_record_failure-2.sh
1 #!/bin/sh
2 # Test failure recording (with and without --direct).
3 # Copyright (C) 2016-2018 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>. */
19
20 set -e
21
22 common_objpfx=$1; shift
23 test_program_prefix_before_env=$1; shift
24 run_program_env=$1; shift
25 test_program_prefix_after_env=$1; shift
26
27 run_test () {
28 expected_status="$1"
29 expected_output="$2"
30 shift 2
31 args="${common_objpfx}support/tst-support_record_failure $*"
32 echo "running: $args"
33 set +e
34 output="$(${test_program_prefix_before_env} \
35 ${run_program} ${test_program_prefix_after_env} $args)"
36 status=$?
37 set -e
38 echo " exit status: $status"
39 if test "$output" != "$expected_output" ; then
40 echo "error: unexpected output: $output"
41 exit 1
42 fi
43 if test "$status" -ne "$expected_status" ; then
44 echo "error: exit status $expected_status expected"
45 exit 1
46 fi
47 }
48
49 different_status () {
50 direct="$1"
51 run_test 1 "error: 1 test failures" $direct --status=0
52 run_test 1 "error: 1 test failures" $direct --status=1
53 run_test 2 "error: 1 test failures" $direct --status=2
54 run_test 1 "error: 1 test failures" $direct --status=77
55 run_test 2 "error: tst-support_record_failure.c:109: not true: false
56 error: 1 test failures" $direct --test-verify
57 run_test 2 "error: tst-support_record_failure.c:109: not true: false
58 info: execution passed failed TEST_VERIFY
59 error: 1 test failures" $direct --test-verify --verbose
60 }
61
62 different_status
63 different_status --direct
64
65 run_test 1 "error: tst-support_record_failure.c:116: not true: false
66 error: 1 test failures" --test-verify-exit
67 # --direct does not print the summary error message if exit is called.
68 run_test 1 "error: tst-support_record_failure.c:116: not true: false" \
69 --direct --test-verify-exit