From 3bf55f92b871bae05a1832542c724314c1ef1ff0 Mon Sep 17 00:00:00 2001 From: nikstur Date: Thu, 14 Sep 2023 16:15:50 +0200 Subject: [PATCH] test: clean up a few minor details --- rust/tool/systemd/tests/common/mod.rs | 16 +++++++++------- rust/tool/systemd/tests/systemd_boot.rs | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rust/tool/systemd/tests/common/mod.rs b/rust/tool/systemd/tests/common/mod.rs index 0e1182c..ac17003 100644 --- a/rust/tool/systemd/tests/common/mod.rs +++ b/rust/tool/systemd/tests/common/mod.rs @@ -24,13 +24,15 @@ use lzbt_systemd::architecture::SystemdArchitectureExt; /// in the system double format for /// our usual targets. #[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")] -pub static TARGET_SYSTEM_DOUBLE: &'static str = "i686-linux"; +pub static SYSTEM: &str = "i686-linux"; #[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. /// @@ -70,7 +72,7 @@ pub fn setup_generation_link_from_toplevel( ], "label": "LanzaOS", "toplevel": toplevel, - "system": TARGET_SYSTEM_DOUBLE, + "system": SYSTEM, }, "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 /// it (and when it goes out of scope). pub fn setup_toplevel(tmpdir: &Path) -> Result { - 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 // other in the same directory. let toplevel = tmpdir.join(format!("toplevel-{}", random_string(8))); @@ -139,7 +141,7 @@ pub fn lanzaboote_install( ) -> Result { // To simplify the test setup, we use the systemd stub here instead of the lanzaboote stub. See // 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 systemd_stub_filename = system.systemd_stub_filename(); let test_systemd_stub = format!( @@ -157,7 +159,7 @@ pub fn lanzaboote_install( .arg("-vv") .arg("install") .arg("--system") - .arg(TARGET_SYSTEM_DOUBLE) + .arg(SYSTEM) .arg("--systemd") .arg(test_systemd) .arg("--systemd-boot-loader-config") diff --git a/rust/tool/systemd/tests/systemd_boot.rs b/rust/tool/systemd/tests/systemd_boot.rs index 53e5fbe..d295f79 100644 --- a/rust/tool/systemd/tests/systemd_boot.rs +++ b/rust/tool/systemd/tests/systemd_boot.rs @@ -8,7 +8,7 @@ use tempfile::tempdir; 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] 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 { - let arch = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE).unwrap(); + let arch = Architecture::from_nixos_system(SYSTEM).unwrap(); esp.path() .join("EFI/systemd/") .join(arch.systemd_filename()) } 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() .join("EFI/BOOT/") .join(arch.efi_fallback_filename())