Skip to content

Commit 77ad97d

Browse files
Do not test global platform.
- change the test to use locally allocated object Change-Id: Ie0818a4791d03d8f9004aba312f58fa0746c608b
1 parent 8672360 commit 77ad97d

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

unit_tests/platform/platform_negative_tests.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,13 @@ extern bool getDevicesResult;
3333

3434
struct PlatformNegativeTest : public ::testing::Test {
3535
void SetUp() override {
36-
pPlatform = platform();
36+
pPlatform.reset(new Platform());
3737
}
3838

39-
Platform *pPlatform = nullptr;
39+
std::unique_ptr<Platform> pPlatform;
4040
};
4141

4242
TEST_F(PlatformNegativeTest, GivenPlatformWhenGetDevicesFailedThenFalseIsReturned) {
43-
class PlatformShutdown {
44-
public:
45-
PlatformShutdown(Platform *pPlatform) : pPlatform(pPlatform) {
46-
pPlatform->shutdown();
47-
}
48-
~PlatformShutdown() {
49-
pPlatform->shutdown();
50-
}
51-
52-
protected:
53-
Platform *pPlatform = nullptr;
54-
} a(pPlatform);
55-
5643
VariableBackup<decltype(getDevicesResult)> bkp(&getDevicesResult, false);
5744

5845
auto ret = pPlatform->initialize();

unit_tests/platform/platform_tests.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,9 @@
3434
using namespace OCLRT;
3535

3636
struct PlatformTest : public ::testing::Test {
37-
PlatformTest() {}
38-
39-
void SetUp() override { pPlatform = platform(); }
40-
41-
void TearDown() override {}
42-
37+
void SetUp() override { pPlatform.reset(new Platform()); }
4338
cl_int retVal = CL_SUCCESS;
44-
Platform *pPlatform = nullptr;
39+
std::unique_ptr<Platform> pPlatform;
4540
};
4641

4742
TEST_F(PlatformTest, getDevices) {

0 commit comments

Comments
 (0)