tests/papyrus: convert to new stand-alone test process (#38627)
This commit is contained in:
		| @@ -40,68 +40,83 @@ def setup_run_environment(self, env): | |||||||
|     def cache_test_sources(self): |     def cache_test_sources(self): | ||||||
|         """Copy the example source files after the package is installed to an |         """Copy the example source files after the package is installed to an | ||||||
|         install test subdirectory for use during `spack test run`.""" |         install test subdirectory for use during `spack test run`.""" | ||||||
|         self.cache_extra_test_sources([join_path("kv", "tests")]) |         self.cache_extra_test_sources(join_path("kv", "tests")) | ||||||
| 
 | 
 | ||||||
|     def run_example_tests(self): |     @property | ||||||
|         """Run all c & c++ stand alone test""" |     def _lib_dir(self): | ||||||
|  |         """Path to the installed library root.""" | ||||||
|  |         return self.prefix.lib64 if os.path.isdir(self.prefix.lib64) else self.prefix.lib | ||||||
| 
 | 
 | ||||||
|         example_dir = join_path(self.test_suite.current_test_cache_dir, "kv", "tests") |     def _build_and_run_kv_test(self, test): | ||||||
|  |         """build and run a kv/tests test""" | ||||||
| 
 | 
 | ||||||
|         if not os.path.exists(example_dir): |         test_dir = join_path(self.test_suite.current_test_cache_dir.kv.tests, test) | ||||||
|             print("Skipping all test") |         if not os.path.exists(test_dir): | ||||||
|             return |             raise SkipTest(f"Example directory ({test_dir}) is missing") | ||||||
| 
 | 
 | ||||||
|         if os.path.isdir(self.prefix.lib64): |         with working_dir(test_dir): | ||||||
|             lib_dir = self.prefix.lib64 |             options = [ | ||||||
|         else: |                 f"test{test}.c", | ||||||
|             lib_dir = self.prefix.lib |                 f"-I{self.prefix.include}", | ||||||
|  |                 f"-L{self._lib_dir}", | ||||||
|  |                 "-lpapyruskv", | ||||||
|  |                 "-g", | ||||||
|  |                 "-o", | ||||||
|  |                 test, | ||||||
|  |                 "-lpthread", | ||||||
|  |                 "-lm", | ||||||
|  |             ] | ||||||
| 
 | 
 | ||||||
|         example_list = [ |             mpicxx = which(self.spec["mpi"].mpicxx) | ||||||
|             "01_open_close", |             mpicxx(*options) | ||||||
|             "02_put_get", |  | ||||||
|             "03_barrier", |  | ||||||
|             "04_delete", |  | ||||||
|             "05_fence", |  | ||||||
|             "06_signal", |  | ||||||
|             "07_consistency", |  | ||||||
|             "08_protect", |  | ||||||
|             "09_cache", |  | ||||||
|             "10_checkpoint", |  | ||||||
|             "11_restart", |  | ||||||
|             "12_free", |  | ||||||
|         ] |  | ||||||
| 
 | 
 | ||||||
|         for example in example_list: |             mpirun = which(self.spec["mpi"].prefix.bin.mpirun) | ||||||
|             test_dir = join_path(self.test_suite.current_test_cache_dir, "kv", "tests", example) |             mpirun("-np", "4", test) | ||||||
|             test_example = "test{0}.c".format(example) |  | ||||||
| 
 | 
 | ||||||
|             if not os.path.exists(test_dir): |     def test_01_open_close(self): | ||||||
|                 print("Skipping {0} test".format(example)) |         """build and run test01_open_close""" | ||||||
|                 continue |         self._build_and_run_kv_test("01_open_close") | ||||||
| 
 | 
 | ||||||
|             self.run_test( |     def test_02_put_get(self): | ||||||
|                 self.spec["mpi"].mpicxx, |         """build and run test02_put_get""" | ||||||
|                 options=[ |         self._build_and_run_kv_test("02_put_get") | ||||||
|                     "{0}".format(join_path(test_dir, test_example)), |  | ||||||
|                     "-I{0}".format(join_path(self.prefix, "include")), |  | ||||||
|                     "-L{0}".format(lib_dir), |  | ||||||
|                     "-lpapyruskv", |  | ||||||
|                     "-g", |  | ||||||
|                     "-o", |  | ||||||
|                     example, |  | ||||||
|                     "-lpthread", |  | ||||||
|                     "-lm", |  | ||||||
|                 ], |  | ||||||
|                 purpose="test: compile {0} example".format(example), |  | ||||||
|                 work_dir=test_dir, |  | ||||||
|             ) |  | ||||||
| 
 | 
 | ||||||
|             self.run_test( |     def test_03_barrier(self): | ||||||
|                 self.spec["mpi"].prefix.bin.mpirun, |         """build and run test03_barrier""" | ||||||
|                 options=["-np", "4", example], |         self._build_and_run_kv_test("03_barrier") | ||||||
|                 purpose="test: run {0} example".format(example), |  | ||||||
|                 work_dir=test_dir, |  | ||||||
|             ) |  | ||||||
| 
 | 
 | ||||||
|     # def test(self): |     def test_04_delete(self): | ||||||
|     #     self.run_example_tests() |         """build and run test 04_delete""" | ||||||
|  |         self._build_and_run_kv_test("04_delete") | ||||||
|  | 
 | ||||||
|  |     def test_05_fence(self): | ||||||
|  |         """build and run test05_fence""" | ||||||
|  |         self._build_and_run_kv_test("05_fence") | ||||||
|  | 
 | ||||||
|  |     def test_06_signal(self): | ||||||
|  |         """build and run test06_signal""" | ||||||
|  |         self._build_and_run_kv_test("06_signal") | ||||||
|  | 
 | ||||||
|  |     def test_07_consistency(self): | ||||||
|  |         """build and run test07_consistency""" | ||||||
|  |         self._build_and_run_kv_test("07_consistency") | ||||||
|  | 
 | ||||||
|  |     def test_08_protect(self): | ||||||
|  |         """build and run test08_protect""" | ||||||
|  |         self._build_and_run_kv_test("08_protect") | ||||||
|  | 
 | ||||||
|  |     def test_09_cache(self): | ||||||
|  |         """build and run test09_cache""" | ||||||
|  |         self._build_and_run_kv_test("09_cache") | ||||||
|  | 
 | ||||||
|  |     def test_10_checkpoint(self): | ||||||
|  |         """build and run test10_checkpoint""" | ||||||
|  |         self._build_and_run_kv_test("10_checkpoint") | ||||||
|  | 
 | ||||||
|  |     def test_11_restart(self): | ||||||
|  |         """build and run test11_restart""" | ||||||
|  |         self._build_and_run_kv_test("11_restart") | ||||||
|  | 
 | ||||||
|  |     def test_12_free(self): | ||||||
|  |         """build and run test12_free""" | ||||||
|  |         self._build_and_run_kv_test("12_free") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tamara Dahlgren
					Tamara Dahlgren