blob: ae49366c6227fceff0d3cedfeda25b9a957c50f7 [file] [log] [blame]
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00006#include <test/RuntimeTests.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01007
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00008#include <LeakChecking.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01009
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000010#include <backendsCommon/test/RuntimeTestImpl.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010011
12#include <boost/test/unit_test.hpp>
13
14BOOST_AUTO_TEST_SUITE(RefRuntime)
15
16#ifdef ARMNN_LEAK_CHECKING_ENABLED
17BOOST_AUTO_TEST_CASE(RuntimeMemoryLeaksCpuRef)
18{
19 BOOST_TEST(ARMNN_LEAK_CHECKER_IS_ACTIVE());
20
21 armnn::IRuntime::CreationOptions options;
22 armnn::Runtime runtime(options);
23 armnn::RuntimeLoadedNetworksReserve(&runtime);
24
25 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
26 {
27 // Do a warmup of this so we make sure that all one-time
28 // initialization happens before we do the leak checking.
29 CreateAndDropDummyNetwork(backends, runtime);
30 }
31
32 {
33 ARMNN_SCOPED_LEAK_CHECKER("LoadAndUnloadNetworkCpuRef");
34 BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE());
35 // In the second run we check for all remaining memory
36 // in use after the network was unloaded. If there is any
37 // then it will be treated as a memory leak.
38 CreateAndDropDummyNetwork(backends, runtime);
39 BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE());
40 BOOST_TEST(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0);
41 BOOST_TEST(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0);
42 }
43}
44#endif
45
46BOOST_AUTO_TEST_SUITE_END()