On 08.08.23 16:23, 'Earl Chew' via EFI Boot Guard wrote:
> Remove the temporary directory containing the test data to reduce clutter.
> When diagnosing test failures, developers can use --no-tempdir-cleanup to
> prevent BATS from removing test artifacts.
>
> Signed-off-by: Earl Chew <[email protected]>
> ---
> tests/bg_setenv.bats | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/tests/bg_setenv.bats b/tests/bg_setenv.bats
> index 67cee8f..6d0249b 100755
> --- a/tests/bg_setenv.bats
> +++ b/tests/bg_setenv.bats
> @@ -17,6 +17,13 @@ setup() {
> # file respectively
> DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
> PATH="$DIR/..:$PATH"
> +
> + # BATS_TEST_TMPDIR was introduced by BATS 1.4.0, and not available
> + # until Ubuntu 23.04.
The world is larger than Ubuntu - we can drop that reference here.
That means we will continue to leave the temp folder behind for older
versions of bats. Fine with me, maybe just state that explicitly in the
commit message.
Jan
> + [ -n "${BATS_TEST_TMPDIR:++}" ] || {
> + BATS_TEST_TMPDIR="$BATS_RUN_TMPDIR/test/$BATS_TEST_NUMBER"
> + mkdir -p "$BATS_TEST_TMPDIR"
> + }
> }
>
> create_sample_bgenv() {
> @@ -29,7 +36,7 @@ create_sample_bgenv() {
>
> @test "ensure BGENV.DAT backwards compatbility" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
> create_sample_bgenv "$envfile"
>
> run bg_printenv -f "$envfile"
> @@ -50,7 +57,7 @@ foo = bar" ]]
>
> @test "create an empty BGENV.DAT" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> run bg_setenv -f "$envfile"
> [[ "$output" = "Output written to $envfile." ]]
> @@ -72,7 +79,7 @@ user variables:" ]]
>
> @test "modify BGENV, discard existing values" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> create_sample_bgenv "$envfile"
> run bg_setenv -f "$envfile" -k C:BOOTNEW:kernel.efi
> @@ -94,7 +101,7 @@ user variables:" ]]
>
> @test "modify BGENV, preserve existing values" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> create_sample_bgenv "$envfile"
> run bg_setenv -f "$envfile" -k C:BOOTNEW:kernel.efi -P
> @@ -117,7 +124,7 @@ foo = bar" ]]
>
> @test "bg_printenv ustate" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> create_sample_bgenv "$envfile"
> run bg_printenv "--filepath=$envfile" --output ustate
> @@ -127,7 +134,7 @@ ustate: 0 (OK)" ]]
>
> @test "bg_printenv with all fields is the same as omitting fields" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> create_sample_bgenv "$envfile"
> expected_output=$(bg_printenv "--filepath=$envfile")
> @@ -137,7 +144,7 @@ ustate: 0 (OK)" ]]
>
> @test "bg_printenv ustate raw" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> create_sample_bgenv "$envfile"
> run bg_printenv "--filepath=$envfile" --output ustate --raw
> @@ -146,7 +153,7 @@ ustate: 0 (OK)" ]]
>
> @test "bg_printenv multiple fields raw" {
> local envfile
> - envfile="$(mktemp -d)/BGENV.DAT"
> + envfile="$BATS_TEST_TMPDIR/BGENV.DAT"
>
> create_sample_bgenv "$envfile"
> run bg_printenv "--filepath=$envfile" --output ustate,kernel,kernelargs
> --raw
--
Siemens AG, Technology
Linux Expert Center
--
You received this message because you are subscribed to the Google Groups "EFI
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/abb9b4e5-0634-7b60-503c-c9dd66cf0e8d%40siemens.com.