libMesh
Functions | Variables
driver.C File Reference

Go to the source code of this file.

Functions

int add_matching_tests_to_runner (CppUnit::Test *test, const std::string &allow_r_str, const std::regex &allow_r, const std::string &deny_r_str, const std::regex &deny_r, CppUnit::TextUi::TestRunner &runner, CppUnit::TestSuite &rejects)
 
int main (int argc, char **argv)
 

Variables

libMesh::Parallel::CommunicatorTestCommWorld
 
libMesh::PerfLogunitlog
 

Function Documentation

◆ add_matching_tests_to_runner()

int add_matching_tests_to_runner ( CppUnit::Test *  test,
const std::string &  allow_r_str,
const std::regex &  allow_r,
const std::string &  deny_r_str,
const std::regex &  deny_r,
CppUnit::TextUi::TestRunner &  runner,
CppUnit::TestSuite &  rejects 
)

Definition at line 21 of file driver.C.

References libMesh::out.

Referenced by main().

28 {
29  int n_tests_added = 0;
30 
31  // If running all tests, just add the "All Tests" test and return
32  if (test->getName() == "All Tests" && allow_r_str == "All Tests" &&
33  deny_r_str == "^$")
34  {
35  libMesh::out << test->getName() << std::endl;
36  runner.addTest(test);
37  return -12345;
38  }
39 
40  if (test->getChildTestCount() == 0)
41  {
42  // Add the test to the runner
43  if ((allow_r_str == "All Tests" ||
44  std::regex_search(test->getName(), allow_r)) &&
45  !std::regex_search(test->getName(), deny_r))
46  {
47  libMesh::out << test->getName() << std::endl;
48  n_tests_added ++;
49  runner.addTest(test);
50  }
51  // Add the test to the rejects it can be cleaned up later
52  else
53  rejects.addTest(test);
54  }
55 
56  // Call this recursively on each of our children, if any.
57  for (int i = 0; i < test->getChildTestCount(); i++)
58  n_tests_added +=
59  add_matching_tests_to_runner(test->getChildTestAt(i), allow_r_str, allow_r,
60  deny_r_str, deny_r, runner, rejects);
61 
62  return n_tests_added;
63 }
int add_matching_tests_to_runner(CppUnit::Test *test, const std::string &allow_r_str, const std::regex &allow_r, const std::string &deny_r_str, const std::regex &deny_r, CppUnit::TextUi::TestRunner &runner, CppUnit::TestSuite &rejects)
Definition: driver.C:21
OStreamProxy out

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file driver.C.

References add_matching_tests_to_runner(), libMesh::PerfLog::clear(), libMesh::command_line_next(), libMesh::PerfLog::enable_summarized_logs(), libMesh::TriangleWrapper::init(), libMesh::on_command_line(), libMesh::out, TestCommWorld, and unitlog.

