]> git.ipfire.org Git - thirdparty/nftables.git/commit
tests/shell: honor NFT_TEST_VERBOSE_TEST variable to debug tests via `bash -x`
authorThomas Haller <thaller@redhat.com>
Mon, 16 Oct 2023 19:43:08 +0000 (21:43 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 21 Oct 2023 09:58:20 +0000 (11:58 +0200)
commit8cacebc36732fe190a991d512e60e4fcbfc782eb
treed1c8f6ac488564229ec47ce1f740d897ef621f26
parent22fab8681a50014174cdd02ace90f74b9e9eefe9
tests/shell: honor NFT_TEST_VERBOSE_TEST variable to debug tests via `bash -x`

It can be cumbersome to debug why a test fails. Our tests are just shell
scripts, which for the most part don't print much. That is good, but for
debugging, it can be useful to run the test via `bash -x`. Previously,
we would just patch the source file while debugging.

Add an option "-x" and NFT_TEST_VERBOSE_TEST=y environment variable. If set,
"test-wrapper.sh" will check whether the shebang is "#!/bin/bash" and add
"-x" to the command line.

While at it, let test-wrapper.sh also log a line like

    Command: $CMD

With this, we see in the log the command that was run, and how
NFT_TEST_VERBOSE_TEST may have affected it. This is anyway useful,
because many tests don't print anything at all, and we end up with an
empty "testout.log". Empty files are cumbersome, e.g. I like to use
`grep -R ^` to show the content of all files, which does not show empty
files. Ensuring that something is always written is desirable.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/helpers/test-wrapper.sh
tests/shell/run-tests.sh