@@ -63,7 +63,7 @@ def execute_in_evm(code: str, expected: str) -> str:
63
63
try :
64
64
emv_path = os .environ ['EVM_PATH' ] + "/evm"
65
65
except KeyError :
66
- print ("EVM_PATH not defined, using pwd instead" )
66
+ # print("EVM_PATH not defined, using pwd instead")
67
67
evm_pth = "evm"
68
68
69
69
command = ["evm" , "--code" , code , "run" ]
@@ -86,7 +86,7 @@ def process_line(input: str) -> str:
86
86
return input [:index ]
87
87
88
88
def remove_directives_in_assembly (input : str ) -> str :
89
- print ("EVM TEST: removing directives" )
89
+ # print("EVM TEST: removing directives")
90
90
cleaned_input = []
91
91
for line in input .split ("\n " ):
92
92
# ignore directives
@@ -111,8 +111,8 @@ def generate_asm_file(infilename: str, outfilename: str) -> str:
111
111
llc_exec = "llc"
112
112
113
113
command = [llc_exec , "-mtriple=evm" , "-filetype=asm" , infilename , "-o" , outfilename ]
114
- print ("EVM TEST: executing command:" )
115
- print (' ' .join (command ))
114
+ # print("EVM TEST: executing command:")
115
+ # print(' '.join(command))
116
116
117
117
result = subprocess .run (command , stdout = subprocess .PIPE )
118
118
result .check_returncode ()
@@ -131,7 +131,7 @@ def check_result(name: str, result: str, expected: str) -> bool:
131
131
print ("Test \" " + name + "\" passed." )
132
132
return True
133
133
134
- def run_assembly (name : str , inputs : List [str ], output : str , filename : str ) -> None :
134
+ def run_assembly (name : str , inputs : List [str ], output : str , filename : str ) -> bool :
135
135
assembly_filename = Template (
136
136
"/tmp/evm_test_${num}.s" ).substitute (num = randint (0 , 65535 ))
137
137
generate_asm_file (filename , assembly_filename )
@@ -203,18 +203,31 @@ def run_string_input(name: str, inputs: List[str], output: str, function: str) -
203
203
},
204
204
}
205
205
206
+ def assembly_tests () -> List [str ]:
207
+ failed_tests = []
208
+ for key ,val in file_input_fixtures .items ():
209
+ inputs = val ["input" ]
210
+ output = val ["output" ]
211
+ filename = runtime_file_prefix + key
212
+ result = run_assembly (name = key , inputs = inputs ,
213
+ output = output , filename = filename )
214
+ if not result :
215
+ failed_tests .append (key )
216
+ return failed_tests
217
+
218
+ def print_failed (tests : List [str ]) -> None :
219
+ print ("The following test cases are failing:" )
220
+ for t in tests :
221
+ print (" " + t )
222
+
206
223
def execute_tests () -> None :
207
224
for key ,val in string_input_fixtures .items ():
208
225
inputs = val ["input" ]
209
226
output = val ["output" ]
210
227
function = val ["func" ]
211
228
run_string_input (name = key , inputs = inputs , output = output , function = function )
212
-
213
- for key ,val in file_input_fixtures .items ():
214
- inputs = val ["input" ]
215
- output = val ["output" ]
216
- filename = runtime_file_prefix + key
217
- run_assembly (name = key , inputs = inputs , output = output , filename = filename )
229
+ failed_asembly = assembly_tests ()
230
+ print_failed (failed_asembly )
218
231
219
232
seed (2019 )
220
233
execute_tests ()
0 commit comments