log the run so travis doesn't timeout
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from __future__ import print_function
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
def logrun(cmd, file, timeout):
|
||||
with open(file, 'w') as outf:
|
||||
p = subprocess.Popen(cmd, stdout=outf, stderr=outf)
|
||||
start = time.time()
|
||||
oldContents = ""
|
||||
while (p.poll() is None) and ((time.time() - start) < timeout):
|
||||
with open(file, 'r') as inf:
|
||||
contents = inf.read()
|
||||
if len(contents) > len(oldContents):
|
||||
print(contents[len(oldContents):], end="")
|
||||
oldContents = contents
|
||||
time.sleep(1)
|
||||
print()
|
||||
if p.poll() is None:
|
||||
return ("TIMEOUT", contents)
|
||||
return (p.returncode, contents)
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import subprocess
|
||||
from unittest import TestCase
|
||||
import logrun
|
||||
|
||||
|
||||
class TestBasicFunctionality(TestCase):
|
||||
def test_basic_functionality(self):
|
||||
deepstate = os.getenv("DEEPSTATE_CMD")
|
||||
if deepstate is None:
|
||||
deepstate = "deepstate-angr" # default to angr in an environment without a defined command
|
||||
|
||||
r = subprocess.call([deepstate + " build/examples/IntegerArithmetic | tee deepstate.out"],
|
||||
shell=True)
|
||||
(r, output) = logrun.logrun([deepstate, "build/examples/IntegerArithmetic"],
|
||||
"deepstate.out", 1800)
|
||||
self.assertEqual(r, 0)
|
||||
|
||||
with open("deepstate.out", 'r') as outf:
|
||||
result = outf.read()
|
||||
|
||||
print ("RESULT:", result)
|
||||
|
||||
self.assertTrue("Passed: Arithmetic_AdditionIsCommutative" in result)
|
||||
self.assertTrue("Passed: Arithmetic_AdditionIsAssociative" in result)
|
||||
self.assertTrue("Passed: Arithmetic_InvertibleMultiplication_CanFail" in result)
|
||||
self.assertTrue("Failed: Arithmetic_InvertibleMultiplication_CanFail" in result)
|
||||
self.assertTrue("Passed: Arithmetic_AdditionIsCommutative" in output)
|
||||
self.assertTrue("Passed: Arithmetic_AdditionIsAssociative" in output)
|
||||
self.assertTrue("Passed: Arithmetic_InvertibleMultiplication_CanFail" in output)
|
||||
self.assertTrue("Failed: Arithmetic_InvertibleMultiplication_CanFail" in output)
|
||||
|
||||
Reference in New Issue
Block a user