From 77ad97d2c5d41373a7775c9372040f0cdb5fa031 Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Tue, 26 Jun 2018 12:49:00 +0200 Subject: [PATCH] Do not test global platform. - change the test to use locally allocated object Change-Id: Ie0818a4791d03d8f9004aba312f58fa0746c608b --- unit_tests/platform/platform_negative_tests.cpp | 17 ++--------------- unit_tests/platform/platform_tests.cpp | 9 ++------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/unit_tests/platform/platform_negative_tests.cpp b/unit_tests/platform/platform_negative_tests.cpp index 50fbc49521..5b4fcdb113 100644 --- a/unit_tests/platform/platform_negative_tests.cpp +++ b/unit_tests/platform/platform_negative_tests.cpp @@ -33,26 +33,13 @@ extern bool getDevicesResult; struct PlatformNegativeTest : public ::testing::Test { void SetUp() override { - pPlatform = platform(); + pPlatform.reset(new Platform()); } - Platform *pPlatform = nullptr; + std::unique_ptr pPlatform; }; TEST_F(PlatformNegativeTest, GivenPlatformWhenGetDevicesFailedThenFalseIsReturned) { - class PlatformShutdown { - public: - PlatformShutdown(Platform *pPlatform) : pPlatform(pPlatform) { - pPlatform->shutdown(); - } - ~PlatformShutdown() { - pPlatform->shutdown(); - } - - protected: - Platform *pPlatform = nullptr; - } a(pPlatform); - VariableBackup bkp(&getDevicesResult, false); auto ret = pPlatform->initialize(); diff --git a/unit_tests/platform/platform_tests.cpp b/unit_tests/platform/platform_tests.cpp index ecaa7c5965..57f8fd5af9 100644 --- a/unit_tests/platform/platform_tests.cpp +++ b/unit_tests/platform/platform_tests.cpp @@ -34,14 +34,9 @@ using namespace OCLRT; struct PlatformTest : public ::testing::Test { - PlatformTest() {} - - void SetUp() override { pPlatform = platform(); } - - void TearDown() override {} - + void SetUp() override { pPlatform.reset(new Platform()); } cl_int retVal = CL_SUCCESS; - Platform *pPlatform = nullptr; + std::unique_ptr pPlatform; }; TEST_F(PlatformTest, getDevices) {