From f67e460a91ad7d9b368555599db359e23ec82129 Mon Sep 17 00:00:00 2001 From: xjd Date: Mon, 20 May 2024 09:36:22 +0800 Subject: [PATCH] Add case with saturate memory 128M peak memory in a script --- .../tests/ckb_latest/features_since_v2023.rs | 6 +++ script/testdata/Makefile | 4 +- script/testdata/spawn_saturate_memory | Bin 0 -> 4864 bytes script/testdata/spawn_saturate_memory.c | 45 ++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 script/testdata/spawn_saturate_memory create mode 100644 script/testdata/spawn_saturate_memory.c diff --git a/script/src/verify/tests/ckb_latest/features_since_v2023.rs b/script/src/verify/tests/ckb_latest/features_since_v2023.rs index d6539cfcb1..a465c6515a 100644 --- a/script/src/verify/tests/ckb_latest/features_since_v2023.rs +++ b/script/src/verify/tests/ckb_latest/features_since_v2023.rs @@ -1320,3 +1320,9 @@ fn check_spawn_io_cycles() { assert_eq!(cycles2 - cycles1, offset_size / 2); } + +#[test] +fn check_spawn_saturate_memory() { + let result = simple_spawn_test("testdata/spawn_saturate_memory", &[0]); + assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); +} diff --git a/script/testdata/Makefile b/script/testdata/Makefile index 71325a06c4..8d72cc3900 100644 --- a/script/testdata/Makefile +++ b/script/testdata/Makefile @@ -74,7 +74,8 @@ ALL_BINS := jalr_zero \ spawn_fuzzing \ spawn_huge_swap \ spawn_cycles \ - spawn_io_cycles + spawn_io_cycles \ + spawn_saturate_memory ALL_LIBS := is_even.lib \ add1.lib sub1.lib mul2.lib div2.lib @@ -162,3 +163,4 @@ spawn_fuzzing: spawn_fuzzing.c spawn_utils.h spawn_huge_swap: spawn_huge_swap.c spawn_utils.h spawn_cycles: spawn_cycles.c spawn_utils.h spawn_io_cycles: spawn_io_cycles.c spawn_utils.h +spawn_saturate_memory: spawn_saturate_memory.c spawn_utils.h diff --git a/script/testdata/spawn_saturate_memory b/script/testdata/spawn_saturate_memory new file mode 100755 index 0000000000000000000000000000000000000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-gdceFzcm@YTfHvcuO{>1 z*B*=2Sh65Qaa>(xuBa?A zTZ#Y{%UlAC#^TcQg8WirML9-ImFXDSuv+^|tuaSuSes`w;&IM~4Mttw>M&hURb{NQ zHbPfq1E73N#=fzf2fWs_O8t;~{NfO|`2q~9!27Sq!fkXczC=FY@AK_)6M zD>Io1N{S~l-(smODX>~hcd8#d=l^WUSdN55`W7L@iTIneI4PkcL!6^i+gv;(@)9o9 z-}|E6b5q&z7n7;&emo?YSO$0UQ2gF8y+o(WXJT2h{`50L`rZ 0) { + // child + dirty_all_pages(); + uint64_t inherited_fds[2]; + size_t inherited_fds_length = 2; + err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + uint64_t length = MAX_MEMORY; + // Write a piece of data starting from address 0 with a size of 4M. + // Internally, it is cached before being read out. + err = ckb_write(inherited_fds[CKB_STDOUT], 0, &length); + // should be blocked forever since there is no reading on other end + CHECK(err); + } else { + // parent + for (size_t i = 0; i < 15; i++) { + uint64_t pid = 0; + const char* argv[] = {"", 0}; + uint64_t fds[2] = {0}; + err = full_spawn(0, 1, argv, fds, &pid); + CHECK(err); + } + dirty_all_pages(); + } + +exit: + return err; +}