[cig-commits] r14523 - in short/3D/PyLith/branches/pylith-swig: . pylith pylith/apps pylith/utils tests tests/petsc
brad at geodynamics.org
brad at geodynamics.org
Sat Mar 28 15:37:01 PDT 2009
Author: brad
Date: 2009-03-28 15:37:01 -0700 (Sat, 28 Mar 2009)
New Revision: 14523
Added:
short/3D/PyLith/branches/pylith-swig/tests/petsc/
short/3D/PyLith/branches/pylith-swig/tests/petsc/Makefile.am
short/3D/PyLith/branches/pylith-swig/tests/petsc/README
short/3D/PyLith/branches/pylith-swig/tests/petsc/TestPetscApp.py
short/3D/PyLith/branches/pylith-swig/tests/petsc/testpetsc.py
Modified:
short/3D/PyLith/branches/pylith-swig/configure.ac
short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py
short/3D/PyLith/branches/pylith-swig/pylith/apps/__init__.py
short/3D/PyLith/branches/pylith-swig/pylith/utils/__init__.py
short/3D/PyLith/branches/pylith-swig/tests/Makefile.am
Log:
Added tests of PetscApplication and PetscComponent.
Modified: short/3D/PyLith/branches/pylith-swig/configure.ac
===================================================================
--- short/3D/PyLith/branches/pylith-swig/configure.ac 2009-03-28 21:35:57 UTC (rev 14522)
+++ short/3D/PyLith/branches/pylith-swig/configure.ac 2009-03-28 22:37:01 UTC (rev 14523)
@@ -264,6 +264,7 @@
unittests/pytests/topology/data/Makefile
unittests/pytests/utils/Makefile
tests/Makefile
+ tests/petsc/Makefile
tests/1d/Makefile
tests/1d/line2/Makefile
tests/2d/Makefile
Modified: short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am 2009-03-28 21:35:57 UTC (rev 14522)
+++ short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am 2009-03-28 22:37:01 UTC (rev 14523)
@@ -14,6 +14,7 @@
__init__.py \
apps/__init__.py \
apps/PyLithApp.py \
+ apps/PetscApplication.py \
bc/__init__.py \
bc/AbsorbingDampers.py \
bc/BoundaryCondition.py \
@@ -106,6 +107,7 @@
utils/CppData.py \
utils/EmptyBin.py \
utils/EventLogger.py \
+ utils/PetscComponent.py \
utils/PetscManager.py \
utils/VTKDataReader.py \
utils/importing.py \
Modified: short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py 2009-03-28 21:35:57 UTC (rev 14522)
+++ short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py 2009-03-28 22:37:01 UTC (rev 14523)
@@ -55,7 +55,7 @@
self.petsc.initialize()
self.main(*args, **kwds)
self.cleanup()
- self.petc.finalize()
+ self.petsc.finalize()
return
@@ -63,6 +63,7 @@
"""
Deallocate data structures.
"""
+ from pylith.utils.PetscComponent import PetscComponent
for component in self.components():
if isinstance(component, PetscComponent):
component.cleanup()
Modified: short/3D/PyLith/branches/pylith-swig/pylith/apps/__init__.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/apps/__init__.py 2009-03-28 21:35:57 UTC (rev 14522)
+++ short/3D/PyLith/branches/pylith-swig/pylith/apps/__init__.py 2009-03-28 22:37:01 UTC (rev 14523)
@@ -15,6 +15,7 @@
## @brief Python PyLith apps module initialization.
__all__ = ['PyLithApp',
+ 'PetscApplication',
]
Modified: short/3D/PyLith/branches/pylith-swig/pylith/utils/__init__.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/utils/__init__.py 2009-03-28 21:35:57 UTC (rev 14522)
+++ short/3D/PyLith/branches/pylith-swig/pylith/utils/__init__.py 2009-03-28 22:37:01 UTC (rev 14523)
@@ -12,6 +12,7 @@
__all__ = ['CheckpointTimer',
'CppData',
+ 'PetscComponent',
'PetscManager',
'testarray',
'importing']
Modified: short/3D/PyLith/branches/pylith-swig/tests/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/tests/Makefile.am 2009-03-28 21:35:57 UTC (rev 14522)
+++ short/3D/PyLith/branches/pylith-swig/tests/Makefile.am 2009-03-28 22:37:01 UTC (rev 14523)
@@ -11,6 +11,7 @@
#
SUBDIRS = \
+ petsc \
1d \
2d \
3d
Added: short/3D/PyLith/branches/pylith-swig/tests/petsc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/tests/petsc/Makefile.am (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/tests/petsc/Makefile.am 2009-03-28 22:37:01 UTC (rev 14523)
@@ -0,0 +1,40 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+TESTS = testpetsc.py
+
+check_SCRIPTS = testpetsc.py
+
+noinst_PYTHON = \
+ TestPetscApp.py
+
+noinst_DATA =
+
+noinst_TMP =
+
+TESTS_ENVIRONMENT = $(PYTHON)
+
+
+# 'export' the input files by performing a mock install
+export_datadir = $(top_builddir)/tests/petsc
+export-data: $(noinst_PYTHON) $(noinst_DATA)
+ for f in $(noinst_PYTHON) $(noinst_DATA); do $(install_sh_DATA) $(srcdir)/$$f $(export_datadir); done
+
+BUILT_SOURCES = export-data
+
+CLEANFILES = \
+ $(export_datadir)/$(noinst_PYTHON) \
+ $(export_datadir)/$(noinst_DATA) \
+ $(export_datadir)/$(noinst_TMP)
+
+
+# End of file
Added: short/3D/PyLith/branches/pylith-swig/tests/petsc/README
===================================================================
--- short/3D/PyLith/branches/pylith-swig/tests/petsc/README (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/tests/petsc/README 2009-03-28 22:37:01 UTC (rev 14523)
@@ -0,0 +1,3 @@
+Test PetscApplication and PetscComponent, which provides
+initialization and finalization of PETSc as well as cleanup() for
+deallocating PETSc and other data structures.
Added: short/3D/PyLith/branches/pylith-swig/tests/petsc/TestPetscApp.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/tests/petsc/TestPetscApp.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/tests/petsc/TestPetscApp.py 2009-03-28 22:37:01 UTC (rev 14523)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests/petsc/TestPetscApp.py
+##
+## @brief Test PetscApplication and PetscComponent.
+
+import unittest
+
+# Component with value.
+from pylith.utils.PetscComponent import PetscComponent
+class FooBar(PetscComponent):
+ class Inventory(PetscComponent.Inventory):
+ import pyre.inventory
+ value = pyre.inventory.int("value", default=0)
+ def __init__(self, name="foobar", facility="foo"):
+ PetscComponent.__init__(self, name, facility)
+ return
+ def _configure(self):
+ PetscComponent._configure(self)
+ self.value = self.inventory.value
+ return
+ def _cleanup(self):
+ self.value = -1 # Change value to verify cleanup
+ return
+
+
+# Local version of PetscApplicatiion
+from pylith.apps.PetscApplication import PetscApplication
+class TestApp(PetscApplication):
+ """
+ PetscApplication with one facility, 'foo'.
+ """
+ class Inventory(PetscApplication.Inventory):
+ import pyre.inventory
+ foo = pyre.inventory.facility("foo", factory=FooBar)
+ def __init__(self):
+ PetscApplication.__init__(self, name="testapp")
+ return
+ def main(self, *args, **kwds):
+ self.label = "main" # Set label to some value
+ return
+ def _configure(self):
+ PetscApplication._configure(self)
+ self.foo = self.inventory.foo
+ return
+ def _cleanup(self):
+ self.label = "_cleanup" # Verify cleanup by changing value
+ return
+ def onComputeNodes(self, *args, **kwds):
+ PetscApplication.onComputeNodes(self, args, kwds)
+ assert(-1 == self.foo.value)
+ assert("_cleanup" == self.label)
+ return
+
+
+class TestPetscApp(unittest.TestCase):
+ """
+ Test of PetscApplication.
+ """
+
+ def test_run(self):
+ """
+ Test running application.
+ """
+ app = TestApp()
+ app.run()
+
+ return
+
+
+# End of file
Added: short/3D/PyLith/branches/pylith-swig/tests/petsc/testpetsc.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/tests/petsc/testpetsc.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/tests/petsc/testpetsc.py 2009-03-28 22:37:01 UTC (rev 14523)
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+__requires__ = "PyLith"
+
+import unittest
+
+def suite():
+ """
+ Create test suite.
+ """
+ suite = unittest.TestSuite()
+
+ from TestPetscApp import TestPetscApp
+ suite.addTest(unittest.makeSuite(TestPetscApp))
+
+ return suite
+
+
+def main():
+ """
+ Run test suite.
+ """
+ unittest.TextTestRunner(verbosity=2).run(suite())
+ return
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ main()
+
+
+# End of file
Property changes on: short/3D/PyLith/branches/pylith-swig/tests/petsc/testpetsc.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the CIG-COMMITS
mailing list