2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-03-23 22:55:13 +08:00
|
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2018-08-27 17:58:31 +08:00
|
|
|
#include "runtime/os_interface/windows/os_context_win.h"
|
2018-05-22 21:55:06 +08:00
|
|
|
#include "unit_tests/os_interface/windows/os_interface_win_tests.h"
|
2018-08-27 17:58:31 +08:00
|
|
|
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
TEST_F(OsInterfaceTest, givenOsInterfaceWithoutWddmWhenGetHwContextIdIsCalledThenReturnsZero) {
|
|
|
|
auto retVal = osInterface->getHwContextId();
|
|
|
|
EXPECT_EQ(0u, retVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(OsInterfaceTest, GivenWindowsWhenOsSupportFor64KBpagesIsBeingQueriedThenTrueIsReturned) {
|
|
|
|
EXPECT_TRUE(OSInterface::are64kbPagesEnabled());
|
|
|
|
}
|
2018-03-23 22:55:13 +08:00
|
|
|
|
|
|
|
TEST_F(OsInterfaceTest, GivenWindowsWhenCreateEentIsCalledThenValidEventHandleIsReturned) {
|
|
|
|
auto ev = osInterface->get()->createEvent(NULL, TRUE, FALSE, "DUMMY_EVENT_NAME");
|
|
|
|
EXPECT_NE(nullptr, ev);
|
|
|
|
auto ret = osInterface->get()->closeHandle(ev);
|
|
|
|
EXPECT_EQ(TRUE, ret);
|
|
|
|
}
|
2018-08-27 17:58:31 +08:00
|
|
|
|
|
|
|
TEST(OsContextTest, givenWddmWhenCreateOsContextBeforeInitWddmThenOsContextIsNotInitialized) {
|
|
|
|
auto wddm = new WddmMock;
|
|
|
|
OSInterface osInterface;
|
|
|
|
osInterface.get()->setWddm(wddm);
|
2018-09-12 13:47:55 +08:00
|
|
|
EXPECT_THROW(auto osContext = std::make_unique<OsContext>(&osInterface, 0u), std::exception);
|
2018-08-27 17:58:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitialized) {
|
|
|
|
auto wddm = new WddmMock;
|
|
|
|
OSInterface osInterface;
|
|
|
|
osInterface.get()->setWddm(wddm);
|
|
|
|
wddm->init();
|
2018-09-12 13:47:55 +08:00
|
|
|
auto osContext = std::make_unique<OsContext>(&osInterface, 0u);
|
2018-08-27 17:58:31 +08:00
|
|
|
EXPECT_NE(nullptr, osContext->get());
|
|
|
|
EXPECT_TRUE(osContext->get()->isInitialized());
|
2018-08-27 21:48:29 +08:00
|
|
|
EXPECT_EQ(osContext->get()->getWddm(), wddm);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(OsContextTest, whenCreateOsContextWithoutOsInterfaceThenOsContextImplIsNotAvailable) {
|
2018-09-12 13:47:55 +08:00
|
|
|
auto osContext = std::make_unique<OsContext>(nullptr, 0u);
|
2018-08-27 21:48:29 +08:00
|
|
|
EXPECT_EQ(nullptr, osContext->get());
|
2018-08-27 17:58:31 +08:00
|
|
|
}
|