summaryrefslogtreecommitdiff
path: root/runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc')
-rw-r--r--runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc b/runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc
index d615cc928..59fdeedc9 100644
--- a/runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc
+++ b/runtime/contrib/heap_trace/tests/src/symbol_searcher_test.cc
@@ -14,23 +14,25 @@
* limitations under the License.
*/
-#include "gtest/gtest.h"
+#include "common_test_environment.h"
+#include "file_content_manipulations.h"
#include "test_sample1.h"
#include "test_sample2.h"
#include "test_sample4.h"
#include "symbol_searcher.h"
+#include "trace.h"
#include <dlfcn.h>
#include <linux/limits.h>
#include <unistd.h>
-#include <cstdlib>
-
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
+extern std::unique_ptr<Trace> GlobalTrace;
+
fs::path exePath()
{
char result[PATH_MAX] = {0};
@@ -41,8 +43,9 @@ fs::path exePath()
namespace backstage
{
-struct SymbolSearcher : public ::testing::Test
+struct SymbolSearcher : TestEnv
{
+ SymbolSearcher() : TestEnv("./symbol_searcher_test.log") {}
};
TEST_F(SymbolSearcher, should_find_symbol_in_linked_library)
@@ -76,4 +79,21 @@ TEST_F(SymbolSearcher,
dlclose(test_sample2_handle);
}
+TEST_F(SymbolSearcher, should_give_an_opportunity_do_not_log_its_internal_allocations)
+{
+ GlobalTrace.reset();
+ fs::path pathToTestLib = exePath() / "libtest_sample2.so";
+ void *handle = dlopen(pathToTestLib.c_str(), RTLD_NOW);
+
+ GlobalTrace.reset(new Trace);
+ void *symbolAddress = findSymbol("funcDefinedOnlyInTestSample2");
+ GlobalTrace.reset();
+
+ ASSERT_STREQ(getContentOfFile("./symbol_searcher_test.log").c_str(),
+ "On CPU - Peak heap usage: 0 B, Total allocated: 0 B, Total deallocated: 0 B\nOn "
+ "GPU - Peak mem usage: 0 B, Total allocated: 0 B, Total deallocated: 0 B\n");
+
+ dlclose(handle);
+}
+
} // namespace backstage