Skip to content

Commit

Permalink
Merge pull request #632 from wcampbell0x2a/replace-test-assets-with-t…
Browse files Browse the repository at this point in the history
…est-assets-ureq
  • Loading branch information
wcampbell0x2a authored Nov 9, 2024
2 parents edabc62 + 89ce5ad commit 3da32e8
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 31 deletions.
12 changes: 7 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backhand-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ backhand = { path = "../backhand", default-features = false }
assert_cmd = { version = "2.0.16", features = ["color", "color-auto"] }
dir-diff = { git = "https://github.com/wcampbell0x2a/dir-diff", branch = "add-checking-permissions" }
tempfile = "3.13.0"
test-assets = { git = "https://github.com/wcampbell0x2a/test-assets", branch = "replace-curl-ureq" }
test-assets-ureq = "0.3.0"
test-log = { version = "0.2.16", features = ["trace"] }
tracing = "0.1.40"
libdeflater = "1.22.0"
Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::Command;

use assert_cmd::prelude::*;
use tempfile::tempdir;
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;
use test_log::test;

#[test]
Expand Down
14 changes: 3 additions & 11 deletions backhand-test/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ use backon::BlockingRetryable;
use backon::ExponentialBuilder;
use tempfile::tempdir;
use tempfile::tempdir_in;
use test_assets::TestAssetDef;

fn download(assets_defs: &[TestAssetDef], test_path: &str) -> Result<(), Box<dyn Error>> {
if test_assets::download_test_files(assets_defs, test_path, true).is_err() {
return Err("falied to download".into());
}
Ok(())
}
use test_assets_ureq::TestAssetDef;

pub fn download_backoff(assets_defs: &[TestAssetDef], test_path: &str) {
let strategy = ExponentialBuilder::default().with_max_delay(Duration::from_secs(60));

let _result = (|| download(assets_defs, test_path)).retry(strategy).call().unwrap();
test_assets_ureq::dl_test_files_backoff(assets_defs, test_path, true, Duration::from_secs(60))
.unwrap();
}

/// test the new squashfs vs the original squashfs with squashfs-tool/unsquashfs
Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::{BufReader, BufWriter, Cursor};

use backhand::{FilesystemReader, FilesystemWriter, NodeHeader};
use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs};
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;
use test_log::test;

/// Before:
Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/non_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::{BufReader, BufWriter, Write};
use backhand::compression::{CompressionAction, Compressor, DefaultCompressor};
use backhand::kind::{self, Kind};
use backhand::{BackhandError, FilesystemCompressor, FilesystemReader, FilesystemWriter};
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;
use test_log::test;
use tracing::info;

Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use backhand::{
SuperBlock, DEFAULT_BLOCK_SIZE,
};
use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs};
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;

#[test]
#[cfg(all(feature = "xz", feature = "gzip"))]
Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::Command;

use assert_cmd::prelude::*;
use tempfile::tempdir;
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;
use test_log::test;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use assert_cmd::Command;
use backhand::{FilesystemReader, FilesystemWriter};
use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs};
use tempfile::tempdir;
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;
use test_log::test;
use tracing::info;

Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/unsquashfs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod common;

use assert_cmd::prelude::*;
use test_assets::TestAssetDef;
use test_assets_ureq::TestAssetDef;

#[test]
#[cfg(feature = "xz")]
Expand Down
2 changes: 1 addition & 1 deletion backhand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ zstd = ["dep:zstd", "dep:zstd-safe"]

[dev-dependencies]
test-log = { version = "0.2.16", features = ["trace"] }
test-assets = { git = "https://github.com/wcampbell0x2a/test-assets", branch = "replace-curl-ureq" }
test-assets-ureq = "0.3.0"
assert_cmd = { version = "2.0.16", features = ["color", "color-auto"] }
dir-diff = { git = "https://github.com/wcampbell0x2a/dir-diff", branch = "add-checking-permissions" }
tempfile = "3.13.0"
Expand Down
14 changes: 8 additions & 6 deletions backhand/benches/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::fs::File;
use std::io::{BufReader, Cursor};
use std::process::Command;
use std::time::Duration;

use assert_cmd::prelude::*;
use backhand::{FilesystemReader, FilesystemWriter};
use criterion::*;
use tempfile::tempdir;
use test_assets::TestAssetDef;
use test_assets_ureq::dl_test_files_backoff;
use test_assets_ureq::TestAssetDef;

fn read_write(file: File, offset: u64) {
let file = BufReader::new(file);
Expand Down Expand Up @@ -38,7 +40,7 @@ pub fn bench_read_write(c: &mut Criterion) {
),
}];
const TEST_PATH_00: &str = "../backhand-cli/test-assets/test_openwrt_netgear_ex6100v2";
test_assets::download_test_files(&asset_defs, TEST_PATH_00, true).unwrap();
dl_test_files_backoff(&asset_defs, TEST_PATH_00, true, Duration::from_secs(1)).unwrap();
let og_path = format!("{TEST_PATH_00}/{FILE_NAME_00}");
group.bench_function("netgear_ax6100v2", |b| {
b.iter(|| {
Expand All @@ -54,7 +56,7 @@ pub fn bench_read_write(c: &mut Criterion) {
url: format!("https://wcampbell.dev/squashfs/testing/test_tplink1800/{FILE_NAME}"),
}];
const TEST_PATH: &str = "test-assets/test_tplink_ax1800";
test_assets::download_test_files(&asset_defs, TEST_PATH, true).unwrap();
dl_test_files_backoff(&asset_defs, TEST_PATH, true, Duration::from_secs(1)).unwrap();
let og_path = format!("{TEST_PATH}/{FILE_NAME}");
group.bench_function("tplink_ax1800", |b| {
b.iter(|| {
Expand All @@ -81,7 +83,7 @@ pub fn bench_read(c: &mut Criterion) {
),
}];
const TEST_PATH_00: &str = "../backhand-cli/test-assets/test_openwrt_netgear_ex6100v2";
test_assets::download_test_files(&asset_defs, TEST_PATH_00, true).unwrap();
dl_test_files_backoff(&asset_defs, TEST_PATH_00, true, Duration::from_secs(1)).unwrap();
let og_path = format!("{TEST_PATH_00}/{FILE_NAME_00}");
group.bench_function("netgear_ax6100v2", |b| {
b.iter(|| {
Expand All @@ -97,7 +99,7 @@ pub fn bench_read(c: &mut Criterion) {
url: format!("https://wcampbell.dev/squashfs/testing/test_tplink1800/{FILE_NAME_01}"),
}];
const TEST_PATH_01: &str = "test-assets/test_tplink_ax1800";
test_assets::download_test_files(&asset_defs, TEST_PATH_01, true).unwrap();
dl_test_files_backoff(&asset_defs, TEST_PATH_01, true, Duration::from_secs(1)).unwrap();
let og_path = format!("{TEST_PATH_01}/{FILE_NAME_01}");
group.bench_function("tplink_ax1800", |b| {
b.iter(|| {
Expand All @@ -123,7 +125,7 @@ pub fn bench_unsquashfs_extract(c: &mut Criterion) {
}];
// Local, because we run unsquashfs
const TEST_PATH: &str = "test-assets/test_openwrt_netgear_ex6100v2";
test_assets::download_test_files(asset_defs, TEST_PATH, true).unwrap();
dl_test_files_backoff(asset_defs, TEST_PATH, true, Duration::from_secs(1)).unwrap();
let path = format!("{TEST_PATH}/{FILE_NAME}");

let tmp_dir = tempdir().unwrap();
Expand Down

0 comments on commit 3da32e8

Please sign in to comment.