2013-02-01 15:22:32 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
import os
|
2013-08-22 12:17:28 -04:00
|
|
|
from subprocess import Popen, STDOUT, PIPE, call
|
2013-08-12 13:17:03 -04:00
|
|
|
import filecmp
|
2013-08-16 17:36:44 -04:00
|
|
|
from nose_mpi import NoseMPI
|
2013-08-21 16:19:54 -04:00
|
|
|
import glob
|
2013-02-01 15:22:32 -05:00
|
|
|
|
|
|
|
|
pwd = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
|
|
def setup():
|
|
|
|
|
os.putenv('PWD', pwd)
|
|
|
|
|
os.chdir(pwd)
|
|
|
|
|
|
|
|
|
|
def test_run():
|
2013-08-16 17:36:44 -04:00
|
|
|
openmc_path = pwd + '/../../src/openmc'
|
|
|
|
|
if int(NoseMPI.mpi_np) > 0:
|
|
|
|
|
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
|
|
|
|
stderr=STDOUT, stdout=PIPE)
|
|
|
|
|
else:
|
|
|
|
|
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
2013-02-01 15:22:32 -05:00
|
|
|
print(proc.communicate()[0])
|
2013-10-16 23:03:40 -04:00
|
|
|
returncode = proc.returncode
|
2013-02-01 15:22:32 -05:00
|
|
|
assert returncode == 0
|
|
|
|
|
|
|
|
|
|
def test_created_statepoint():
|
2013-08-22 12:17:28 -04:00
|
|
|
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
2013-08-21 16:19:54 -04:00
|
|
|
assert len(statepoint) == 1
|
|
|
|
|
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
2013-02-01 15:22:32 -05:00
|
|
|
|
2013-08-12 13:17:03 -04:00
|
|
|
def test_results():
|
2013-08-22 12:17:28 -04:00
|
|
|
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
|
|
|
|
call(['python', 'results.py', statepoint[0]])
|
2013-08-12 14:13:54 -04:00
|
|
|
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
|
|
|
|
if not compare:
|
2013-08-14 20:09:27 -05:00
|
|
|
os.rename('results_test.dat', 'results_error.dat')
|
2013-08-12 14:13:54 -04:00
|
|
|
assert compare
|
2013-08-12 13:17:03 -04:00
|
|
|
|
2013-02-01 15:22:32 -05:00
|
|
|
def teardown():
|
2013-08-22 12:17:28 -04:00
|
|
|
output = glob.glob(pwd + '/statepoint.10.*')
|
|
|
|
|
output.append(pwd + '/results_test.dat')
|
2013-02-01 15:22:32 -05:00
|
|
|
for f in output:
|
|
|
|
|
if os.path.exists(f):
|
|
|
|
|
os.remove(f)
|