Publishing R3
[platform/upstream/dldt.git] / inference-engine / tests / unit / inference_engine_tests / device_tests.cpp
1 // Copyright (C) 2018 Intel Corporation
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5
6 #include <gtest/gtest.h>
7 #include "ie_device.hpp"
8 #include "details/ie_exception.hpp"
9
10 using namespace InferenceEngine;
11
12 class DeviceTests : public ::testing::Test {
13 protected:
14     virtual void TearDown() {
15     }
16
17     virtual void SetUp() {
18     }
19
20 public:
21
22 };
23
24 TEST_F(DeviceTests, internalFindThrowsOnBadDevice) {
25     FindPluginRequest request = { TargetDevice::eBalanced };
26     ASSERT_THROW(findPlugin(request), InferenceEngine::details::InferenceEngineException);
27 }
28
29 TEST_F(DeviceTests, externalFindReturnsErrorStatus) {
30     FindPluginRequest request = { TargetDevice::eBalanced };
31     FindPluginResponse result;
32     ResponseDesc desc;
33     StatusCode status = findPlugin(request, result, &desc);
34     ASSERT_EQ(status, GENERAL_ERROR);
35 }
36
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;
41     ResponseDesc desc;
42     StatusCode status = findPlugin(request, result, &desc);
43     ASSERT_EQ(status, OK);
44     ASSERT_NE(result.names.size(), 0);
45 }
46 #endif
47
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);
53 }
54 #endif
55
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");
68 }