1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
5 #include <gtest/gtest.h>
6 #include "ie_device.hpp"
7 #include "details/ie_exception.hpp"
9 using namespace InferenceEngine;
11 class DeviceTests : public ::testing::Test {
13 virtual void TearDown() {
16 virtual void SetUp() {
23 TEST_F(DeviceTests, internalFindThrowsOnBadDevice) {
24 FindPluginRequest request = { TargetDevice::eBalanced };
25 ASSERT_THROW(findPlugin(request), InferenceEngine::details::InferenceEngineException);
28 TEST_F(DeviceTests, externalFindReturnsErrorStatus) {
29 FindPluginRequest request = { TargetDevice::eBalanced };
30 FindPluginResponse result;
32 StatusCode status = findPlugin(request, result, &desc);
33 ASSERT_EQ(status, GENERAL_ERROR);
36 #if defined(ENABLE_OPENVX) || defined(ENABLE_MKL_DNN) || defined(ENABLE_OPENVX_CVE)
37 TEST_F(DeviceTests, externalFindPopulatesResult) {
38 FindPluginRequest request = { TargetDevice::eCPU };
39 FindPluginResponse result;
41 StatusCode status = findPlugin(request, result, &desc);
42 ASSERT_EQ(status, OK);
43 ASSERT_NE(result.names.size(), 0);
47 #if defined(ENABLE_OPENVX) || defined(ENABLE_CLDNN)
48 TEST_F(DeviceTests, internalFindReturnsResponse) {
49 FindPluginRequest request = { TargetDevice::eGPU };
50 FindPluginResponse result = findPlugin(request);
51 ASSERT_NE(result.names.size(), 0);
55 TEST_F(DeviceTests, returnsProperDeviceName) {
56 ASSERT_STREQ(getDeviceName(TargetDevice::eDefault), "Default");
57 ASSERT_STREQ(getDeviceName(TargetDevice::eBalanced), "Balanced");
58 ASSERT_STREQ(getDeviceName(TargetDevice::eCPU), "CPU");
59 ASSERT_STREQ(getDeviceName(TargetDevice::eGPU), "GPU");
60 ASSERT_STREQ(getDeviceName(TargetDevice::eFPGA), "FPGA");
61 ASSERT_STREQ(getDeviceName(TargetDevice::eMYRIAD), "MYRIAD");
62 ASSERT_STREQ(getDeviceName(TargetDevice::eGNA), "GNA");
63 ASSERT_STREQ(getDeviceName(TargetDevice::eHETERO), "HETERO");
64 ASSERT_STREQ(getDeviceName(TargetDevice::eKMB), "KMB");
65 ASSERT_STREQ(getDeviceName(static_cast<TargetDevice>(-1)), "Unknown device");
66 //off by one test - might not be enough
67 ASSERT_STREQ(getDeviceName(static_cast<TargetDevice>((uint8_t)TargetDevice::eKMB + 1)), "Unknown device");