Skip to content

Commit

Permalink
Issue #27: clean up printing messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
lialan committed Nov 18, 2019
1 parent 4325524 commit d3fb166
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions tools/evm-test/evm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def execute_in_evm(code: str, expected: str) -> str:
try:
emv_path = os.environ['EVM_PATH'] + "/evm"
except KeyError:
print("EVM_PATH not defined, using pwd instead")
#print("EVM_PATH not defined, using pwd instead")
evm_pth = "evm"

command = ["evm", "--code", code, "run"]
Expand All @@ -86,7 +86,7 @@ def process_line(input: str) -> str:
return input[:index]

def remove_directives_in_assembly(input: str) -> str:
print("EVM TEST: removing directives")
# print("EVM TEST: removing directives")
cleaned_input = []
for line in input.split("\n"):
# ignore directives
Expand All @@ -111,8 +111,8 @@ def generate_asm_file(infilename: str, outfilename: str) -> str:
llc_exec = "llc"

command = [llc_exec, "-mtriple=evm", "-filetype=asm", infilename, "-o", outfilename]
print("EVM TEST: executing command:")
print(' '.join(command))
#print("EVM TEST: executing command:")
#print(' '.join(command))

result = subprocess.run(command, stdout=subprocess.PIPE)
result.check_returncode()
Expand All @@ -131,7 +131,7 @@ def check_result(name: str, result: str, expected: str) -> bool:
print("Test \"" + name + "\" passed.")
return True

def run_assembly(name: str, inputs: List[str], output: str, filename: str) -> None:
def run_assembly(name: str, inputs: List[str], output: str, filename: str) -> bool:
assembly_filename = Template(
"/tmp/evm_test_${num}.s").substitute(num=randint(0, 65535))
generate_asm_file(filename, assembly_filename)
Expand Down Expand Up @@ -203,18 +203,31 @@ def run_string_input(name: str, inputs: List[str], output: str, function: str) -
},
}

def assembly_tests() -> List[str]:
failed_tests = []
for key,val in file_input_fixtures.items():
inputs = val["input"]
output = val["output"]
filename = runtime_file_prefix + key
result = run_assembly(name=key, inputs=inputs,
output=output, filename=filename)
if not result:
failed_tests.append(key)
return failed_tests

def print_failed(tests: List[str]) -> None:
print("The following test cases are failing:")
for t in tests:
print(" " + t)

def execute_tests() -> None:
for key,val in string_input_fixtures.items():
inputs = val["input"]
output = val["output"]
function = val["func"]
run_string_input(name=key, inputs=inputs, output=output, function=function)

for key,val in file_input_fixtures.items():
inputs = val["input"]
output = val["output"]
filename = runtime_file_prefix + key
run_assembly(name=key, inputs=inputs, output=output, filename=filename)
failed_asembly = assembly_tests()
print_failed(failed_asembly)

seed(2019)
execute_tests()

0 comments on commit d3fb166

Please sign in to comment.