The verifier accepted one-byte placeholder modules, a caller-supplied version/flavor, any NVIDIA firmware file and a nouveau blacklist that happened to exist somewhere. It now establishes what it claims: - reject placeholder modules and userspace libraries (size floor); - require every module to be registered in the live kernel's modules.dep; - normalise the dpkg revision and require the userspace libnvidia-glcore and firmware directory versions to match the bundled driver; - infer the module flavor from the on-disk naming and reject a contradiction; - require the exact etc/modprobe.d/phoebus-nvidia.conf with nouveau blacklist and nvidia_drm modeset, not any blacklist; - keep every filesystem read rooted inside the build root. Negative tests cover placeholders, version mismatches, a stale modules.dep, a contradictory flavor and a missing final config.
322 lines
12 KiB
Rust
322 lines
12 KiB
Rust
//! Regression guards for the live ISO assembly and the installed defaults.
|
|
//!
|
|
//! These do not build an ISO; they pin the invariants that make the build
|
|
//! meaningful: the desktop payload is required and present in the package list,
|
|
//! the build fails clearly when it is missing, the live and installed login
|
|
//! configuration stay separate, and both session entries are shipped.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use phoebus_core::config::{DesktopProfile, InstallConfig};
|
|
use phoebus_core::system;
|
|
|
|
fn repo_root() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../..")
|
|
.canonicalize()
|
|
.expect("repo root")
|
|
}
|
|
|
|
fn read(rel: &str) -> String {
|
|
let path: PathBuf = repo_root().join(rel);
|
|
std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("cannot read {}: {e}", path.display()))
|
|
}
|
|
|
|
#[test]
|
|
fn live_build_bundles_and_verifies_the_nvidia_payload() {
|
|
let list = read("installer/live/live-packages.list");
|
|
for required in [
|
|
"nvidia-driver",
|
|
"nvidia-kernel-dkms",
|
|
"firmware-nvidia-gsp",
|
|
"firmware-nvidia-graphics",
|
|
"libnvidia-egl-gbm1",
|
|
"libnvidia-egl-wayland1",
|
|
"linux-headers-amd64",
|
|
"dkms",
|
|
] {
|
|
assert!(
|
|
list.lines().any(|l| l.trim() == required),
|
|
"live package list is missing {required}"
|
|
);
|
|
}
|
|
let build = read("installer/live/build.sh");
|
|
// The signed non-free components are enabled for the NVIDIA packages.
|
|
assert!(build.contains("main,contrib,non-free,non-free-firmware"));
|
|
// The payload is verified on every build, including a cached rootfs, and a
|
|
// missing/mismatched component fails the build.
|
|
assert!(build.contains("--verify-live-nvidia"));
|
|
assert!(build.contains("--nvidia-version"));
|
|
assert!(build.contains("etc/phoebus/nvidia"));
|
|
// Module build happens for the exact live kernel in the hook.
|
|
let hook = read("installer/live/livefs-hook.sh");
|
|
assert!(hook.contains("dkms autoinstall"));
|
|
assert!(hook.contains("nvidia_drm"));
|
|
// The live kernel is pinned to Debian stable, where the 550 driver builds;
|
|
// testing's 7.2 kernel removed strncpy and breaks nvidia-kernel-dkms.
|
|
assert!(build.contains("trixie"));
|
|
assert!(build.contains("linux-kbuild-"));
|
|
assert!(build.contains("--setup-hook"));
|
|
// The live driver policy file the verifier requires is actually produced,
|
|
// and Debian's unconditional nouveau configuration is replaced so the
|
|
// explicit nouveau fallback can bind an unsupported GPU.
|
|
assert!(build.contains("etc/modprobe.d/phoebus-nvidia.conf"));
|
|
assert!(build.contains("nvidia-blacklists-nouveau.conf"));
|
|
assert!(build.contains("blacklist nouveau"));
|
|
// Nouveau blacklisting/module options no longer come solely from
|
|
// nvidia-kernel-common; its unconditional modules-load entry is removed in
|
|
// favour of the gated unit.
|
|
assert!(build.contains("nvidia-kernel-common"));
|
|
assert!(build.contains("modules-load.d/nvidia.conf"));
|
|
// A documented fail-safe entry disables NVIDIA for that boot, and marks the
|
|
// command line so the load script and unit both stand down.
|
|
assert!(build.contains("nomodeset"));
|
|
assert!(build.contains("phoebus.nvidia=off"));
|
|
assert!(build.contains("modprobe.blacklist=nvidia"));
|
|
}
|
|
|
|
#[test]
|
|
fn live_package_list_carries_the_desktop_stack() {
|
|
let list = read("installer/live/live-packages.list");
|
|
let entries: Vec<&str> = list
|
|
.lines()
|
|
.map(str::trim)
|
|
.filter(|l| !l.is_empty() && !l.starts_with('#'))
|
|
.collect();
|
|
for required in [
|
|
"quickshell",
|
|
"greetd",
|
|
"tuigreet",
|
|
// Mango is built from source, so its build dependencies must be present.
|
|
"libwlroots-0.20-dev",
|
|
"libscenefx-0.5-dev",
|
|
"meson",
|
|
// The installer and bookkeeping need these tools in the live image.
|
|
"cryptsetup-bin",
|
|
"btrfs-progs",
|
|
"flatpak",
|
|
] {
|
|
assert!(
|
|
entries.contains(&required),
|
|
"live package list is missing {required}"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn live_build_requires_the_desktop_and_fails_clearly() {
|
|
let build = read("installer/live/build.sh");
|
|
// The desktop compositor and shell must be verified before packing.
|
|
assert!(build.contains("usr/bin/mango"));
|
|
assert!(build.contains("usr/bin/dms"));
|
|
assert!(build.contains("quickshell"));
|
|
assert!(build.contains("phoebus-install.desktop"));
|
|
// Live autologin must be present in the live login config.
|
|
assert!(build.contains("initial_session"));
|
|
// The pinned releases are checksum-verified.
|
|
assert!(build.contains("releases.sha256"));
|
|
// The shared assets come from the installer, not a divergent copy.
|
|
assert!(build.contains("--emit-asset"));
|
|
}
|
|
|
|
#[test]
|
|
fn pinned_releases_are_checksummed() {
|
|
let pins = read("installer/live/releases.sha256");
|
|
assert!(pins.contains("dms-full-amd64.tar.gz"));
|
|
assert!(pins.contains("mango-0.17.2.tar.gz"));
|
|
// 64-hex digests.
|
|
for line in pins.lines() {
|
|
let line = line.trim();
|
|
if line.is_empty() || line.starts_with('#') {
|
|
continue;
|
|
}
|
|
let digest = line.split_whitespace().next().unwrap();
|
|
assert_eq!(digest.len(), 64, "not a sha256: {line}");
|
|
assert!(digest.chars().all(|c| c.is_ascii_hexdigit()));
|
|
assert!(
|
|
digest.chars().any(|c| c != '0'),
|
|
"placeholder digest: {line}"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn installed_login_is_authenticated_and_selects_mango_by_default() {
|
|
let config = system::greetd_config(system::default_session_command(DesktopProfile::Mango));
|
|
assert!(config.contains("--cmd /usr/local/bin/phoebus-session-mango"));
|
|
assert!(config.contains("--sessions /usr/share/wayland-sessions"));
|
|
assert!(
|
|
!config.contains("[initial_session]"),
|
|
"the installed system must require authentication"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn live_login_autologins_and_the_configs_are_separate() {
|
|
let live = system::desktop_asset("greetd-live").unwrap();
|
|
let installed = system::desktop_asset("greetd-installed").unwrap();
|
|
assert!(live.contains("[initial_session]"));
|
|
assert!(live.contains("user = \"phoebus\""));
|
|
assert!(!installed.contains("[initial_session]"));
|
|
// The live and installed configs must not be the same file content.
|
|
assert_ne!(live, installed);
|
|
}
|
|
|
|
#[test]
|
|
fn both_session_entries_are_shipped_for_the_fallback() {
|
|
let mango = system::desktop_asset("wayland-session-mango").unwrap();
|
|
let dwl = system::desktop_asset("wayland-session-dwl").unwrap();
|
|
assert!(mango.contains("Exec=/usr/local/bin/phoebus-session-mango"));
|
|
assert!(dwl.contains("Exec=/usr/local/bin/phoebus-session"));
|
|
assert_ne!(mango, dwl);
|
|
}
|
|
|
|
#[test]
|
|
fn default_config_omits_to_mango_and_overrides_are_respected() {
|
|
assert_eq!(
|
|
InstallConfig::default().desktop.profile,
|
|
DesktopProfile::Mango
|
|
);
|
|
assert!(InstallConfig::default().desktop.flatpak);
|
|
for (value, expected) in [
|
|
("none", DesktopProfile::None),
|
|
("dwl", DesktopProfile::Dwl),
|
|
("full", DesktopProfile::Full),
|
|
("mango", DesktopProfile::Mango),
|
|
] {
|
|
let cfg = InstallConfig::from_legacy(&format!("DESKTOP_PROFILE='{value}'\n")).unwrap();
|
|
assert_eq!(cfg.desktop.profile, expected);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn build_script_is_syntax_declared_shell() {
|
|
// A cheap guard that the checked-in script is still a bash script and not a
|
|
// stub: it must contain the mmdebstrap invocation and the ISO assembly.
|
|
let build = read("installer/live/build.sh");
|
|
assert!(build.starts_with("#!/usr/bin/env bash"));
|
|
assert!(build.contains("mmdebstrap"));
|
|
assert!(build.contains("xorriso"));
|
|
assert!(build.contains("mksquashfs"));
|
|
let _ = Path::new(".");
|
|
}
|
|
|
|
#[test]
|
|
fn live_build_installs_the_branded_launcher_and_marker() {
|
|
let build = read("installer/live/build.sh");
|
|
// The welcome/installer Quickshell configs and branding are part of the
|
|
// payload, and the live marker gates live-only autostart.
|
|
for needle in [
|
|
"etc/xdg/quickshell/phoebus-welcome",
|
|
"etc/xdg/quickshell/phoebus-install",
|
|
"phoebus-welcome",
|
|
"usr/share/phoebus/branding",
|
|
"etc/phoebus/live",
|
|
"brand-wallpaper",
|
|
"splash.png",
|
|
] {
|
|
assert!(build.contains(needle), "build.sh is missing {needle}");
|
|
}
|
|
// The live help text is shipped and read by the welcome window.
|
|
let help = read("installer/live/install-help.txt");
|
|
assert!(help.contains("ERASE"));
|
|
assert!(help.contains("LUKS2"));
|
|
}
|
|
|
|
#[test]
|
|
fn assets_include_the_welcome_launcher_and_branding() {
|
|
let welcome = system::desktop_asset("welcome").expect("welcome asset");
|
|
assert!(welcome.contains("quickshell --no-duplicate -c phoebus-welcome"));
|
|
// Duplicate installer sessions are prevented.
|
|
let install = system::desktop_asset("install").expect("install asset");
|
|
assert!(install.contains("quickshell --no-duplicate -c phoebus-install"));
|
|
assert!(install.contains("pgrep -f"));
|
|
// Branding assets are reachable through the same `--emit-asset` dispatch.
|
|
for name in [
|
|
"brand-emblem",
|
|
"brand-wordmark",
|
|
"brand-wallpaper",
|
|
"brand-tokens",
|
|
] {
|
|
assert!(system::desktop_asset(name).is_some(), "{name} missing");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn installed_session_never_starts_the_welcome() {
|
|
// The live-only marker is the gate; the installed session script must not
|
|
// autostart the welcome unless the marker exists.
|
|
let script = system::desktop_asset("session-mango").unwrap();
|
|
assert!(script.contains("/etc/phoebus/live"));
|
|
assert!(script.contains("phoebus-welcome"));
|
|
}
|
|
|
|
#[test]
|
|
fn qml_theme_matches_the_backend_palette() {
|
|
let qml = read("installer/live/desktop/common/Theme.qml");
|
|
for token in [
|
|
phoebus_core::brand::PALETTE.charcoal,
|
|
phoebus_core::brand::PALETTE.surface,
|
|
phoebus_core::brand::PALETTE.border,
|
|
phoebus_core::brand::PALETTE.warm_white,
|
|
phoebus_core::brand::PALETTE.muted,
|
|
phoebus_core::brand::PALETTE.amber,
|
|
phoebus_core::brand::PALETTE.amber_deep,
|
|
phoebus_core::brand::PALETTE.success,
|
|
phoebus_core::brand::PALETTE.warning,
|
|
phoebus_core::brand::PALETTE.danger,
|
|
] {
|
|
assert!(
|
|
qml.contains(token),
|
|
"Theme.qml is missing brand token {token}"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn installer_help_is_available_to_the_gui() {
|
|
let help = read("installer/live/install-help.txt");
|
|
assert!(help.contains("deterministic `sys`"));
|
|
assert!(help.contains("installation medium"));
|
|
}
|
|
|
|
#[test]
|
|
fn welcome_primary_action_is_keyboard_reachable() {
|
|
let qml = read("installer/live/desktop/phoebus-welcome/shell.qml");
|
|
// The tiled window may not be focused at session start, so the launcher
|
|
// must request activation and force focus on the primary action; without
|
|
// this the focus ring (and Enter) never reach it.
|
|
assert!(
|
|
qml.contains("forceActiveFocus"),
|
|
"welcome never forces focus"
|
|
);
|
|
assert!(
|
|
qml.contains("requestActivate"),
|
|
"welcome never requests activation"
|
|
);
|
|
assert!(
|
|
qml.contains("id: installButton") || qml.contains("id: window"),
|
|
"welcome has no identifiable primary action"
|
|
);
|
|
// Regression: `FloatingWindow` has no `onActiveChanged`; using it makes the
|
|
// whole configuration fail to load.
|
|
assert!(
|
|
!qml.contains("onActiveChanged"),
|
|
"welcome uses a non-existent FloatingWindow signal"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn progress_cannot_be_abandoned_silently() {
|
|
let qml = read("installer/live/desktop/phoebus-install/shell.qml");
|
|
// Escape during the destructive stage must not close the frontend without
|
|
// an explanation.
|
|
assert!(
|
|
qml.contains("cannot be cancelled"),
|
|
"no truthful cancellation message"
|
|
);
|
|
assert!(
|
|
qml.contains("shell.phase === \"progress\""),
|
|
"the guard against closing mid-install is missing"
|
|
);
|
|
}
|