Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wakebox: add some unit tests #1404

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": []
}
1 change: 1 addition & 0 deletions tests/wakebox/isolate-retcode/out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"usage":{"status":1,"membytes":4341760,"inbytes":0,"outbytes":0,"runtime":0.023453,"cputime":0.003199},"inputs":[],"outputs":[],"run-host":"pe01.internal.sifive.com"}
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/isolate-retcode/result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"usage":{"status":97,"membytes":4255744,"inbytes":0,"outbytes":0,"runtime":0.022961,"cputime":0.003021},"inputs":[],"outputs":[],"run-host":"pe01.internal.sifive.com"}
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