2019-12-19 14:02:05 +01:00
|
|
|
/*
|
2021-03-08 18:50:32 +00:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2019-12-19 14:02:05 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/os_context.h"
|
2019-12-19 14:02:05 +01:00
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
|
|
TEST(OSContext, whenCreatingDefaultOsContextThenExpectInitializedAlways) {
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContext *osContext = OsContext::create(nullptr, 0, 0, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2020-03-03 23:33:31 +01:00
|
|
|
EXPECT_FALSE(osContext->isLowPriority());
|
|
|
|
|
EXPECT_FALSE(osContext->isInternalEngine());
|
|
|
|
|
EXPECT_FALSE(osContext->isRootDevice());
|
|
|
|
|
delete osContext;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
TEST(OSContext, givenInternalAndRootDeviceAreTrueWhenCreatingDefaultOsContextThenExpectGettersTrue) {
|
|
|
|
|
OsContext *osContext = OsContext::create(nullptr, 0, 0, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Internal}, PreemptionMode::Disabled, true);
|
|
|
|
|
EXPECT_FALSE(osContext->isLowPriority());
|
2020-03-03 23:33:31 +01:00
|
|
|
EXPECT_TRUE(osContext->isInternalEngine());
|
|
|
|
|
EXPECT_TRUE(osContext->isRootDevice());
|
2019-12-19 14:02:05 +01:00
|
|
|
delete osContext;
|
|
|
|
|
}
|
2020-03-06 19:02:24 +01:00
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
TEST(OSContext, givenLowPriorityAndRootDeviceAreTrueWhenCreatingDefaultOsContextThenExpectGettersTrue) {
|
|
|
|
|
OsContext *osContext = OsContext::create(nullptr, 0, 0, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::LowPriority}, PreemptionMode::Disabled, true);
|
|
|
|
|
EXPECT_TRUE(osContext->isLowPriority());
|
|
|
|
|
EXPECT_FALSE(osContext->isInternalEngine());
|
|
|
|
|
EXPECT_TRUE(osContext->isRootDevice());
|
|
|
|
|
delete osContext;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 19:02:24 +01:00
|
|
|
TEST(OSContext, givenOsContextCreatedDefaultIsFalseWhenSettingTrueThenFlagTrueReturned) {
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContext *osContext = OsContext::create(nullptr, 0, 0, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2020-03-06 19:02:24 +01:00
|
|
|
EXPECT_FALSE(osContext->isDefaultContext());
|
|
|
|
|
osContext->setDefaultContext(true);
|
|
|
|
|
EXPECT_TRUE(osContext->isDefaultContext());
|
|
|
|
|
delete osContext;
|
|
|
|
|
}
|