Skip to content

Commit 17e0dbe

Browse files
committed
small passing fuzz test
1 parent 566ed60 commit 17e0dbe

File tree

11 files changed

+786
-53
lines changed

11 files changed

+786
-53
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
- name: Install candid-extractor
5454
run: cargo install candid-extractor
5555

56+
- name: Install ic-test
57+
run: cargo install ic-test
58+
5659
# Build everything
5760
- name: Build test projects
5861
run: ./scripts/build_tests.sh

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ test/test_programs
1212

1313
lcov.info
1414
codecov.json
15-
16-
.codegpt
15+
playground

fuzz-tests/src/bindings/fs_tests_backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn canister_id() -> Option<Principal> {
121121
pub fn wasm() -> Option<Vec<u8>> {
122122
let mut path = std::path::PathBuf::new();
123123
path.push("../target/wasm32-wasip1/release/fs_tests_backend_nowasi.wasm");
124-
let wasm =
125-
std::fs::read(path.as_path()).unwrap_or_else(|_| panic!("wasm binary not found: {path:?}"));
124+
let wasm = std::fs::read(path.as_path())
125+
.unwrap_or_else(|_| panic!("wasm binary not found: {:?}", path));
126126
Some(wasm)
127127
}

fuzz-tests/src/tests.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::f32::consts::E;
2+
13
use ic_test::IcpTest;
24

35
use crate::test_setup;
@@ -29,5 +31,10 @@ async fn test_fs_durability() {
2931

3032
let expected = std::fs::read_to_string("../target/release/report.txt").unwrap();
3133

32-
assert_eq!(result.trim(), expected.trim());
34+
let computed = result.trim().split("\n");
35+
let expected = expected.trim().split("\n");
36+
37+
for (c, e) in computed.zip(expected) {
38+
assert_eq!(c, e);
39+
}
3340
}

ic-wasi-polyfill/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ repository = "https://github.com/wasm-forge/ic-wasi-polyfill"
1010
[dependencies]
1111
ic-cdk = "0.18.5"
1212
ic-stable-structures = "0.6.7"
13-
stable-fs = "0.8.1"
13+
#stable-fs = "0.8.1"
14+
stable-fs = {path="../../stable-fs"}
1415

1516

1617
rand = "0.9.1"

ic-wasi-polyfill/tests/lib_tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
mod common;
22

3-
use std::fs::read_to_string;
4-
53
use common::*;
64
use ic_wasi_polyfill::wasi::{self, Fd};
75
use ic_wasi_polyfill::wasi_helpers::DIRENT_SIZE;

scripts/build_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ candid-extractor target/wasm32-wasip1/release/fs_tests_backend.wasm > test/canis
99

1010
wasi2ic target/wasm32-wasip1/release/fs_tests_backend.wasm target/wasm32-wasip1/release/fs_tests_backend_nowasi.wasm
1111

12+
ic-test update --force
13+
1214
# build fs_tests for local launch
1315
cargo build --release
1416

scripts/perf.repl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!ic-repl
2+
3+
function install(wasm, args, cycle) {
4+
let id = call ic.provisional_create_canister_with_cycles(record { settings = null; amount = cycle });
5+
let S = id.canister_id;
6+
let _ = call ic.install_code(
7+
record {
8+
arg = args;
9+
wasm_module = gzip(wasm);
10+
mode = variant { install };
11+
canister_id = S;
12+
}
13+
);
14+
S
15+
};
16+
17+
function upgrade(id, wasm, args) {
18+
call ic.install_code(
19+
record {
20+
arg = args;
21+
wasm_module = gzip(wasm);
22+
mode = variant { upgrade };
23+
canister_id = id;
24+
}
25+
);
26+
};
27+
28+
function uninstall(id) {
29+
call ic.stop_canister(record { canister_id = id });
30+
call ic.delete_canister(record { canister_id = id });
31+
};
32+
33+
function get_memory(cid) {
34+
let _ = call ic.canister_status(record { canister_id = cid });
35+
_.memory_size
36+
};
37+
38+
let file = "README.md";
39+
40+
let rs_config = record { start_page = 1; page_limit = 1128};
41+
42+
let wasm_name = "../target/wasm32-wasip1/release/fs_tests_backend_nowasi.wasm";
43+
44+
45+
function perf_fuzz_test() {
46+
let cid = install(wasm_profiling(wasm_name, rs_config), encode (), null);
47+
48+
call cid.do_fs_test_basic();
49+
50+
flamegraph(cid, "perf_write_10mb", "svg/perf_fuzz_test.svg");
51+
uninstall(cid)
52+
};
53+
54+
55+
/// main calls
56+
perf_fuzz_test();

0 commit comments

Comments
 (0)