summaryrefslogtreecommitdiff
path: root/nn/runtime/test/fuzzing
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2020-03-05 12:45:27 -0800
committerXusong Wang <xusongw@google.com>2020-03-09 13:08:10 -0700
commit6e4afba20cd62dade0dd178b638e406cc3bc13dc (patch)
tree4df4f3a50f78e8d7c7de65ca78a57334be8d1ccf /nn/runtime/test/fuzzing
parent6c1527c1f64d463b2f8fdcc17a9c14dbf6e74fa1 (diff)
downloadml-6e4afba20cd62dade0dd178b638e406cc3bc13dc.tar.gz
Add memory leak detector into RGG tests.
The memory leak detector is enabled when deubg.nn.fuzzer.detectleak system property is set. Bug: 133780504 Test: NNT_static_fuzzing Change-Id: Ib0497e6d916a53a075b96626f6fca1c16dd10291
Diffstat (limited to 'nn/runtime/test/fuzzing')
-rw-r--r--nn/runtime/test/fuzzing/TestRandomGraph.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/nn/runtime/test/fuzzing/TestRandomGraph.cpp b/nn/runtime/test/fuzzing/TestRandomGraph.cpp
index 18e536f13..98fd3a51b 100644
--- a/nn/runtime/test/fuzzing/TestRandomGraph.cpp
+++ b/nn/runtime/test/fuzzing/TestRandomGraph.cpp
@@ -29,7 +29,10 @@
#ifndef NNTEST_CTS
#include <android-base/properties.h>
+#include <memunreachable/memunreachable.h>
+
#include <vector>
+
#include "HalInterfaces.h"
#include "Manager.h"
#include "SampleDriverFull.h"
@@ -138,6 +141,7 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
#ifndef NNTEST_CTS
mEnableLog = ::android::base::GetProperty("debug.nn.fuzzer.log", "") == "1";
mDumpSpec = ::android::base::GetProperty("debug.nn.fuzzer.dumpspec", "") == "1";
+ mDetectMemoryLeak = ::android::base::GetProperty("debug.nn.fuzzer.detectleak", "") == "1";
mStandardDevices = DeviceManager::get()->forTest_getDevices();
mSyntheticDevices.push_back(makeTestDevice<TestDriverV1_2>());
@@ -177,6 +181,11 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
mGraph.dumpSpecFile("/data/local/tmp/" + mTestName + ".mod.py", mTestName);
}
NN_FUZZER_LOG_CLOSE;
+#ifndef NNTEST_CTS
+ if (mDetectMemoryLeak) {
+ ASSERT_TRUE(NoLeaks());
+ }
+#endif
}
bool shouldSkipTest(int64_t featureLevel) {
@@ -343,6 +352,7 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
static bool mEnableLog;
static bool mDumpSpec;
+ static bool mDetectMemoryLeak;
static std::map<std::string, ANeuralNetworksDevice*> mDevices;
const uint32_t kSeed = GetParam();
@@ -359,6 +369,7 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
bool RandomGraphTest::mEnableLog = false;
bool RandomGraphTest::mDumpSpec = false;
+bool RandomGraphTest::mDetectMemoryLeak = false;
std::map<std::string, ANeuralNetworksDevice*> RandomGraphTest::mDevices;
int64_t RandomGraphTest::mStandardDevicesFeatureLevel;