Skip to content

Commit

Permalink
Capture the exitcode test as a docker compose recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
eds-collabora committed Aug 16, 2021
1 parent 8706474 commit b7849db
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
24 changes: 24 additions & 0 deletions docker/exitcode-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.6'

services:
sut:
build:
context: ..
dockerfile: docker/Dockerfile
target: runner
volumes:
- type: bind
source: ../tests/exit_test
target: /recipes
tmpfs:
- /scratch:exec
environment:
- TMP=/scratch
cap_add:
- SYS_PTRACE
security_opt:
- label:disable
working_dir: /recipes/
entrypoint: ./exit_test.sh
command: --fakemachine-backend=uml

28 changes: 16 additions & 12 deletions tests/exit_test/exit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TEST=0
FAILURES=0
VERBOSE=0
VERBOSE=1

function test_failed {
local MSG="$1"
Expand All @@ -18,6 +18,7 @@ function test_passed {

function run_cmd {
local CMD="$@"
echo
echo "Running ${CMD}"
if [[ $VERBOSE == 0 ]]; then
$CMD &>/dev/null
Expand All @@ -29,7 +30,6 @@ function run_cmd {

function expect_success {
local CMD="$@"

run_cmd $CMD && test_passed || test_failed "${CMD} failed with exitcode $?, expected success"
}

Expand All @@ -45,6 +45,11 @@ function rename_command {
return $?
}

if [ -v sudo ]; then
SUDO=sudo
else
SUDO=
fi

expect_success debos --help
expect_failure debos --not-a-valid-option
Expand All @@ -53,26 +58,25 @@ expect_failure debos good.yaml good.yaml
expect_failure debos --disable-fakemachine --fakemachine-backend=uml good.yaml
expect_failure debos non-existent-file.yaml
expect_failure debos garbled.yaml
expect_failure debos --fakemachine-backend=uml good.yaml
expect_failure debos --fakemachine-backend=kvm good.yaml
expect_failure debos verify-fail.yaml
expect_success debos --dry-run good.yaml
expect_failure debos --memory=NotANumber good.yaml
expect_failure debos --cpus=-1 good.yaml
expect_failure debos --scratchsize=NotANumber good.yaml
expect_success debos good.yaml
expect_failure debos bad.yaml
expect_failure debos pre-machine-failure.yaml
expect_failure debos post-machine-failure.yaml
expect_failure rename_command NOT_DEBOS debos good.yaml

expect_failure sudo debos non-existent-file.yaml --disable-fakemachine
expect_failure sudo debos garbled.yaml --disable-fakemachine
expect_failure sudo debos verify-fail.yaml --disable-fakemachine
expect_success sudo debos --dry-run good.yaml --disable-fakemachine
expect_success sudo debos good.yaml --disable-fakemachine
expect_failure sudo debos bad.yaml --disable-fakemachine
expect_failure sudo debos pre-machine-failure.yaml --disable-fakemachine
expect_failure sudo debos post-machine-failure.yaml --disable-fakemachine
expect_failure $SUDO debos non-existent-file.yaml --disable-fakemachine
expect_failure $SUDO debos garbled.yaml --disable-fakemachine
expect_failure $SUDO debos verify-fail.yaml --disable-fakemachine
expect_success $SUDO debos --dry-run good.yaml --disable-fakemachine
expect_success $SUDO debos good.yaml --disable-fakemachine
expect_failure $SUDO debos bad.yaml --disable-fakemachine
expect_failure $SUDO debos pre-machine-failure.yaml --disable-fakemachine
expect_failure $SUDO debos post-machine-failure.yaml --disable-fakemachine

echo
if [[ $FAILURES -ne 0 ]]; then
Expand Down

0 comments on commit b7849db

Please sign in to comment.