Files
compute-runtime/unit_tests/helpers/windows/kmd_notify_windows_tests.cpp
Filip Hazubski 8b57d28116 clang-format: enable sorting includes
Include files are now grouped and sorted in following order:
1. Header file of the class the current file implements
2. Project files
3. Third party files
4. Standard library

Change-Id: If31af05652184169f7fee1d7ad08f1b2ed602cf0
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
2019-02-27 11:50:07 +01:00

73 lines
2.5 KiB
C++

/*
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/kmd_notify_properties.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/windows/sys_calls.h"
#include "test.h"
#include "unit_tests/helpers/variable_backup.h"
namespace OCLRT {
namespace SysCalls {
extern BOOL systemPowerStatusRetVal;
extern BYTE systemPowerStatusACLineStatusOverride;
} // namespace SysCalls
class MockKmdNotifyHelper : public KmdNotifyHelper {
public:
using KmdNotifyHelper::acLineConnected;
using KmdNotifyHelper::getBaseTimeout;
using KmdNotifyHelper::updateAcLineStatus;
MockKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
};
TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnSuccessThenUpdateAcLineStatus) {
auto properties = &(platformDevices[0]->capabilityTable.kmdNotifyProperties);
MockKmdNotifyHelper helper(properties);
EXPECT_TRUE(helper.acLineConnected);
VariableBackup<BOOL> systemPowerStatusRetValBkp(&SysCalls::systemPowerStatusRetVal);
VariableBackup<BYTE> systemPowerStatusACLineStatusOverrideBkp(&SysCalls::systemPowerStatusACLineStatusOverride);
systemPowerStatusRetValBkp = 1;
systemPowerStatusACLineStatusOverrideBkp = 0;
helper.updateAcLineStatus();
EXPECT_FALSE(helper.acLineConnected);
systemPowerStatusACLineStatusOverrideBkp = 1;
helper.updateAcLineStatus();
EXPECT_TRUE(helper.acLineConnected);
}
TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnErrorThenDontUpdateAcLineStatus) {
auto properties = &(platformDevices[0]->capabilityTable.kmdNotifyProperties);
MockKmdNotifyHelper helper(properties);
EXPECT_TRUE(helper.acLineConnected);
VariableBackup<BOOL> systemPowerStatusRetValBkp(&SysCalls::systemPowerStatusRetVal);
VariableBackup<BYTE> systemPowerStatusACLineStatusOverrideBkp(&SysCalls::systemPowerStatusACLineStatusOverride);
systemPowerStatusRetValBkp = 0;
systemPowerStatusACLineStatusOverrideBkp = 0;
helper.updateAcLineStatus();
EXPECT_TRUE(helper.acLineConnected);
}
TEST(KmdNotifyWindowsTests, givenTaskCountDiffGreaterThanOneWhenBaseTimeoutRequestedThenDontMultiply) {
auto localProperties = (platformDevices[0]->capabilityTable.kmdNotifyProperties);
localProperties.delayKmdNotifyMicroseconds = 10;
const int64_t multiplier = 10;
MockKmdNotifyHelper helper(&localProperties);
EXPECT_EQ(localProperties.delayKmdNotifyMicroseconds, helper.getBaseTimeout(multiplier));
}
} // namespace OCLRT