File tree Expand file tree Collapse file tree 4 files changed +87
-0
lines changed
Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change @@ -53,3 +53,11 @@ execute:
5353 how: fmf
5454 test:
5555 - /tmt/tests/test-25-soft-reboot
56+
57+ /test-26-custom-selinux-policy:
58+ summary: Execute restorecon test on system with custom selinux policy
59+ discover:
60+ how: fmf
61+ test:
62+ - /tmt/tests/bootc-install-provision
63+ - /tmt/tests/test-26-custom-selinux-policy
Original file line number Diff line number Diff line change 1+ use std assert
2+ use tap .nu
3+
4+ # Test each directory separately for better granularity
5+ let directories = [" /boot" , " /etc" , " /var" ]
6+
7+ for dir in $directories {
8+ tap begin $" Run restorecon on ($dir )"
9+
10+ # Run restorecon on single directory and capture trimmed output
11+ let out = (restorecon - vnr $dir | str trim )
12+
13+ if $dir == " /boot" {
14+ # /boot is expected to have incorrect labels - known issue
15+ # See: https://github.com/bootc-dev/bootc/issues/1622
16+ print $" Note: /boot restorecon output (expected ): ($out )"
17+ } else {
18+ # Assert it's empty for other directories
19+ assert equal $out " " $" restorecon run found incorrect labels in ($dir ): ($out )"
20+ }
21+
22+ tap ok
23+ }
Original file line number Diff line number Diff line change 1+ # Verify that correct labels are applied after a deployment
2+ use std assert
3+ use tap .nu
4+
5+ # This code runs on *each* boot.
6+ # Here we just capture information.
7+ bootc status
8+
9+ # Run on the first boot
10+ def initial_build [] {
11+ tap begin " local image push + pull + upgrade"
12+
13+ let td = mktemp - d
14+ cd $td
15+
16+ bootc image copy-to-storage
17+
18+ # A simple derived container that customizes selinux policy for random dir
19+ " FROM localhost/bootc
20+ RUN mkdir /usr/lib/opt123 && echo " /usr/lib/opt123 /opt " > /usr/etc/selinux/targeted/contexts/files/file_contexts.subs_dist
21+ " | save Dockerfile
22+ # Build it
23+ podman build - t localhost/bootc-derived .
24+
25+ bootc switch -- soft-reboot=auto -- transport containers-storage localhost/bootc-derived
26+
27+ assert (not (" /usr/lib/opt123" | path exists ))
28+
29+ # https://tmt.readthedocs.io/en/stable/stories/features.html#reboot-during-test
30+ tmt-reboot
31+ }
32+
33+ # The second boot; verify we're in the derived image and directory has correct selinux label
34+ def second_boot [] {
35+ tap begin " Verify directory exists and has correct SELinux label"
36+
37+ assert (" /usr/lib/opt123" | path exists )
38+
39+ # Verify the directory has the correct SELinux label (opt_t)
40+ let label = (ls - Z /usr/lib/opt123 | get security_context | first )
41+ assert ($label | str contains " opt_t" ) $" Expected opt_t label, got: ($label )"
42+
43+ tap ok
44+ }
45+
46+ def main [] {
47+ # See https://tmt.readthedocs.io/en/stable/stories/features.html#reboot-during-test
48+ match $env .TMT_REBOOT_COUNT ? {
49+ null | " 0" => initial_build ,
50+ " 1" => second_boot ,
51+ $o => { error make { msg : $" Invalid TMT_REBOOT_COUNT ($o )" } },
52+ }
53+ }
Original file line number Diff line number Diff line change 1+ summary: Execute soft reboot test
2+ test: nu booted/test-custom-selinux-policy.nu
3+ duration: 30m
You can’t perform that action at this time.
0 commit comments