mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
runtime: Consolidate flags setting in unit tests script
One of the responsibilities of the go-test.sh script is setting up the default flags for 'go test'. This is constructed across several different places in the script using several unneeded intermediate variables though. Consolidate all the flag construction into one place. fixes #4190 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
cf465feb02
commit
f24a6e761f
@ -15,14 +15,19 @@ long_options=(
|
||||
[package:]="Specify test package to run"
|
||||
)
|
||||
|
||||
# Set default test run timeout value.
|
||||
#
|
||||
# Set up go test flags
|
||||
go_test_flags="${KATA_GO_TEST_FLAGS}"
|
||||
if [ -z "$go_test_flags" ]; then
|
||||
# KATA_GO_TEST_TIMEOUT can be set to any value accepted by
|
||||
# "go test -timeout X"
|
||||
timeout_value=${KATA_GO_TEST_TIMEOUT:-30s}
|
||||
go_test_flags="-v -timeout ${KATA_GO_TEST_TIMEOUT:-30s}"
|
||||
|
||||
# -race flag is not supported on s390x
|
||||
[ "$(go env GOARCH)" != "s390x" ] && race="-race"
|
||||
[ "$(go env GOARCH)" != "s390x" ] && go_test_flags+=" -race"
|
||||
|
||||
# s390x requires special linker flags
|
||||
[ "$(go env GOARCH)" = s390x ] && go_test_flags+=" -ldflags '-extldflags -Wl,--s390-pgste'"
|
||||
fi
|
||||
|
||||
# The "master" coverage file that contains the coverage results for
|
||||
# all packages run under all scenarios.
|
||||
@ -156,12 +161,6 @@ main()
|
||||
shift
|
||||
done
|
||||
|
||||
local go_ldflags
|
||||
[ "$(go env GOARCH)" = s390x ] && go_ldflags="-extldflags -Wl,--s390-pgste"
|
||||
|
||||
# KATA_GO_TEST_FLAGS can be set to change the flags passed to "go test".
|
||||
go_test_flags=${KATA_GO_TEST_FLAGS:-"-v $race -timeout $timeout_value -ldflags '$go_ldflags'"}
|
||||
|
||||
test_coverage
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user