From c2c43c3f847194ee51ed4e926d530eaaba8f7087 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 26 Dec 2021 00:00:34 +0000 Subject: [PATCH] autopkgtests: wip, an actual very simple test Passes with autopkgtest -- qemu /path/to/buster.image Signed-off-by: Ian Jackson --- debian/tests/control | 2 +- tests/lib | 12 ++++++++++++ tests/t-basic | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/lib diff --git a/debian/tests/control b/debian/tests/control index bb74a1f..cc11fad 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,4 +1,4 @@ Tests: t-basic Depends: @, bash Tests-Directory: tests -Restrictions: isolation-container, allow-stderr +Restrictions: isolation-container, allow-stderr, needs-root diff --git a/tests/lib b/tests/lib new file mode 100644 index 0000000..ae2aa50 --- /dev/null +++ b/tests/lib @@ -0,0 +1,12 @@ +# -*- shell-script -*- + +expect_output () { + local e_status=$1; shift + local e_stdout=$1; shift + set +e + local g_stdout="$( "$@" )" + local g_status=$? + set -e + test "$g_status" = "$e_status" + test "$g_stdout" = "$e_stdout" +} diff --git a/tests/t-basic b/tests/t-basic index bd20892..969bbc4 100755 --- a/tests/t-basic +++ b/tests/t-basic @@ -1,2 +1,7 @@ #!/bin/bash set -ex + +. tests/lib + +expect_output 0 'games' \ +userv --override 'execute whoami' games spong -- 2.30.2