Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
fixes for test_evm
Browse files Browse the repository at this point in the history
  • Loading branch information
beaugunderson committed Jul 11, 2017
1 parent b59c908 commit 6ef2600
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
14 changes: 8 additions & 6 deletions oyente/test_evm/evm_unit_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os

from z3 import *
from global_test_params import *
from global_params import *
from arithmetic_utils import *

from ..global_params import *
from ..arithmetic_utils import *

from .global_test_params import *


class EvmUnitTest(object):
def __init__(self, name, data):
Expand All @@ -28,13 +32,12 @@ def gas_info(self):
gas_remaining = long(self.data['gas'], 0)
return (gas_limit, gas_remaining)


def run_test(self):
return self._execute_vm(self.bytecode())

def _execute_vm(self, bytecode):
self._create_bytecode_file(bytecode)
cmd = os.system('python oyente.py -b -s bytecode')
cmd = os.system('python oyente/oyente.py -b -s bytecode')
exit_code = os.WEXITSTATUS(cmd)
return exit_code

Expand Down Expand Up @@ -86,7 +89,6 @@ def _compare_gas_value(self, analysis):
else:
return INCORRECT_GAS


def compare_symbolic(self, global_state):
for key, value in self.storage().items():
key, value = long(key, 0), long(value, 0)
Expand Down
16 changes: 12 additions & 4 deletions oyente/test_evm.py → test_evm.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env python

import json
import glob
import os
import pickle
from test_evm.global_test_params import *
from test_evm.evm_unit_test import EvmUnitTest

from oyente.test_evm.global_test_params import *
from oyente.test_evm.evm_unit_test import EvmUnitTest


def status(exit_code):
if exit_code == 100: return "Pass"
Expand All @@ -16,7 +20,7 @@ def status(exit_code):


def main():
test_dir = 'test_evm/test_data'
test_dir = 'oyente/test_evm/test_data'
files = glob.glob(test_dir+'/vmArithmeticTest.json')
test_cases = {}

Expand All @@ -43,11 +47,15 @@ def main():
pickle.dump(current_test, open("current_test.pickle", "wb"))

exit_code = current_test.run_test()

# Special case when symExec run into exception but it is correct result
if exit_code == EXCEPTION and current_test.is_exception_case():
exit_code = PASS

print "===============%s!====================" % status(exit_code).upper()
if exit_code:
print "===============%s!====================" % status(exit_code).upper()
else:
print "no exit code returned"

testname = testname.encode('utf8')
num_tests += 1
Expand Down

0 comments on commit 6ef2600

Please sign in to comment.