Skip to content

Commit 1ad391e

Browse files
committed
core: Fix usroverlay regression
The `/sysroot` writability regressed this, and add a missing test case for this. Signed-off-by: Colin Walters <[email protected]>
1 parent 01fd6b7 commit 1ad391e

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

crates/lib/src/cli.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,10 +1336,12 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
13361336
}
13371337
Opt::Edit(opts) => edit(opts).await,
13381338
Opt::UsrOverlay => {
1339-
let storage = &get_storage().await?;
1340-
match storage.kind()? {
1341-
BootedStorageKind::Ostree(_) => usroverlay().await,
1342-
BootedStorageKind::Composefs(_) => composefs_usr_overlay(),
1339+
use crate::store::Environment;
1340+
let env = Environment::detect()?;
1341+
match env {
1342+
Environment::OstreeBooted => usroverlay().await,
1343+
Environment::ComposefsBooted(_) => composefs_usr_overlay(),
1344+
_ => anyhow::bail!("usroverlay only applies on booted hosts"),
13431345
}
13441346
}
13451347
Opt::Container(opts) => match opts {

tmt/plans/integration.fmf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ execute:
106106
enabled: false
107107
because: tmt-reboot does not work with systemd reboot in testing farm environment (see bug-soft-reboot.md)
108108

109+
/test-23-usroverlay:
110+
summary: Usroverlay
111+
discover:
112+
how: fmf
113+
test:
114+
- /tmt/tests/test-23-usroverlay
115+
109116
/test-28-factory-reset:
110117
summary: Factory reset
111118
discover:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Verify that bootc usroverlay works
2+
use std assert
3+
use tap.nu
4+
5+
bootc status
6+
7+
# We should start out in a non-writable state on each boot
8+
let is_writable = (do -i { /bin/test -w /usr } | complete | get exit_code) == 0
9+
assert (not $is_writable)
10+
11+
def initial_run [] {
12+
bootc usroverlay
13+
let is_writable = (do -i { /bin/test -w /usr } | complete | get exit_code) == 0
14+
assert ($is_writable)
15+
16+
tmt-reboot
17+
}
18+
19+
# The second boot; verify we're in the derived image
20+
def second_boot [] {
21+
# Nothing, we already verified non-writability above
22+
}
23+
24+
def main [] {
25+
# See https://tmt.readthedocs.io/en/stable/stories/features.html#reboot-during-test
26+
match $env.TMT_REBOOT_COUNT? {
27+
null | "0" => initial_run,
28+
"1" => second_boot,
29+
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
30+
}
31+
}

tmt/tests/test-23-usroverlay.fmf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
summary: Execute tests for bootc usrover
2+
test: nu booted/test-usroverlay.nu
3+
duration: 30m

0 commit comments

Comments
 (0)