tests: Execute tests in a clean (temporary) directory
Instead of executing in the current (build) directory, create a temporary directory and change into it before running any tests. This ensures that tests aren't relying on left-overs from previous test runs. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
This commit is contained in:
parent
1be14f0c9b
commit
b3edb1fb72
4 changed files with 22 additions and 17 deletions
|
@ -1,12 +1,18 @@
|
|||
|
||||
basedir=..
|
||||
testdir="$basedir/tests"
|
||||
bindir="$basedir"
|
||||
basedir=$(cd $srcdir && pwd)
|
||||
datadir=$(pwd)
|
||||
bindir="$datadir/.."
|
||||
|
||||
sbsign=$bindir/sbsign
|
||||
sbverify=$bindir/sbverify
|
||||
sbattach=$bindir/sbattach
|
||||
|
||||
key="$testdir/private-key.rsa"
|
||||
cert="$testdir/public-cert.pem"
|
||||
image="$testdir/test.pecoff"
|
||||
key="$datadir/private-key.rsa"
|
||||
cert="$datadir/public-cert.pem"
|
||||
image="$datadir/test.pecoff"
|
||||
|
||||
tempdir=$(mktemp --directory)
|
||||
exit_trap='rm -rf $tempdir'
|
||||
trap "$exit_trap" EXIT
|
||||
|
||||
cd "$tempdir"
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
. "$srcdir/common.sh"
|
||||
|
||||
sig=test.sig
|
||||
signed=test.signed
|
||||
sig="test.sig"
|
||||
signed="test.signed"
|
||||
|
||||
trap 'rm -f "$sig" "$signed"' EXIT
|
||||
|
||||
"$sbsign" --cert "$cert" --key "$key" --detached --output $sig "$image"
|
||||
"$sbattach" --attach $sig $signed
|
||||
"$sbsign" --cert "$cert" --key "$key" --detached --output "$sig" "$image"
|
||||
cp "$image" "$signed"
|
||||
"$sbattach" --attach "$sig" "$signed"
|
||||
"$sbverify" --cert "$cert" "$signed"
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
. "$srcdir/common.sh"
|
||||
|
||||
sig=test.sig
|
||||
|
||||
trap 'rm -f "$sig"' EXIT
|
||||
sig="test.sig"
|
||||
|
||||
"$sbsign" --cert "$cert" --key "$key" --detached --output $sig "$image"
|
||||
"$sbverify" --cert "$cert" --detached $sig "$image"
|
||||
|
|
|
@ -2,5 +2,7 @@
|
|||
|
||||
. "$srcdir/common.sh"
|
||||
|
||||
"$sbsign" --cert "$cert" --key "$key" --output test.signed "$image"
|
||||
"$sbverify" --cert "$cert" test.signed
|
||||
signed="test.signed"
|
||||
|
||||
"$sbsign" --cert "$cert" --key "$key" --output "$signed" "$image"
|
||||
"$sbverify" --cert "$cert" "$signed"
|
||||
|
|
Loading…
Reference in a new issue