@@ -83,7 +83,8 @@ class TestClass
8383 }
8484 else if (GetSharedData ().GetLogger () == NULL )
8585 {
86- // Force logger to be created before memory leak checking starts.
86+ // Force logger to be created before memory leak checking starts,
87+ // so that this does not get recorded in the start/end memory checking.
8788 LogWriteLine (" Unable to create logging!" );
8889 }
8990
@@ -96,11 +97,8 @@ class TestClass
9697 // but after the previous test has the memory leak checking stopped.
9798 StartLeakChecking ();
9899
99- privateIncConstruction ();
100-
101- SetClassName (class_name);
102- SetFunctionName (function_name);
103- SetArgs (args);
100+ privateSetupPostLeakCheckingData (class_name, function_name, args);
101+ privateIncrementCounters ();
104102
105103 // Start the setup part of a fixture, after leak detection starts.
106104 Setup ();
@@ -123,7 +121,7 @@ class TestClass
123121
124122 // Clear the logger to ensure the allocation
125123 // for the first test is freed.
126- privateClearSharedData ();
124+ GetSharedData (). Clear ();
127125
128126 // Any memory leaks will get reported by dumping
129127 // all information supported for the platform,
@@ -340,8 +338,6 @@ class TestClass
340338 {
341339 privateStopLeakChecking ();
342340 privateLogLeaks ();
343- if (IsLast ())
344- m_leak_check.DumpAll ();
345341 }
346342
347343 template <typename T>
@@ -952,26 +948,27 @@ class TestClass
952948 }
953949 }
954950
955- // Every function or member function test calls this construct function,
956- // which sets up the initial logger and keeps track of number of tests.
957- void privateIncConstruction ()
951+ // This data needs to be set after leak checking so that
952+ // dynamic data is not falsely reported as a memory leak.
953+ void privateSetupPostLeakCheckingData (char const * class_name,
954+ char const * function_name,
955+ char const * args)
958956 {
959- if (GetSharedData ().GetLogger () == NULL )
960- LogWriteLine (" Error setting logger!" );
957+ SetClassName (class_name);
958+ SetFunctionName (function_name);
959+ SetArgs (args);
960+ }
961961
962+ // Keep track of constructions,
963+ // totals and current test number for every test.
964+ void privateIncrementCounters ()
965+ {
962966 GetSharedData ().IncConstructions ();
963967 GetSharedData ().IncTotalTests ();
964968
965969 m_test_number = GetSharedData ().GetConstructions ();
966970 }
967971
968- static void privateClearSharedData ()
969- {
970- // Free shared pointers to prevent false positives
971- // for memory leak detection.
972- GetSharedData ().Clear ();
973- }
974-
975972 void privateSetFilename (TestString const & filename)
976973 {
977974 m_filename = filename;
@@ -1051,10 +1048,12 @@ class TestClass
10511048 // The amount of time to run the performance test.
10521049 TestTime m_sample_time;
10531050
1054- // total checks for this function.
1051+ // Total checks for this function.
10551052 ocl_size_type m_check_count;
10561053
1057- // test failures for this function.
1054+ // Test failures for this function.
1055+ // Only record check or timing failures as these have specific tests.
1056+ // Memory leaks do not affect this failure count.
10581057 ocl_size_type m_failure_check_count;
10591058 TestString m_check_failures;
10601059
0 commit comments