added new results test for basic test

This commit is contained in:
Bryan Herman 2013-08-12 13:17:03 -04:00
parent e178c7b16d
commit 5d00dfa638
4 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,22 @@
#!/usr/bin/env python
import sys
# import statepoint
sys.path.append('../../src/utils')
import statepoint
# read in statepoint file
sp = statepoint.StatePoint('statepoint.10.binary')
sp.read_results()
# set up output string
outstr = ''
# write out k-combined
outstr += 'k-combined:\n'
outstr += "{0:10.8f} {1:10.8f}".format(sp.k_combined[0], sp.k_combined[1])
# write results to file
with open('results_test.dat','w') as fh:
fh.write(outstr)

View file

@ -0,0 +1,2 @@
k-combined:
0.30078030 0.00343315

View file

@ -2,6 +2,7 @@
import os
from subprocess import Popen, STDOUT, PIPE
import filecmp
pwd = os.path.dirname(__file__)
@ -18,6 +19,10 @@ def test_run():
def test_created_statepoint():
assert os.path.exists(pwd + '/statepoint.10.binary')
def test_results():
os.system('python results.py')
assert filecmp.cmp('results_test.dat', 'results_true.dat')
def teardown():
output = [pwd + '/statepoint.10.binary']
for f in output:

31
tests/update_results.py Normal file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env python
import os
import sys
from subprocess import Popen, STDOUT, PIPE
# Loop around directories
for root, dirs, files in os.walk('.'):
# Don't continue if not prefixed by test
if root[2:6] != 'test':
continue
# Go into that directory
os.chdir(root)
pwd = os.path.abspath(os.path.dirname('settings.xml'))
os.putenv('PWD', pwd)
# Run openmc
proc = Popen(['../../src/openmc'])
returncode = proc.wait()
# Process results
os.system('python results.py')
os.system('mv results_test.dat results_true.dat')
os.system('rm *.binary')
# Go back a directory
os.chdir('..')
exit()