Do not test global platform.

- change the test to use locally allocated object

Change-Id: Ie0818a4791d03d8f9004aba312f58fa0746c608b
This commit is contained in:
Mrozek, Michal
2018-06-26 12:49:00 +02:00
committed by sys_ocldev
parent 8672360766
commit 77ad97d2c5
2 changed files with 4 additions and 22 deletions

View File

@@ -33,26 +33,13 @@ extern bool getDevicesResult;
struct PlatformNegativeTest : public ::testing::Test { struct PlatformNegativeTest : public ::testing::Test {
void SetUp() override { void SetUp() override {
pPlatform = platform(); pPlatform.reset(new Platform());
} }
Platform *pPlatform = nullptr; std::unique_ptr<Platform> pPlatform;
}; };
TEST_F(PlatformNegativeTest, GivenPlatformWhenGetDevicesFailedThenFalseIsReturned) { TEST_F(PlatformNegativeTest, GivenPlatformWhenGetDevicesFailedThenFalseIsReturned) {
class PlatformShutdown {
public:
PlatformShutdown(Platform *pPlatform) : pPlatform(pPlatform) {
pPlatform->shutdown();
}
~PlatformShutdown() {
pPlatform->shutdown();
}
protected:
Platform *pPlatform = nullptr;
} a(pPlatform);
VariableBackup<decltype(getDevicesResult)> bkp(&getDevicesResult, false); VariableBackup<decltype(getDevicesResult)> bkp(&getDevicesResult, false);
auto ret = pPlatform->initialize(); auto ret = pPlatform->initialize();

View File

@@ -34,14 +34,9 @@
using namespace OCLRT; using namespace OCLRT;
struct PlatformTest : public ::testing::Test { struct PlatformTest : public ::testing::Test {
PlatformTest() {} void SetUp() override { pPlatform.reset(new Platform()); }
void SetUp() override { pPlatform = platform(); }
void TearDown() override {}
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
Platform *pPlatform = nullptr; std::unique_ptr<Platform> pPlatform;
}; };
TEST_F(PlatformTest, getDevices) { TEST_F(PlatformTest, getDevices) {