test: point at root in the local-mode apt failure

A local run fails apt-get update exactly like a local build does when
the user is not root; say so in the error instead of leaving a bare
failure (the chroot modes bootstrap their own root environment).
This commit is contained in:
2026-09-27 21:33:11 +02:00
parent d35ffefacb
commit 8513805f98
+21 -2
View File
@@ -176,7 +176,16 @@ pub async fn run(opts: TestOptions<'_>) -> Result<TestRunReport, Box<dyn std::er
env.insert("LOGNAME".to_string(), "root".to_string()); env.insert("LOGNAME".to_string(), "root".to_string());
} }
configure_testbed(&ctx, &env, &series, &arch, &opts, view).await?; configure_testbed(
&ctx,
&env,
&series,
&arch,
&opts,
matches!(bed, Bed::Local(_)),
view,
)
.await?;
// Stage the tree and the binaries into the testbed. The copy also // Stage the tree and the binaries into the testbed. The copy also
// protects the host tree: tests may write into it (rw-build-tree). // protects the host tree: tests may write into it (rw-build-tree).
@@ -431,6 +440,7 @@ async fn configure_testbed(
series: &str, series: &str,
arch: &str, arch: &str,
opts: &TestOptions<'_>, opts: &TestOptions<'_>,
local_context: bool,
view: &dyn BuildView, view: &dyn BuildView,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let mut sources = crate::apt::sources::load(Some(ctx.clone()))?; let mut sources = crate::apt::sources::load(Some(ctx.clone()))?;
@@ -509,7 +519,16 @@ async fn configure_testbed(
.status() .status()
.map_err(|e| format!("apt-get update failed inside the testbed: {e}"))?; .map_err(|e| format!("apt-get update failed inside the testbed: {e}"))?;
if !status.success() { if !status.success() {
return Err("apt-get update failed inside the testbed".into()); return Err(format!(
"apt-get update failed inside the testbed{}",
if local_context {
" (a local run needs root to install packages: \
use sudo, or the default chroot mode)"
} else {
""
}
)
.into());
} }
if opts.apt_upgrade { if opts.apt_upgrade {