tests: Make all guestfish tests use runtime check.
[nbdkit/ericb.git] / tests / test-debug-flags.sh
blob10e916c578cc11844366552080e75d5667db1e4d
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright (C) 2018 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # SUCH DAMAGE.
33 source ./functions.sh
34 set -x
36 export LANG=C
38 # Test nbdkit -D option.
40 files=debug-flags.out
41 rm -f $files
42 cleanup_fn rm -f $files
44 expected_failure ()
46 echo "expected previous nbdkit command to fail, but it did not"
47 exit 1
50 check_error ()
52 if ! grep -sq "$1" debug-flags.out; then
53 echo "unexpected error message containing: $1"
54 echo "actual output:"
55 cat debug-flags.out
56 exit 1
60 # This is expected to fail because we didn't set the file= parameter,
61 # but it should not fail because of the debug flag.
62 nbdkit -f -D example2.extra=1 example2 2>debug-flags.out && expected_failure
63 check_error "you must supply the file="
65 # This should fail because the -D flag refers to an unknown global in
66 # a known plugin.
67 nbdkit -f -D example2.unknown=1 example2 2>debug-flags.out && expected_failure
68 check_error "does not contain a global variable called example2_debug_unknown"
70 # This should fail because the -D flag is unused.
71 nbdkit -f -D example1.foo=1 example2 2>debug-flags.out && expected_failure
72 check_error "was not used"
74 # These should fail because the -D flag has a bad format.
75 nbdkit -f -D = example2 2>debug-flags.out && expected_failure
76 check_error "must have the format"
77 nbdkit -f -D . example2 2>debug-flags.out && expected_failure
78 check_error "must have the format"
79 nbdkit -f -D =. example2 2>debug-flags.out && expected_failure
80 check_error "must have the format"
81 nbdkit -f -D .= example2 2>debug-flags.out && expected_failure
82 check_error "must have the format"
83 nbdkit -f -D .extra=1 example2 2>debug-flags.out && expected_failure
84 check_error "must have the format"
85 nbdkit -f -D example2.=1 example2 2>debug-flags.out && expected_failure
86 check_error "must have the format"
87 nbdkit -f -D example2.extra= example2 2>debug-flags.out && expected_failure
88 check_error "must have the format"