2
2
// Under linux, we choose to use smem, which can monitor memory changes more accurately
3
3
4
4
use ckb_vm:: { run_with_memory, Bytes , FlatMemory , SparseMemory } ;
5
- use lazy_static:: lazy_static;
6
5
use std:: process:: { id, Command } ;
7
6
8
7
#[ cfg( has_asm) ]
@@ -17,11 +16,8 @@ use ckb_vm::{
17
16
#[ cfg( has_asm) ]
18
17
use std:: thread;
19
18
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" ;
25
21
26
22
#[ cfg( not( target_os = "windows" ) ) ]
27
23
#[ global_allocator]
@@ -128,8 +124,8 @@ fn check_interpreter(memory_size: usize) -> Result<(), ()> {
128
124
println ! ( "Base memory: {}" , get_current_memory( ) ) ;
129
125
for _ in 0 ..G_CHECK_LOOP {
130
126
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 ) ] ,
133
129
SparseMemory :: new_with_memory ( memory_size) ,
134
130
) ;
135
131
assert ! ( result. is_ok( ) ) ;
@@ -148,8 +144,8 @@ fn check_falt(memory_size: usize) -> Result<(), ()> {
148
144
println ! ( "Base memory: {}" , get_current_memory( ) ) ;
149
145
for _ in 0 ..G_CHECK_LOOP {
150
146
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 ) ] ,
153
149
FlatMemory :: new_with_memory ( memory_size) ,
154
150
) ;
155
151
assert ! ( result. is_ok( ) ) ;
@@ -172,7 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> {
172
168
let core = DefaultMachineBuilder :: new ( asm_core) . build ( ) ;
173
169
let mut machine = AsmMachine :: new ( core) ;
174
170
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 ) ] )
176
172
. unwrap ( ) ;
177
173
let result = machine. run ( ) ;
178
174
assert ! ( result. is_ok( ) ) ;
@@ -196,7 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> {
196
192
let core = DefaultMachineBuilder :: new ( asm_core) . build ( ) ;
197
193
let mut machine = AsmMachine :: new ( core) ;
198
194
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 ) ] )
200
196
. unwrap ( ) ;
201
197
let thread_join_handle = thread:: spawn ( move || {
202
198
let result = machine. run ( ) ;
0 commit comments