mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
converted new tests to ctest format
This commit is contained in:
parent
433b579004
commit
94535a0fbe
5 changed files with 222 additions and 148 deletions
|
|
@ -3,10 +3,15 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
settings1="""<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
|
@ -45,57 +50,67 @@ settings2 = """<?xml version="1.0"?>
|
|||
</settings>
|
||||
"""
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
|
||||
def test_run1():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
source = glob.glob(pwd + '/source.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
source = glob.glob(cwd + '/source.10.*')
|
||||
assert len(statepoint) == 1, 'Either multple or no source files exist.'
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5'),\
|
||||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
def test_run2():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
source = glob.glob(pwd + '/source.10.*')
|
||||
openmc_path = cwd + '/../../src/openmc'
|
||||
source = glob.glob(cwd + '/source.10.*')
|
||||
with open('settings.xml','w') as fh:
|
||||
fh.write(settings2.format(source[0].split('.')[2]))
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
with open('settings.xml','w') as fh:
|
||||
fh.write(settings1)
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output += glob.glob(pwd + '/source.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(cwd + '/statepoint.10.*')
|
||||
output += glob.glob(cwd + '/source.10.*')
|
||||
output.append(cwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe == None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run1()
|
||||
test_statepoint_exists()
|
||||
test_run2()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.*')
|
||||
assert len(statepoint) == 5
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.*')
|
||||
assert len(statepoint) == 5, '5 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file detected that is not binary or hdf5.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.8.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.8.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do no agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(cwd + '/statepoint.*')
|
||||
output.append(cwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe == None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.*')
|
||||
assert len(statepoint) == 5
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.*')
|
||||
assert len(statepoint) == 5, '5 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file detected that is not binary or hdf5.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.8.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.8.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(cwd + '/statepoint.*')
|
||||
output.append(cwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe == None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
source = glob.glob(pwd + '/source.*')
|
||||
assert len(source) == 1
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint file exists.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
source = glob.glob(cwd + '/source.*')
|
||||
assert len(source) == 1, 'Either multple or no source file exists.'
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5'),\
|
||||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output += glob.glob(pwd + '/source.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(cwd + '/statepoint.10.*')
|
||||
output += glob.glob(cwd + '/source.*')
|
||||
output.append(cwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe == None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,127 +3,146 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.*')
|
||||
assert len(statepoint) == 2
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
assert len(sourcepoint) == 1
|
||||
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.*')
|
||||
assert len(statepoint) == 2, '2 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file must either be binary or hdf5.'
|
||||
sourcepoint = glob.glob(cwd + '/source.7.*')
|
||||
assert len(sourcepoint) == 1, 'Either multiple or no source files found.'
|
||||
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5'),\
|
||||
'Source file must either be binary or hdf5.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
os.remove(statepoint[0])
|
||||
|
||||
def test_restart_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
|
||||
'-r', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(cwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(cwd + '/source.7.*')
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe,
|
||||
'-r', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-r', statepoint[0], sourcepoint[0]], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-r', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart 1 did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1, 'Batch 10 statepoint file does not exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file must be a binary or hdf5 file.'
|
||||
|
||||
def test_results_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Restart 1 results do not agree.'
|
||||
os.remove(statepoint[0])
|
||||
|
||||
def test_restart_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
|
||||
'--restart', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(cwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(cwd + '/source.7.*')
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe,
|
||||
'--restart', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '--restart', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart 2 did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1, 'Batch 10 statepoint file does not exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file not a binary or hdf5 file.'
|
||||
|
||||
def test_results_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Restart 2 results do not agree.'
|
||||
os.remove(statepoint[0])
|
||||
|
||||
def test_restart_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(cwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(cwd + '/source.7.*')
|
||||
proc = Popen([opts.exe, '--restart', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart serial did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1, 'Batch 10 statepoint file does not exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(cwd + '/statepoint.10.*')
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Serial results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output += glob.glob(pwd + '/source.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(cwd + '/statepoint.*')
|
||||
output += glob.glob(cwd + '/source.*')
|
||||
output.append(cwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe == None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
test_restart_form1()
|
||||
test_created_statepoint_form1()
|
||||
test_results_form1()
|
||||
test_restart_form2()
|
||||
test_created_statepoint_form2()
|
||||
test_results_form2()
|
||||
test_restart_serial()
|
||||
test_created_statepoint_serial()
|
||||
test_results_serial()
|
||||
teardown()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue