| 24 | namespace tensorflow { |
| 25 | |
| 26 | TEST(MKLBFCAllocatorTest, TestMaxLimit) { |
| 27 | setenv(MklCPUAllocator::kMaxLimitStr, "1000", 1); |
| 28 | MklCPUAllocator a; |
| 29 | TF_EXPECT_OK(a.Initialize()); |
| 30 | auto stats = a.GetStats(); |
| 31 | EXPECT_EQ(stats->bytes_limit, 1000); |
| 32 | |
| 33 | unsetenv(MklCPUAllocator::kMaxLimitStr); |
| 34 | TF_EXPECT_OK(a.Initialize()); |
| 35 | stats = a.GetStats(); |
| 36 | uint64 max_mem_bytes = MklCPUAllocator::kDefaultMaxLimit; |
| 37 | #if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) |
| 38 | max_mem_bytes = |
| 39 | (uint64)sysconf(_SC_PHYS_PAGES) * (uint64)sysconf(_SC_PAGESIZE); |
| 40 | #endif |
| 41 | EXPECT_EQ(stats->bytes_limit, max_mem_bytes); |
| 42 | |
| 43 | setenv(MklCPUAllocator::kMaxLimitStr, "wrong-input", 1); |
| 44 | EXPECT_TRUE(errors::IsInvalidArgument(a.Initialize())); |
| 45 | |
| 46 | setenv(MklCPUAllocator::kMaxLimitStr, "-20", 1); |
| 47 | EXPECT_TRUE(errors::IsInvalidArgument(a.Initialize())); |
| 48 | } |
| 49 | |
| 50 | } // namespace tensorflow |
| 51 |
nothing calls this directly
no test coverage detected