69 {
70  // Initialize the library. This is necessary because the library
71  // may depend on a number of other libraries (i.e. MPI and Petsc)
72  // that require initialization before use.
73  libMesh::LibMeshInit init(argc, argv);
74  TestCommWorld = &init.comm();
75 
76  // See how long each of our tests are taking to run. This should be
77  // coarse-grained enough to enable even if we're not performance
78  // logging inside the library itself. We need to do this early, so
79  // we can query unitlog when first initializing tests.
80  libMesh::PerfLog driver_unitlog ("Unit Tests");
81  unitlog = &driver_unitlog;
82 
83  // Print just logs summarized by test suite, not every test
84  // individually
85  if (!libMesh::on_command_line("--full-logs"))
86  driver_unitlog.enable_summarized_logs();
87 
88  // We can now run all tests that match a regular expression, for
89  // example, "--re PartitionerTest" will match all the Partitioner
90  // unit tests. If the user does not specify a regex, we run all the
91  // tests returned by makeTest().
92 
93  // An example regex_string that would _exactly_ match a _single_ test is:
94  // "PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartition2"
95  // On the other hand, the regex "HilbertSFC" would match all of the
96  // following tests:
97  //
98  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh
99  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartitionEmpty
100  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartition1
101  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartition2
102  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartitionNProc
103  //
104  // If the user does not provide a a regex, the default re is "All Tests",
105  // which runs all the unit tests.
106 
107  // We can also skip tests that match a regular expression, with e.g.
108  // "--deny_re PartitionerTest" to skip all the Partitioner unit
109  // tests (even if a "--re" option would have included them.)
110 
111  // Read command line argument specifying the allowlist regular expression.
112  std::string allow_regex_string = "All Tests";
113  allow_regex_string = libMesh::command_line_next("--re", allow_regex_string);
114 
115  // Read command line argument specifying the allowlist regular expression.
116  std::string deny_regex_string = "^$";
117  deny_regex_string = libMesh::command_line_next("--deny_re", deny_regex_string);
118 
119  // Recursively add tests matching the regex to the runner object.
120  CppUnit::TextUi::TestRunner runner;
121 
122  // The Cppunit registry object that knows about all the tests.
123  CppUnit::TestFactoryRegistry & registry = CppUnit::TestFactoryRegistry::getRegistry();
124 
125  // A test suite container for holding tests not matching the regex. When main's
126  // scope ends, this class's destructor will delete the rejected tests
127  CppUnit::TestSuite rejects("rejects");
128 
129 #ifdef LIBMESH_HAVE_CXX11_REGEX
130  // Make regex objects from user's input.
131  const std::regex allow_regex(allow_regex_string);
132  const std::regex deny_regex(deny_regex_string);
133 
134  // Add all tests which match the re to the runner object.
135  libMesh::out << "Will run the following tests:" << std::endl;
136  const int n_tests_added =
137  add_matching_tests_to_runner(registry.makeTest(),
138  allow_regex_string, allow_regex,
139  deny_regex_string, deny_regex,
140  runner, rejects);
141  if (n_tests_added >= 0)
142  libMesh::out << "--- Running " << n_tests_added << " tests in total." << std::endl;
143 #else
144  // If no C++11 <regex> just run all the tests.
145  runner.addTest(registry.makeTest());
146 #endif
147 
148  std::unique_ptr<CppUnit::TestResult> controller;
149  std::unique_ptr<CppUnit::BriefTestProgressListener> listener;
150 
151  // Actually run all the requested tests, possibly with verbose
152  // output of test names as they are run
153  if (libMesh::on_command_line("--verbose"))
154  {
155  listener = std::make_unique<CppUnit::BriefTestProgressListener>();
156  runner.eventManager().addListener(listener.get());
157  }
158 
159  bool succeeded = runner.run();
160 
161  // Many users won't care at all about the PerfLog
162 #ifndef LIBMESH_ENABLE_PERFORMANCE_LOGGING
163  if (!libMesh::on_command_line("--full-logs"))
164  driver_unitlog.clear();
165 #endif
166 
167  // 1 for failure, 0 for success
168  return !succeeded;
169 }
T command_line_next(std::string name, T default_value)
Use GetPot&#39;s search()/next() functions to get following arguments from the command line...
Definition: libmesh.C:1078
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
int add_matching_tests_to_runner(CppUnit::Test *test, const std::string &allow_r_str, const std::regex &allow_r, const std::string &deny_r_str, const std::regex &deny_r, CppUnit::TextUi::TestRunner &runner, CppUnit::TestSuite &rejects)
Definition: driver.C:21
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:90
The PerfLog class allows monitoring of specific events.
Definition: perf_log.h:145
void enable_summarized_logs()
Tells the PerfLog to only print log results summarized by header.
Definition: perf_log.h:191
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
libMesh::PerfLog * unitlog
Definition: driver.C:173
OStreamProxy out
bool on_command_line(std::string arg)
Definition: libmesh.C:987

