Skip to content

Commit 7ceceda

Browse files
Unit tests: Move initialization of Wddm to fixture's SetUp
Change-Id: I3d3fa30d5aebf4069c1726a21f537a3d40799793 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 12e21c0 commit 7ceceda

File tree

6 files changed

+80
-243
lines changed

6 files changed

+80
-243
lines changed

unit_tests/os_interface/windows/os_time_win_tests.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,6 +22,8 @@
2222

2323
#include "gtest/gtest.h"
2424
#include "mock_os_time_win.h"
25+
#include "runtime/os_interface/windows/os_interface.h"
26+
#include "unit_tests/os_interface/windows/wddm_fixture.h"
2527
#include <memory>
2628

2729
using namespace OCLRT;
@@ -77,3 +79,40 @@ TEST_F(OSTimeWinTest, givenHighValueOfCpuTimestampWhenItIsObtainedThenItHasPrope
7779
osTime->getCpuTime(&timeStamp);
7880
EXPECT_EQ(expectedTimestamp, timeStamp);
7981
}
82+
83+
TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetCpuTimeThenReturnsSuccess) {
84+
uint64_t time = 0;
85+
auto osTime(OSTime::create(nullptr));
86+
auto error = osTime->getCpuTime(&time);
87+
EXPECT_TRUE(error);
88+
EXPECT_NE(0, time);
89+
}
90+
91+
TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetCpuGpuTimeThenReturnsError) {
92+
TimeStampData CPUGPUTime = {0};
93+
auto osTime(OSTime::create(nullptr));
94+
auto success = osTime->getCpuGpuTime(&CPUGPUTime);
95+
EXPECT_FALSE(success);
96+
EXPECT_EQ(0, CPUGPUTime.CPUTimeinNS);
97+
EXPECT_EQ(0, CPUGPUTime.GPUTimeStamp);
98+
}
99+
100+
TEST(OSTimeWinTests, givenOSInterfaceWhenGetCpuGpuTimeThenReturnsSuccess) {
101+
auto wddm = new WddmMock;
102+
wddm->init();
103+
TimeStampData CPUGPUTime01 = {0};
104+
TimeStampData CPUGPUTime02 = {0};
105+
std::unique_ptr<OSInterface> osInterface(new OSInterface());
106+
osInterface->get()->setWddm(wddm);
107+
auto osTime = OSTime::create(osInterface.get());
108+
auto success = osTime->getCpuGpuTime(&CPUGPUTime01);
109+
EXPECT_TRUE(success);
110+
EXPECT_NE(0, CPUGPUTime01.CPUTimeinNS);
111+
EXPECT_NE(0, CPUGPUTime01.GPUTimeStamp);
112+
success = osTime->getCpuGpuTime(&CPUGPUTime02);
113+
EXPECT_TRUE(success);
114+
EXPECT_NE(0, CPUGPUTime02.CPUTimeinNS);
115+
EXPECT_NE(0, CPUGPUTime02.GPUTimeStamp);
116+
EXPECT_GT(CPUGPUTime02.GPUTimeStamp, CPUGPUTime01.GPUTimeStamp);
117+
EXPECT_GT(CPUGPUTime02.CPUTimeinNS, CPUGPUTime01.CPUTimeinNS);
118+
}

0 commit comments

Comments
 (0)