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
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
38 # Test nbdkit -D option.
42 cleanup_fn
rm -f $files
46 echo "expected previous nbdkit command to fail, but it did not"
53 if ! grep -sq "$1" debug-flags.out
; then
54 echo "$0: expected error message not present in above output: '$1'"
62 if ! grep -sq "warning.*$1" debug-flags.out
; then
63 echo "$0: expected warning message not present in above output: '$1'"
68 # This is expected to fail because we didn't set the file= parameter,
69 # but it should not fail because of the debug flag.
70 nbdkit
-f -D example2.extra
=1 example2
2>debug-flags.out
&& expected_failure
71 check_error
"you must supply the file="
73 # This should fail because we didn't set the file= parameter, but it
74 # should also print a warning about the unknown -D flag.
75 nbdkit
-f -D example2.unknown
=1 example2
2>debug-flags.out
&& expected_failure
76 check_error
"you must supply the file="
77 check_warning
"does not contain a global variable called example2_debug_unknown"
79 # This should fail because we didn't set the file= parameter, but it
80 # should also print a warning because the -D flag is unused.
81 nbdkit
-f -D example1.foo
=1 example2
2>debug-flags.out
&& expected_failure
82 check_error
"you must supply the file="
83 check_warning
"was not used"
85 # These should fail because the -D flag has a bad format.
86 nbdkit
-f -D = example2
2>debug-flags.out
&& expected_failure
87 check_error
"must have the format"
88 nbdkit
-f -D . example2
2>debug-flags.out
&& expected_failure
89 check_error
"must have the format"
90 nbdkit
-f -D =. example2
2>debug-flags.out
&& expected_failure
91 check_error
"must have the format"
92 nbdkit
-f -D .
= example2
2>debug-flags.out
&& expected_failure
93 check_error
"must have the format"
94 nbdkit
-f -D .extra
=1 example2
2>debug-flags.out
&& expected_failure
95 check_error
"must have the format"
96 nbdkit
-f -D example2.
=1 example2
2>debug-flags.out
&& expected_failure
97 check_error
"must have the format"
98 nbdkit
-f -D example2.extra
= example2
2>debug-flags.out
&& expected_failure
99 check_error
"must have the format"