btrfs-progs: tests: add support to test the .static binaries

Testing the statically built binaries is not straightforward, add a
convenient way to do that:

  $ make TEST_FLAVOR=static

There should be no difference in the test results.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-01-29 14:24:33 +01:00
parent 922eaa7b54
commit 911741e854
3 changed files with 15 additions and 3 deletions

View File

@ -3,6 +3,7 @@
# TEST=GLOB run test(s) from directories matching GLOB
# TEST_LOG=tty print name of a command run via the execution helpers
# TEST_LOG=dump dump testing log file when a test fails
# TEST_FLAVOR test build flavor: dynamic (default), static
#
# TOP=path test binaries from the given path

View File

@ -132,6 +132,9 @@ occurs, possibly allowing to continue interactively debugging.
* `TEST_LOG=dump` -- dump the entire testing log when a test fails
* `TEST_FLAVOR` -- run binaries of specified flavor, which is dynamic build by
default, or *static* using all the build binaries with *.static* suffix
* `TEST_ENABLE_OVERRIDE` -- defined either as make arguments or via
`tests/common.local` to enable additional arguments to some commands, using
the variable(s) below (default: false, enable by setting to 'true')

View File

@ -198,7 +198,11 @@ expand_command()
if [ $i -eq $ins -a ! -z "$spec" ]; then
cmd_array+=("$spec")
fi
cmd_array+=("${!i}")
if [ $i -eq $command_index -a "$TEST_FLAVOR" = 'static' ]; then
cmd_array+=("${!i}".static)
else
cmd_array+=("${!i}")
fi
done
}
@ -376,8 +380,12 @@ check_prereq()
fi
;;
*)
if ! [ -f "$TOP/$1" ]; then
_fail "Failed prerequisites: $TOP/$1";
bin="$TOP/$1"
if [ "$TEST_FLAVOR" = 'static' ]; then
bin="${bin}.static"
fi
if ! [ -f "$bin" ]; then
_fail "Failed prerequisites: $bin";
fi
;;
esac