Variable Documentation

◆ TestCommWorld

Definition at line 171 of file driver.C.

Referenced by AllSecondOrderTest::allCompleteOrder(), AllSecondOrderTest::allCompleteOrderDoNothing(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderMixedFixing(), AllSecondOrderTest::allCompleteOrderMixedFixing3D(), AllSecondOrderTest::allCompleteOrderRange(), AllSecondOrderTest::allSecondOrder(), AllSecondOrderTest::allSecondOrderDoNothing(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderMixedFixing(), AllSecondOrderTest::allSecondOrderMixedFixing3D(), AllSecondOrderTest::allSecondOrderRange(), GetBoundaryPointsTest::build_mesh(), ExtraIntegersTest::checkpoint_helper(), CopyNodesAndElementsTest::collectMeshes(), NodalNeighborsTest::do_test(), ParallelSyncTest::fill_scalar_data(), ParallelSyncTest::fill_vector_data(), MeshInputTest::helperTestingDynaQuad(), main(), TimeSolverTestImplementation< NewmarkSolver >::run_test_with_exact_soln(), ParsedFEMFunctionTest::setUp(), LumpedMassMatrixTest::setUp(), SparseMatrixTest< LaspackMatrix< Number > >::setUp(), DiagonalMatrixTest::setUp(), NumericVectorTest< DistributedVector< Number > >::setUp(), MultiEvaluablePredTest::test(), SystemsTest::test100KVariables(), MeshSpatialDimensionTest::test1D(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshSpatialDimensionTest::test2D(), SystemsTest::test2DProjectVectorFE(), SystemsTest::test3DProjectVectorFE(), SimplexRefinementTest::test3DTriRefinement(), ExtraIntegersTest::test_helper(), DistortTest::test_helper_2D(), AllTriTest::test_helper_2D(), DistortTest::test_helper_3D(), AllTriTest::test_helper_3D(), ElemTest< elem_type >::test_n_refinements(), MeshFunctionTest::test_p_level(), ExodusTest< elem_type >::test_read_gold(), XdrTest::test_read_write(), MeshFunctionTest::test_subdomain_id_sets(), VolumeTest::test_true_centroid_and_volume(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), EquationSystemsTest::testAddSystem(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), ParallelTest::testAllGather(), ParallelTest::testAllGatherEmptyVectorString(), ParallelTest::testAllGatherHalfEmptyVectorString(), ParallelPointTest::testAllGatherPairPointPoint(), ParallelPointTest::testAllGatherPairRealPoint(), ParallelPointTest::testAllGatherPoint(), ParallelTest::testAllGatherString(), ParallelTest::testAllGatherVectorString(), MeshStitchTest::testAmbiguousRemappingStitch(), SystemsTest::testAssemblyWithDgFemContext(), DofMapTest::testBadElemFECombo(), ExtraIntegersTest::testBadExtraIntegersExodusReading(), MeshInputTest::testBadGmsh(), EquationSystemsTest::testBadVarNames(), ParallelTest::testBarrier(), SystemsTest::testBlockRestrictedVarNDofs(), MeshStitchTest::testBoundaryInfo(), SystemsTest::testBoundaryProjectCube(), ParallelTest::testBroadcast(), ParallelTest::testBroadcastNestedType(), ParallelPointTest::testBroadcastPoint(), ParallelPointTest::testBroadcastVectorValue(), MeshGenerationTest::testBuildSphere(), ParallelGhostSyncTest::testByXYZ(), VolumeTest::testC0Polygon(), VolumeTest::testC0Polyhedron(), VolumeTest::testC0PolyhedronCube(), DofMapTest::testConstraintLoopDetection(), EquationSystemsTest::testConstruction(), PackedRangeTest::testContainerSendReceive(), MeshAssignTest::testCopyConstruct(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshDeletionsTest::testDeleteElemDistributed(), MeshDeletionsTest::testDeleteElemReplicated(), EquationSystemsTest::testDisableDefaultGhosting(), MeshBaseTest::testDistributedMeshVerifyIsPrepared(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaFileMappings(), PackingTypesTest::testDynamicEigenMatrix(), PackingTypesTest::testDynamicEigenVector(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), ConnectedComponentsTest::testEdge(), VolumeTest::testEdge3Volume(), BoundaryInfoTest::testEdgeBoundaryConditions(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusReadHeader(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), ExtraIntegersTest::testExtraIntegersExodusReading(), MeshExtruderTest::testExtruder(), MixedOrderTest::testFindNeighbors(), ParallelTest::testGather(), ParallelTest::testGatherString(), MessageTagTest::testGetUniqueTagAuto(), MessageTagTest::testGetUniqueTagManual(), MeshInputTest::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), ParsedFEMFunctionTest::testGradients(), ParsedFEMFunctionTest::testHessians(), VolumeTest::testHex20PLevelTrueCentroid(), ParallelTest::testInfinityMax(), ParallelTest::testInfinityMin(), InfFERadialTest::testInfQuants(), InfFERadialTest::testInfQuants_numericDeriv(), EquationSystemsTest::testInit(), ParsedFEMFunctionTest::testInlineGetter(), ParsedFEMFunctionTest::testInlineSetter(), ParallelPointTest::testIrecvSend(), ParallelTest::testIrecvSend(), ParallelPointTest::testIsendRecv(), ParallelTest::testIsendRecv(), MeshSmootherTest::testLaplaceQuad(), MeshSmootherTest::testLaplaceTri(), PointLocatorTest::testLocator(), MeshInputTest::testLowOrderEdgeBlocks(), MappedSubdomainPartitionerTest::testMappedSubdomainPartitioner(), ParallelPointTest::testMapUnionVec(), ParallelTest::testMax(), ParallelTest::testMaxloc(), ParallelTest::testMaxlocReal(), BoundaryInfoTest::testMesh(), MeshStitchTest::testMeshStitch(), MeshBaseTest::testMeshVerifyIsPrepared(), ParallelTest::testMin(), ParallelTest::testMinloc(), ParallelTest::testMinlocReal(), BoundaryInfoTest::testNameCopying(), MeshInputTest::testNemesisReadImpl(), MeshTetTest::testNetGen(), MeshTetTest::testNetGenError(), MeshTetTest::testNetGenFlippedTris(), MeshTetTest::testNetGenHole(), MeshTetTest::testNetGenSphereShell(), MeshTetTest::testNetGenTets(), PackingTypesTest::testNonFixedScalar(), ParsedFEMFunctionTest::testNormals(), PackedRangeTest::testNullAllGather(), PackedRangeTest::testNullSendReceive(), NodalNeighborsTest::testOrientation(), PartitionerTest< PartitionerSubclass, MeshClass >::testPartition(), PartitionerTest< PartitionerSubclass, MeshClass >::testPartitionEmpty(), PartitionerTest< PartitionerSubclass, MeshClass >::testPartitionNProc(), PeriodicBCTest::testPeriodicBC(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2Tri(), MeshTriangulationTest::testPoly2TriBad1DMultiBoundary(), MeshTriangulationTest::testPoly2TriBad2DMultiBoundary(), MeshTriangulationTest::testPoly2TriBadEdges(), MeshTriangulationTest::testPoly2TriEdge3s(), MeshTriangulationTest::testPoly2TriEdges(), MeshTriangulationTest::testPoly2TriEdgesRefined(), MeshTriangulationTest::testPoly2TriExtraRefined(), MeshTriangulationTest::testPoly2TriHalfDomain(), MeshTriangulationTest::testPoly2TriHalfDomainEdge3(), MeshTriangulationTest::testPoly2TriHoles(), MeshTriangulationTest::testPoly2TriHolesExtraRefined(), MeshTriangulationTest::testPoly2TriHolesInteriorRefinedBase(), MeshTriangulationTest::testPoly2TriHolesInterpRefined(), MeshTriangulationTest::testPoly2TriHolesNonUniformRefined(), MeshTriangulationTest::testPoly2TriHolesRefined(), MeshTriangulationTest::testPoly2TriInterp(), MeshTriangulationTest::testPoly2TriInterp2(), MeshTriangulationTest::testPoly2TriMeshedHoles(), MeshTriangulationTest::testPoly2TriNonRefined(), MeshTriangulationTest::testPoly2TriNonUniformRefined(), MeshTriangulationTest::testPoly2TriRefined(), MeshTriangulationTest::testPoly2TriRoundHole(), MeshTriangulationTest::testPoly2TriSegments(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), SystemsTest::testPostInitAddVector(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectLine(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectSquare(), ParallelSyncTest::testPull(), ParallelSyncTest::testPullImpl(), ParallelSyncTest::testPullVecVec(), ParallelSyncTest::testPullVecVecImpl(), ParallelSyncTest::testPush(), ParallelSyncTest::testPushImpl(), ParallelSyncTest::testPushOversized(), ParallelSyncTest::testPushVecVec(), ParallelSyncTest::testPushVecVecImpl(), ParallelSyncTest::testPushVecVecOversized(), VolumeTest::testQuad4TrueCentroid(), ParallelTest::testRecvIsendSets(), ParallelTest::testRecvIsendVecVecs(), SimplexRefinementTest::testRefinement(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), MeshStitchTest::testRemappingStitch(), DistributedMeshTest::testRemoteElemError(), BoundaryInfoTest::testRenumber(), EquationSystemsTest::testRepartitionThenReinit(), MeshBaseTest::testReplicatedMeshVerifyIsPrepared(), SlitMeshRefinedSystemTest::testRestart(), ParallelTest::testScatter(), EquationSystemsTest::testSelectivePRefine(), ParallelTest::testSemiVerify(), ParallelTest::testSendRecvVecVecs(), SystemsTest::testSetSystemParameterOverEquationSystem(), BoundaryInfoTest::testShellFaceConstraints(), InfFERadialTest::testSides(), MeshInputTest::testSingleElementImpl(), InfFERadialTest::testSingleOrder(), ParallelSortTest::testSort(), ParallelTest::testSplit(), ParallelTest::testSplitByType(), CheckpointIOTest::testSplitter(), MixedOrderTest::testStitch(), MeshTetTest::testTetGen(), MeshTetTest::testTetGenError(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangle(), MeshTriangulationTest::testTriangleEdges(), MeshTriangulationTest::testTriangleHalfDomain(), MeshTriangulationTest::testTriangleHoles(), MeshTriangulationTest::testTriangleInterp(), MeshTriangulationTest::testTriangleInterp2(), MeshTriangulationTest::testTriangleMeshedHoles(), MeshTriangulationTest::testTriangleRoundHole(), MeshTriangulationTest::testTriangleSegments(), SimplexRefinementTest::testTriRefinement(), VolumeTest::testTwistedVolume(), ParsedFEMFunctionTest::testValues(), MeshSmootherTest::testVariationalQuad(), MeshSmootherTest::testVariationalQuadMultipleSubdomains(), MeshSmootherTest::testVariationalTri(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), SparseMatrixTest< LaspackMatrix< Number > >::testWriteAndRead(), WriteVecAndScalar::testWriteExodus(), WriteNodesetData::testWriteImpl(), WriteEdgesetData::testWriteImpl(), WriteSidesetData::testWriteImpl(), WriteElemsetData::testWriteImpl(), WriteVecAndScalar::testWriteNemesis(), SystemsTest::tripleValueTest(), and NumericVectorTest< DistributedVector< Number > >::WriteAndRead().

◆ unitlog

libMesh::PerfLog* unitlog