1 // Copyright (C) 2018 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
6 #include <gtest/gtest.h>
7 #include "ie_device.hpp"
8 #include "details/ie_exception.hpp"
10 using namespace InferenceEngine;
12 class DeviceTests : public ::testing::Test {
14 virtual void TearDown() {
17 virtual void SetUp() {
24 TEST_F(DeviceTests, internalFindThrowsOnBadDevice) {
25 FindPluginRequest request = { TargetDevice::eBalanced };
26 ASSERT_THROW(findPlugin(request), InferenceEngine::details::InferenceEngineException);
29 TEST_F(DeviceTests, externalFindReturnsErrorStatus) {
30 FindPluginRequest request = { TargetDevice::eBalanced };
31 FindPluginResponse result;
33 StatusCode status = findPlugin(request, result, &desc);
34 ASSERT_EQ(status, GENERAL_ERROR);
37 #if defined(ENABLE_OPENVX) || defined(ENABLE_MKL_DNN) || defined(ENABLE_OPENVX_CVE)
38 TEST_F(DeviceTests, externalFindPopulatesResult) {
39 FindPluginRequest request = { TargetDevice::eCPU };
40 FindPluginResponse result;
42 StatusCode status = findPlugin(request, result, &desc);
43 ASSERT_EQ(status, OK);
44 ASSERT_NE(result.names.size(), 0);
48 #if defined(ENABLE_OPENVX) || defined(ENABLE_CLDNN)
49 TEST_F(DeviceTests, internalFindReturnsResponse) {
50 FindPluginRequest request = { TargetDevice::eGPU };
51 FindPluginResponse result = findPlugin(request);
52 ASSERT_NE(result.names.size(), 0);
56 TEST_F(DeviceTests, returnsProperDeviceName) {
57 ASSERT_STREQ(getDeviceName(TargetDevice::eDefault), "Default");
58 ASSERT_STREQ(getDeviceName(TargetDevice::eBalanced), "Balanced");
59 ASSERT_STREQ(getDeviceName(TargetDevice::eCPU), "CPU");
60 ASSERT_STREQ(getDeviceName(TargetDevice::eGPU), "GPU");
61 ASSERT_STREQ(getDeviceName(TargetDevice::eFPGA), "FPGA");
62 ASSERT_STREQ(getDeviceName(TargetDevice::eMYRIAD), "MYRIAD");
63 ASSERT_STREQ(getDeviceName(TargetDevice::eGNA), "GNA");
64 ASSERT_STREQ(getDeviceName(TargetDevice::eHETERO), "HETERO");
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::eHETERO + 1)), "Unknown device");