Files
compute-runtime/opencl/test/unit_test/device/get_device_name_tests.cpp
Slawomir Milczarek 8c4f3d3953 Add 4-digit zero alignment of device id in device name
Related-To: NEO-4744

Change-Id: Iedca3cb68c015e70bcebbeb2a45fdc2a8563518d
Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
2020-10-19 15:00:32 +02:00

35 lines
1.1 KiB
C++

/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/unit_test/helpers/default_hw_info.h"
#include "shared/test/unit_test/mocks/mock_device.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "gtest/gtest.h"
namespace NEO {
extern const char *familyName[];
} // namespace NEO
using namespace NEO;
using DeviceNameTest = ::testing::Test;
TEST_F(DeviceNameTest, WhenCallingGetClDeviceNameThenReturnDeviceNameWithDeviceIdAppendedAtTheEnd) {
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
std::string deviceName = "Intel(R) Graphics ";
deviceName += familyName[defaultHwInfo->platform.eRenderCoreFamily];
EXPECT_STREQ(deviceName.c_str(), clDevice->device.getDeviceName(*defaultHwInfo.get()).c_str());
std::stringstream clDeviceName;
clDeviceName << deviceName;
clDeviceName << " [0x" << std::hex << std::setw(4) << std::setfill('0') << defaultHwInfo->platform.usDeviceID << "]";
EXPECT_STREQ(clDeviceName.str().c_str(), clDevice->getClDeviceName(*defaultHwInfo.get()).c_str());
}