22// Under linux, we choose to use smem, which can monitor memory changes more accurately
33
44use ckb_vm:: { run_with_memory, Bytes , FlatMemory , SparseMemory } ;
5- use lazy_static:: lazy_static;
65use std:: process:: { id, Command } ;
76
87#[ cfg( has_asm) ]
@@ -17,11 +16,8 @@ use ckb_vm::{
1716#[ cfg( has_asm) ]
1817use std:: thread;
1918
20- lazy_static ! {
21- pub static ref BIN_PATH_BUFFER : Bytes =
22- Bytes :: from( & include_bytes!( "../tests/programs/alloc_many" ) [ ..] ) ;
23- pub static ref BIN_NAME : String = format!( "alloc_many" ) ;
24- }
19+ static BIN_PATH_BUFFER : & ' static [ u8 ] = include_bytes ! ( "../tests/programs/alloc_many" ) ;
20+ static BIN_NAME : & str = "alloc_many" ;
2521
2622#[ cfg( not( target_os = "windows" ) ) ]
2723#[ global_allocator]
@@ -128,8 +124,8 @@ fn check_interpreter(memory_size: usize) -> Result<(), ()> {
128124 println ! ( "Base memory: {}" , get_current_memory( ) ) ;
129125 for _ in 0 ..G_CHECK_LOOP {
130126 let result = run_with_memory :: < u64 , SparseMemory < u64 > > (
131- & BIN_PATH_BUFFER ,
132- & vec ! [ BIN_NAME . clone ( ) . into ( ) ] ,
127+ & Bytes :: from ( BIN_PATH_BUFFER ) ,
128+ & vec ! [ Bytes :: from ( BIN_NAME ) ] ,
133129 SparseMemory :: new_with_memory ( memory_size) ,
134130 ) ;
135131 assert ! ( result. is_ok( ) ) ;
@@ -148,8 +144,8 @@ fn check_falt(memory_size: usize) -> Result<(), ()> {
148144 println ! ( "Base memory: {}" , get_current_memory( ) ) ;
149145 for _ in 0 ..G_CHECK_LOOP {
150146 let result = run_with_memory :: < u64 , FlatMemory < u64 > > (
151- & BIN_PATH_BUFFER ,
152- & vec ! [ BIN_NAME . clone ( ) . into ( ) ] ,
147+ & Bytes :: from ( BIN_PATH_BUFFER ) ,
148+ & vec ! [ Bytes :: from ( BIN_NAME ) ] ,
153149 FlatMemory :: new_with_memory ( memory_size) ,
154150 ) ;
155151 assert ! ( result. is_ok( ) ) ;
@@ -172,7 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> {
172168 let core = DefaultMachineBuilder :: new ( asm_core) . build ( ) ;
173169 let mut machine = AsmMachine :: new ( core) ;
174170 machine
175- . load_program ( & BIN_PATH_BUFFER , & vec ! [ BIN_NAME . clone ( ) . into ( ) ] )
171+ . load_program ( & Bytes :: from ( BIN_PATH_BUFFER ) , & vec ! [ Bytes :: from ( BIN_NAME ) ] )
176172 . unwrap ( ) ;
177173 let result = machine. run ( ) ;
178174 assert ! ( result. is_ok( ) ) ;
@@ -196,7 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> {
196192 let core = DefaultMachineBuilder :: new ( asm_core) . build ( ) ;
197193 let mut machine = AsmMachine :: new ( core) ;
198194 machine
199- . load_program ( & BIN_PATH_BUFFER , & vec ! [ BIN_NAME . clone ( ) . into ( ) ] )
195+ . load_program ( & Bytes :: from ( BIN_PATH_BUFFER ) , & vec ! [ Bytes :: from ( BIN_NAME ) ] )
200196 . unwrap ( ) ;
201197 let thread_join_handle = thread:: spawn ( move || {
202198 let result = machine. run ( ) ;
0 commit comments