|
1 | 1 | /*
|
2 |
| -* Copyright (c) 2017, Intel Corporation |
| 2 | +* Copyright (c) 2017 - 2018, Intel Corporation |
3 | 3 | *
|
4 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
5 | 5 | * copy of this software and associated documentation files (the "Software"),
|
|
22 | 22 |
|
23 | 23 | #include "gtest/gtest.h"
|
24 | 24 | #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" |
25 | 27 | #include <memory>
|
26 | 28 |
|
27 | 29 | using namespace OCLRT;
|
@@ -77,3 +79,40 @@ TEST_F(OSTimeWinTest, givenHighValueOfCpuTimestampWhenItIsObtainedThenItHasPrope
|
77 | 79 | osTime->getCpuTime(&timeStamp);
|
78 | 80 | EXPECT_EQ(expectedTimestamp, timeStamp);
|
79 | 81 | }
|
| 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