diff --git a/tests/bats/002-scans.bats b/tests/bats/002-scans.bats index 135dab4e9..9e71dfb2f 100644 --- a/tests/bats/002-scans.bats +++ b/tests/bats/002-scans.bats @@ -10,6 +10,14 @@ setup_file() { setup_gallia_toml } +setup() { + common_setup +} + +teardown() { + check_artifactsdir "$BATS_TMPDIR"/gallia/*/run-* +} + @test "scan services" { gallia scan uds services --sessions 1 2 --check-session } diff --git a/tests/bats/003-primitives.bats b/tests/bats/003-primitives.bats index 194ec1c16..9ebe6e224 100644 --- a/tests/bats/003-primitives.bats +++ b/tests/bats/003-primitives.bats @@ -10,6 +10,14 @@ setup_file() { setup_gallia_toml } +setup() { + common_setup +} + +teardown() { + check_artifactsdir "$BATS_TMPDIR"/gallia/*/run-* +} + @test "primitive ecu-reset" { gallia primitive uds ecu-reset } diff --git a/tests/bats/helpers.bash b/tests/bats/helpers.bash index 997e1aa9f..3b4f37201 100644 --- a/tests/bats/helpers.bash +++ b/tests/bats/helpers.bash @@ -2,6 +2,14 @@ # # SPDX-License-Identifier: Apache-2.0 +common_setup() { + # https://bats-core.readthedocs.io/en/stable/tutorial.html#let-s-do-some-setup + DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)" + PATH="$DIR/..:$PATH" + + cd "$BATS_TEST_TMPDIR" || exit 1 +} + setup_gallia_toml() { { echo "[gallia]" @@ -24,3 +32,21 @@ rm_gallia_toml() { rm -f "$GALLIA_CONFIG" fi } + +check_artifactsdir() { + # There is only one (tm) artifactsdir per run. + local artifactsdir + artifactsdir="$1" + + if [[ ! -r "$artifactsdir/log.json.zst" ]]; then + return 1 + fi + + if [[ ! -r "$artifactsdir/META.json" ]]; then + return 1 + fi + + if [[ ! -r "$artifactsdir/ENV" ]]; then + return 1 + fi +} diff --git a/tests/bats/setup_suite.bash b/tests/bats/setup_suite.bash index 43a90b7fb..9363fa4b0 100644 --- a/tests/bats/setup_suite.bash +++ b/tests/bats/setup_suite.bash @@ -4,10 +4,4 @@ setup_suite() { bats_require_minimum_version 1.8.0 - - # https://bats-core.readthedocs.io/en/stable/tutorial.html#let-s-do-some-setup - DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)" - PATH="$DIR/..:$PATH" - - cd "$BATS_TEST_TMPDIR" || exit 1 }