tests: Add tests that just including the header works.
[nbdkit/ericb.git] / tests / test-debug-flags.sh
blobd4d5019ac728f27c3512f80a9b323a7646645e4e
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 set -x
34 export LANG=C
36 # Test nbdkit -D option.
38 rm -f debug-flags.out
40 expected_failure ()
42 echo "expected previous nbdkit command to fail, but it did not"
43 exit 1
46 check_error ()
48 if ! grep -sq "$1" debug-flags.out; then
49 echo "unexpected error message containing: $1"
50 echo "actual output:"
51 cat debug-flags.out
52 exit 1
56 # This is expected to fail because we didn't set the file= parameter,
57 # but it should not fail because of the debug flag.
58 nbdkit -f -D example2.extra=1 example2 2>debug-flags.out && expected_failure
59 check_error "you must supply the file="
61 # This should fail because the -D flag refers to an unknown global in
62 # a known plugin.
63 nbdkit -f -D example2.unknown=1 example2 2>debug-flags.out && expected_failure
64 check_error "does not contain a global variable called example2_debug_unknown"
66 # This should fail because the -D flag is unused.
67 nbdkit -f -D example1.foo=1 example2 2>debug-flags.out && expected_failure
68 check_error "was not used"
70 # These should fail because the -D flag has a bad format.
71 nbdkit -f -D = example2 2>debug-flags.out && expected_failure
72 check_error "must have the format"
73 nbdkit -f -D . example2 2>debug-flags.out && expected_failure
74 check_error "must have the 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 .extra=1 example2 2>debug-flags.out && expected_failure
80 check_error "must have the format"
81 nbdkit -f -D example2.=1 example2 2>debug-flags.out && expected_failure
82 check_error "must have the format"
83 nbdkit -f -D example2.extra= example2 2>debug-flags.out && expected_failure
84 check_error "must have the format"
86 rm debug-flags.out