Skip to content

Commit

Permalink
wakebox: add some unit tests (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmjconolly committed Aug 25, 2023
1 parent 6e926cd commit 4dae10d
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/wakebox/false/.wakeroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 6 additions & 0 deletions tests/wakebox/false/fail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
# It's not valid to call wakebox with an empty PATH.
# So we fill PATH with some typical values.
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

${1}/wakebox -p input.json
16 changes: 16 additions & 0 deletions tests/wakebox/false/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"command": [
"false"
],
"environment": [
"USER=root",
"HOME=/root",
"PATH=/usr/bin:/bin:/usr/sbin:/sbin"
],
"directory": ".",
"stdin": "",
"user-id": 0,
"group-id": 0,
"mount-ops": [],
"visible": []
}
1 change: 1 addition & 0 deletions tests/wakebox/isolate-retcode/.wakeroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

16 changes: 16 additions & 0 deletions tests/wakebox/isolate-retcode/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"command": [
"sh", "-c", "exit 97"
],
"environment": [
"USER=root",
"HOME=/root",
"PATH=/usr/bin:/bin:/usr/sbin:/sbin"
],
"directory": ".",
"stdin": "",
"user-id": 0,
"group-id": 0,
"mount-ops": [],
"visible": []
}
14 changes: 14 additions & 0 deletions tests/wakebox/isolate-retcode/pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
# It's not valid to call wakebox with an empty PATH.
# So we fill PATH with some typical values.
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin


${1}/wakebox -I -p input.json -o result.json
RET=$?

[ $RET -ne 0 ] && exit 99

[ $(cat result.json | jq .usage.status) -ne 97 ] && exit 98

exit 0
1 change: 1 addition & 0 deletions tests/wakebox/true/.wakeroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

16 changes: 16 additions & 0 deletions tests/wakebox/true/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"command": [
"true"
],
"environment": [
"USER=root",
"HOME=/root",
"PATH=/usr/bin:/bin:/usr/sbin:/sbin"
],
"directory": ".",
"stdin": "",
"user-id": 0,
"group-id": 0,
"mount-ops": [],
"visible": []
}
6 changes: 6 additions & 0 deletions tests/wakebox/true/pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
# It's not valid to call wakebox with an empty PATH.
# So we fill PATH with some typical values.
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

${1}/wakebox -p input.json

0 comments on commit 4dae10d

Please sign in to comment.