-
Notifications
You must be signed in to change notification settings - Fork 146
Add a test case for our internal reboot command #1426
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [Unit] | ||
| ConditionPathExists=!/etc/initrd-release | ||
| After=local-fs.target | ||
| RequiresMountsFor=/run/bootc-test-reboot | ||
| Before=bootc-test-reboot.service | ||
| PartOf=bootc-test-reboot.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStop=touch /run/bootc-test-reboot/success |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [Unit] | ||
| ConditionPathExists=!/etc/initrd-release | ||
| Requires=bootc-finish-test-reboot.service | ||
| After=bootc-finish-test-reboot.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStart=bootc internals reboot | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
| # Verify that invoking `bootc internals reboot` actually invokes a reboot, when | ||
| # running inside systemd. | ||
| # xref: | ||
| # - https://github.com/bootc-dev/bootc/issues/1416 | ||
| # - https://github.com/bootc-dev/bootc/issues/1419 | ||
| set -euo pipefail | ||
| image=$1 | ||
| tmpd=$(mktemp -d) | ||
| log() { | ||
| echo "$@" | ||
| "$@" | ||
| } | ||
| log timeout 120 podman run --rm --systemd=always --privileged -v /sys:/sys:ro --label bootc.test=reboot --net=none -v $(pwd):/src:ro -v $tmpd:/run/bootc-test-reboot $image /bin/sh -c 'cp /src/*.service /etc/systemd/system && systemctl enable bootc-test-reboot && exec /sbin/init' || true | ||
| ls -al $tmpd | ||
| if test '!' -f $tmpd/success; then | ||
| echo "reboot failed" 1>&2 | ||
| rm -rf "$tmpd" | ||
| exit 1 | ||
| fi | ||
| rm -rf "$tmpd" | ||
| echo "ok reboot" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| image=$1 | ||
| shift | ||
|
|
||
| cd $(dirname $0) | ||
|
|
||
| tests=$(find . -maxdepth 1 -type d) | ||
| for case in $tests; do | ||
| if test $case = .; then continue; fi | ||
| echo "Running: $case" | ||
| cd $case | ||
| ./run $image | ||
| cd - | ||
| echo "ok $case" | ||
| done | ||
|
Comment on lines
+9
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+6
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a subshell
(...)to run commands in a different directory is often cleaner and safer thancd ...; cd -.