mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
added new results test for basic test
This commit is contained in:
parent
e178c7b16d
commit
5d00dfa638
4 changed files with 60 additions and 0 deletions
22
tests/test_basic/results.py
Normal file
22
tests/test_basic/results.py
Normal 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)
|
||||
2
tests/test_basic/results_true.dat
Normal file
2
tests/test_basic/results_true.dat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
k-combined:
|
||||
0.30078030 0.00343315
|
||||
|
|
@ -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
31
tests/update_results.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue