diff --git a/tests/regression_tests/plot_overlaps/__init__.py b/tests/regression_tests/plot_overlaps/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regression_tests/plot_overlaps/geometry.xml b/tests/regression_tests/plot_overlaps/geometry.xml new file mode 100644 index 0000000000..7a9f1fb41f --- /dev/null +++ b/tests/regression_tests/plot_overlaps/geometry.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/regression_tests/plot_overlaps/materials.xml b/tests/regression_tests/plot_overlaps/materials.xml new file mode 100644 index 0000000000..90b3542675 --- /dev/null +++ b/tests/regression_tests/plot_overlaps/materials.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/regression_tests/plot_overlaps/plots.xml b/tests/regression_tests/plot_overlaps/plots.xml new file mode 100644 index 0000000000..28064f58fb --- /dev/null +++ b/tests/regression_tests/plot_overlaps/plots.xml @@ -0,0 +1,35 @@ + + + + + 0. 0. 0. + 25 25 + 200 200 + + + true + + + + 0. 0. 0. + 25 25 + 200 200 + + true + 255 211 0 + + + + 0. 0. 0. + 25 25 + 200 200 + 0 0 0 + + + + 100 100 10 + 0. 0. 0. + 20 20 10 + + + diff --git a/tests/regression_tests/plot_overlaps/results_true.dat b/tests/regression_tests/plot_overlaps/results_true.dat new file mode 100644 index 0000000000..1e34f0ecbc --- /dev/null +++ b/tests/regression_tests/plot_overlaps/results_true.dat @@ -0,0 +1 @@ +1f962e0dfd63fc540c39faaf16eeb4a725b16c1a82e89972524716ff763d2d9e12f5ae9f50fafd86caeeb0bab54f8501e104ced085378e98cb9d014a357c7544 \ No newline at end of file diff --git a/tests/regression_tests/plot_overlaps/settings.xml b/tests/regression_tests/plot_overlaps/settings.xml new file mode 100644 index 0000000000..adf256d2d4 --- /dev/null +++ b/tests/regression_tests/plot_overlaps/settings.xml @@ -0,0 +1,13 @@ + + + + plot + + + 5 4 3 + -10 -10 -10 + 10 10 10 + + 1 + + diff --git a/tests/regression_tests/plot_overlaps/test.py b/tests/regression_tests/plot_overlaps/test.py new file mode 100644 index 0000000000..4e5b6caa42 --- /dev/null +++ b/tests/regression_tests/plot_overlaps/test.py @@ -0,0 +1,63 @@ +import glob +import hashlib +import os + +import h5py +import openmc + +from tests.testing_harness import TestHarness +from tests.regression_tests import config + + +class PlotTestHarness(TestHarness): + """Specialized TestHarness for running OpenMC plotting tests.""" + def __init__(self, plot_names): + super().__init__(None) + self._plot_names = plot_names + + def _run_openmc(self): + openmc.plot_geometry(openmc_exec=config['exe']) + + + + def _test_output_created(self): + """Make sure *.ppm has been created.""" + for fname in self._plot_names: + assert os.path.exists(fname), 'Plot output file does not exist.' + + def _cleanup(self): + super()._cleanup() + for fname in self._plot_names: + if os.path.exists(fname): + os.remove(fname) + + def _get_results(self): + """Return a string hash of the plot files.""" + outstr = bytes() + + for fname in self._plot_names: + if fname.endswith('.ppm'): + # Add PPM output to results + with open(fname, 'rb') as fh: + outstr += fh.read() + elif fname.endswith('.h5'): + # Add voxel data to results + with h5py.File(fname, 'r') as fh: + outstr += fh.attrs['filetype'] + outstr += fh.attrs['num_voxels'].tostring() + outstr += fh.attrs['lower_left'].tostring() + outstr += fh.attrs['voxel_width'].tostring() + outstr += fh['data'].value.tostring() + + # Hash the information and return. + sha512 = hashlib.sha512() + sha512.update(outstr) + outstr = sha512.hexdigest() + + return outstr + + +def test_plot(): + harness = PlotTestHarness(('plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm', + 'plot_4.h5')) + harness.main()