test: clean up a few minor details
This commit is contained in:
parent
f81c30d7d9
commit
3bf55f92b8
|
@ -24,13 +24,15 @@ use lzbt_systemd::architecture::SystemdArchitectureExt;
|
||||||
/// in the system double format for
|
/// in the system double format for
|
||||||
/// our usual targets.
|
/// our usual targets.
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
pub static TARGET_SYSTEM_DOUBLE: &'static str = "aarch64-linux";
|
pub static SYSTEM: &str = "aarch64-linux";
|
||||||
|
|
||||||
|
// We do not actually care much about 32 bit. However we can use this to easily test that lzbt
|
||||||
|
// works with another architecture.
|
||||||
#[cfg(target_arch = "x86")]
|
#[cfg(target_arch = "x86")]
|
||||||
pub static TARGET_SYSTEM_DOUBLE: &'static str = "i686-linux";
|
pub static SYSTEM: &str = "i686-linux";
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub static TARGET_SYSTEM_DOUBLE: &'static str = "x86_64-linux";
|
pub static SYSTEM: &str = "x86_64-linux";
|
||||||
|
|
||||||
/// Create a mock generation link.
|
/// Create a mock generation link.
|
||||||
///
|
///
|
||||||
|
@ -70,7 +72,7 @@ pub fn setup_generation_link_from_toplevel(
|
||||||
],
|
],
|
||||||
"label": "LanzaOS",
|
"label": "LanzaOS",
|
||||||
"toplevel": toplevel,
|
"toplevel": toplevel,
|
||||||
"system": TARGET_SYSTEM_DOUBLE,
|
"system": SYSTEM,
|
||||||
},
|
},
|
||||||
"org.nixos-community.lanzaboote": { "osRelease": toplevel.join("os-release") }
|
"org.nixos-community.lanzaboote": { "osRelease": toplevel.join("os-release") }
|
||||||
});
|
});
|
||||||
|
@ -93,7 +95,7 @@ pub fn setup_generation_link_from_toplevel(
|
||||||
/// Accepts the temporary directory as a parameter so that the invoking function retains control of
|
/// Accepts the temporary directory as a parameter so that the invoking function retains control of
|
||||||
/// it (and when it goes out of scope).
|
/// it (and when it goes out of scope).
|
||||||
pub fn setup_toplevel(tmpdir: &Path) -> Result<PathBuf> {
|
pub fn setup_toplevel(tmpdir: &Path) -> Result<PathBuf> {
|
||||||
let system = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE)?;
|
let system = Architecture::from_nixos_system(SYSTEM)?;
|
||||||
// Generate a random toplevel name so that multiple toplevel paths can live alongside each
|
// Generate a random toplevel name so that multiple toplevel paths can live alongside each
|
||||||
// other in the same directory.
|
// other in the same directory.
|
||||||
let toplevel = tmpdir.join(format!("toplevel-{}", random_string(8)));
|
let toplevel = tmpdir.join(format!("toplevel-{}", random_string(8)));
|
||||||
|
@ -139,7 +141,7 @@ pub fn lanzaboote_install(
|
||||||
) -> Result<Output> {
|
) -> Result<Output> {
|
||||||
// To simplify the test setup, we use the systemd stub here instead of the lanzaboote stub. See
|
// To simplify the test setup, we use the systemd stub here instead of the lanzaboote stub. See
|
||||||
// the comment in setup_toplevel for details.
|
// the comment in setup_toplevel for details.
|
||||||
let system = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE)?;
|
let system = Architecture::from_nixos_system(SYSTEM)?;
|
||||||
let test_systemd = systemd_location_from_env()?;
|
let test_systemd = systemd_location_from_env()?;
|
||||||
let systemd_stub_filename = system.systemd_stub_filename();
|
let systemd_stub_filename = system.systemd_stub_filename();
|
||||||
let test_systemd_stub = format!(
|
let test_systemd_stub = format!(
|
||||||
|
@ -157,7 +159,7 @@ pub fn lanzaboote_install(
|
||||||
.arg("-vv")
|
.arg("-vv")
|
||||||
.arg("install")
|
.arg("install")
|
||||||
.arg("--system")
|
.arg("--system")
|
||||||
.arg(TARGET_SYSTEM_DOUBLE)
|
.arg(SYSTEM)
|
||||||
.arg("--systemd")
|
.arg("--systemd")
|
||||||
.arg(test_systemd)
|
.arg(test_systemd)
|
||||||
.arg("--systemd-boot-loader-config")
|
.arg("--systemd-boot-loader-config")
|
||||||
|
|
|
@ -8,7 +8,7 @@ use tempfile::tempdir;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
use common::{hash_file, mtime, remove_signature, verify_signature, TARGET_SYSTEM_DOUBLE};
|
use common::{hash_file, mtime, remove_signature, verify_signature, SYSTEM};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn keep_systemd_boot_binaries() -> Result<()> {
|
fn keep_systemd_boot_binaries() -> Result<()> {
|
||||||
|
@ -115,14 +115,14 @@ fn overwrite_unsigned_systemd_boot_binaries() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn systemd_boot_path(esp: &tempfile::TempDir) -> PathBuf {
|
fn systemd_boot_path(esp: &tempfile::TempDir) -> PathBuf {
|
||||||
let arch = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE).unwrap();
|
let arch = Architecture::from_nixos_system(SYSTEM).unwrap();
|
||||||
esp.path()
|
esp.path()
|
||||||
.join("EFI/systemd/")
|
.join("EFI/systemd/")
|
||||||
.join(arch.systemd_filename())
|
.join(arch.systemd_filename())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn systemd_boot_fallback_path(esp: &tempfile::TempDir) -> PathBuf {
|
fn systemd_boot_fallback_path(esp: &tempfile::TempDir) -> PathBuf {
|
||||||
let arch = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE).unwrap();
|
let arch = Architecture::from_nixos_system(SYSTEM).unwrap();
|
||||||
esp.path()
|
esp.path()
|
||||||
.join("EFI/BOOT/")
|
.join("EFI/BOOT/")
|
||||||
.join(arch.efi_fallback_filename())
|
.join(arch.efi_fallback_filename())
|
||||||
|
|
Loading…
Reference in New Issue