Skip to content

Commit

Permalink
tests: Only run bin tests on x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Jun 21, 2023
1 parent f28005d commit 9c24f61
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 38 deletions.
23 changes: 13 additions & 10 deletions tests/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,24 @@ fn test_add() {
.unwrap();
cmd.assert().code(0);

let output = Command::new("unsquashfs")
.args([
"-lln",
"-UTC",
tmp_dir.path().join("out1").to_str().unwrap(),
])
.output()
.unwrap();
let expected = r#"drwxr-xr-x 1000/1000 36 2022-10-14 03:02 squashfs-root
#[cfg(target_arch = "x86_64")]
{
let output = Command::new("unsquashfs")
.args([
"-lln",
"-UTC",
tmp_dir.path().join("out1").to_str().unwrap(),
])
.output()
.unwrap();
let expected = r#"drwxr-xr-x 1000/1000 36 2022-10-14 03:02 squashfs-root
drwxr-xr-x 1000/1000 24 2022-10-14 03:02 squashfs-root/b
drwxr-xr-x 1000/1000 24 2022-10-14 03:03 squashfs-root/b/c
-rw-r--r-- 1000/1000 39 2022-10-14 03:03 squashfs-root/b/c/d
dr----x--t 2/4242 26 1970-01-01 00:01 squashfs-root/test
-rw-r--r-- 4242/2 4 1970-01-01 00:02 squashfs-root/test/new
"#;

assert_eq!(expected, std::str::from_utf8(&output.stdout).unwrap());
assert_eq!(expected, std::str::from_utf8(&output.stdout).unwrap());
}
}
9 changes: 6 additions & 3 deletions tests/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ fn test_add_00() {
}
// force output to drop, so buffer is written

// compare
let control_new_path = format!("{TEST_PATH}/control.squashfs");
test_unsquashfs(&new_path, &control_new_path, None);
// compare when on x86 host
#[cfg(target_arch = "x86_64")]
{
let control_new_path = format!("{TEST_PATH}/control.squashfs");
test_unsquashfs(&new_path, &control_new_path, None);
}
}
7 changes: 5 additions & 2 deletions tests/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ fn test_raw_00() {
);

// compare
let control_new_path = format!("{TEST_PATH}/control.squashfs");
test_unsquashfs(&new_path, &control_new_path, None);
#[cfg(target_arch = "x86_64")]
{
let control_new_path = format!("{TEST_PATH}/control.squashfs");
test_unsquashfs(&new_path, &control_new_path, None);
}
}
49 changes: 26 additions & 23 deletions tests/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,31 @@ fn test_replace() {
cmd.assert().code(0);

// extract
let cmd = Command::cargo_bin("unsquashfs")
.unwrap()
.env("RUST_LOG", "none")
.args([
"--path-filter",
r#"/b/c/d"#,
"-i",
tmp_dir.path().join("replaced").to_str().unwrap(),
"-d",
tmp_dir.path().join("squashfs-root-rust2").to_str().unwrap(),
])
.unwrap();
cmd.assert().code(0);
#[cfg(target_arch = "x86_64")]
{
let cmd = Command::cargo_bin("unsquashfs")
.unwrap()
.env("RUST_LOG", "none")
.args([
"--path-filter",
r#"/b/c/d"#,
"-i",
tmp_dir.path().join("replaced").to_str().unwrap(),
"-d",
tmp_dir.path().join("squashfs-root-rust2").to_str().unwrap(),
])
.unwrap();
cmd.assert().code(0);

// assert the text changed!
let bytes = std::fs::read(
tmp_dir
.path()
.join("squashfs-root-rust2/b/c/d")
.to_str()
.unwrap(),
)
.unwrap();
assert_eq!(bytes, text);
// assert the text changed!
let bytes = std::fs::read(
tmp_dir
.path()
.join("squashfs-root-rust2/b/c/d")
.to_str()
.unwrap(),
)
.unwrap();
assert_eq!(bytes, text);
}
}
1 change: 1 addition & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn full_test(
let new_comp_opts = written_new_filesystem.compression_options;
assert_eq!(og_comp_opts, new_comp_opts);

#[cfg(target_arch = "x86_64")]
match verify {
Verify::Extract => {
info!("starting squashfs-tools/unsquashfs test");
Expand Down
2 changes: 2 additions & 0 deletions tests/unsquashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use test_assets::TestAssetDef;

#[test]
#[cfg(feature = "xz")]
#[cfg(target_arch = "x86_64")]
fn test_unsquashfs_cli_path_filter() {
const FILE_NAME: &str = "870D97.squashfs";
let asset_defs = [TestAssetDef {
Expand Down Expand Up @@ -53,6 +54,7 @@ fn test_unsquashfs_cli_path_filter() {

#[test]
#[cfg(feature = "xz")]
#[cfg(target_arch = "x86_64")]
fn test_unsquashfs_cli_auto_offset() {
use tempfile::tempdir;

Expand Down

0 comments on commit 9c24f61

Please sign in to comment.