[IE][VPU]: Fix behavior tests for MXpcie (#1879)
authorAndrey Chekhonin <andrey.chekhonin@intel.com>
Mon, 7 Sep 2020 07:38:07 +0000 (10:38 +0300)
committerGitHub <noreply@github.com>
Mon, 7 Sep 2020 07:38:07 +0000 (10:38 +0300)
* Moved mem type patching under USB protocol switch
* Myriad beh tests fix

inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp
inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp
inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_load_network_case.cpp
inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_get_metric_tests.cpp
inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_protocol_tests.cpp
inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp
inference-engine/thirdparty/movidius/mvnc/src/mvnc_data.c

index a33a583..647871f 100644 (file)
@@ -13,6 +13,7 @@
 
 constexpr char MyriadDevicesInfo::kMyriadXName[];
 constexpr char MyriadDevicesInfo::kMyriad2Name[];
+constexpr char MyriadDevicesInfo::kMyriadXPCIeName[];
 
 MyriadDevicesInfo::MyriadDevicesInfo() {
 #if (defined(_WIN32) || defined(_WIN64))
index 00d2738..6e36544 100644 (file)
@@ -19,6 +19,7 @@ public:
     // Constants
     static constexpr char kMyriadXName[] = "ma2480";
     static constexpr char kMyriad2Name[] = "ma2450";
+    static constexpr char kMyriadXPCIeName[] = "mxl";
 
     //Constructor
     MyriadDevicesInfo();
@@ -54,7 +55,8 @@ const std::string& MyriadDevicesInfo::firmwareDir() {
 }
 
 bool MyriadDevicesInfo::isMyriadXDevice(const std::string &device_name) {
-    return (device_name.find(kMyriadXName) != std::string::npos);
+    return ( (device_name.find(kMyriadXName) != std::string::npos)
+             || (device_name.find(kMyriadXPCIeName) != std::string::npos) );
 }
 
 bool MyriadDevicesInfo::isMyriad2Device(const std::string &device_name) {
index 7bf1598..20e8faa 100644 (file)
@@ -26,6 +26,6 @@ void MyriadLoadNetworkTestCase::LoadNetwork() {
 }
 
 bool MyriadLoadNetworkTestCase::IsDeviceAvailable(std::string device_name) {
-    auto act_devices = getDevicesList();
+    auto act_devices = getDevicesList(NC_ANY_PROTOCOL, NC_ANY_PLATFORM, X_LINK_UNBOOTED);
     return std::find(act_devices.begin(), act_devices.end(), device_name) != act_devices.end();
-}
\ No newline at end of file
+}
index 6555a67..5ffd53f 100644 (file)
@@ -83,18 +83,16 @@ TEST_F(VPUGetMetric, smoke_ThermalStatsFromPluginWithoutLoadedNetwork) {
     ASSERT_TRUE(result.empty());
 }
 
-TEST_F(VPUGetMetric, smoke_MyriadGetAvailableDevices) {
+TEST_F(VPUGetMetric, smoke_MyriadGetFullDeviceName) {
     std::vector<std::string> availableDevices;
     ASSERT_NO_THROW(availableDevices = getAvailableDevices());
     ASSERT_TRUE(!availableDevices.empty());
 
     auto result = Parameter{};
-    auto deviceNames = std::vector<std::string>(availableDevices.size());
     for (size_t i = 0; i < availableDevices.size(); ++i) {
         const auto deviceName = "MYRIAD." + availableDevices[i];
         ASSERT_NO_THROW(result = ie.GetMetric(deviceName, METRIC_KEY(FULL_DEVICE_NAME)));
-
-        deviceNames[i] = result.as<std::string>();
-        ASSERT_TRUE(deviceNames[i] != availableDevices[i]);
+        auto act_res = result.as<std::string>();
+        ASSERT_TRUE(!act_res.empty());
     }
 }
index d66b56e..a2c2fb4 100644 (file)
@@ -3,6 +3,7 @@
 //
 
 #include "helpers/myriad_protocol_case.hpp"
+#include "XLinkLog.h"
 
 std::shared_ptr<InferenceEngine::Core> MyriadProtocolTests::ie = nullptr;
 
@@ -26,6 +27,33 @@ TEST_P(MyriadProtocolTests, CanInferenceWithProtocol) {
     ASSERT_EQ(statusCode, StatusCode::OK) << resp.msg;
 }
 
+
+
+TEST_P(MyriadProtocolTests, NoErrorsMessagesWhenLoadNetworkSuccessful) {
+    if (protocol != NC_USB) {
+        GTEST_SKIP();
+    }
+
+    char buff[8192] = {};
+    setbuf(stdout, buff);
+
+    auto network = ie->ReadNetwork(FuncTestUtils::TestModel::convReluNormPoolFcModelFP16.model_xml_str,
+                                   FuncTestUtils::TestModel::convReluNormPoolFcModelFP16.weights_blob);
+
+    std::map<std::string, std::string> config = {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_WARNING)}};
+
+    InferenceEngine::IExecutableNetwork::Ptr exe_network =
+            ie->LoadNetwork(network, "MYRIAD", config);
+    setbuf(stdout, NULL);
+
+
+    std::string content(buff);
+    for (int i = MVLOG_WARN; i < MVLOG_LAST; i++) {
+        auto found = content.find(mvLogHeader[i]);
+        ASSERT_TRUE(found == std::string::npos);
+    }
+}
+
 INSTANTIATE_TEST_CASE_P(smoke_VPUConfigProtocolTests,
                         MyriadProtocolTests,
                         ::testing::ValuesIn(myriadProtocols),
index bfb7299..b9b6057 100644 (file)
@@ -60,10 +60,10 @@ class MYRIADWatchdog :  public BehaviorPluginTest,
         int total() const {return booted + unbooted;}
     };
 
-    DevicesState queryDevices() {
+    DevicesState queryDevices(ncDeviceProtocol_t protocol = NC_ANY_PROTOCOL) {
         DevicesState devicesState;
-        devicesState.booted = getAmountOfBootedDevices(NC_USB);
-        devicesState.unbooted = getAmountOfUnbootedDevices(NC_USB);
+        devicesState.booted = getAmountOfBootedDevices(protocol);
+        devicesState.unbooted = getAmountOfUnbootedDevices(protocol);
         return devicesState;
     }
 
@@ -120,8 +120,11 @@ class MYRIADWatchdog :  public BehaviorPluginTest,
 }
 
 TEST_P(MYRIADWatchdog, canDisableWatchdog) {
-
-    auto startup_devices = queryDevices();
+    auto startup_devices = queryDevices(NC_PCIE);
+    if (startup_devices.unbooted >= 1) {
+        GTEST_SKIP();
+    }
+    startup_devices = queryDevices(NC_USB);
     ASSERT_GE(startup_devices.unbooted, 1);
 
     auto ctime = Time::now();
@@ -136,7 +139,7 @@ TEST_P(MYRIADWatchdog, canDisableWatchdog) {
     for (int j = 0; j != 20; j++) {
         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
         std::cout << "Time since boot:" << chrono::duration_cast<ms>(Time::now() - ctime).count() << std::endl;
-        if (queryDevices().booted == startup_devices.booted) {
+        if (queryDevices(NC_USB).booted == startup_devices.booted) {
             SUCCEED() << "All devices gets reset";
             break;
         }
@@ -149,7 +152,11 @@ TEST_P(MYRIADWatchdog, canDisableWatchdog) {
 }
 
 TEST_P(MYRIADWatchdog, canDetectWhenHostSiteStalled) {
-    auto startup_devices = queryDevices();
+    auto startup_devices = queryDevices(NC_PCIE);
+    if (startup_devices.unbooted >= 1) {
+        GTEST_SKIP();
+    }
+    startup_devices = queryDevices(NC_USB);
     ASSERT_GE(startup_devices.unbooted, 1);
 
     auto ctime = Time::now();
@@ -180,12 +187,13 @@ TEST_P(MYRIADWatchdog, canDetectWhenHostSiteStalled) {
 
 TEST_P(MYRIADWatchdog, watchDogIntervalDefault) {
     auto startup_devices = queryDevices();
+    ASSERT_GE(startup_devices.unbooted, 1);
+
     auto ctime = Time::now();
     {
         InferenceEngine::Core core;
         auto model = FuncTestUtils::TestModel::convReluNormPoolFcModelFP16;
         CNNNetwork network = core.ReadNetwork(model.model_xml_str, model.weights_blob);
-        ASSERT_GE(startup_devices.unbooted, 1);
 
         ExecutableNetwork ret;
         ctime = Time::now();
@@ -212,13 +220,18 @@ TEST_P(MYRIADWatchdog, watchDogIntervalDefault) {
 }
 
 TEST_P(MYRIADWatchdog, canTurnoffWatchDogViaConfig) {
-    auto startup_devices = queryDevices();
+    auto startup_devices = queryDevices(NC_PCIE);
+    if (startup_devices.unbooted >= 1) {
+        GTEST_SKIP();
+    }
+    startup_devices = queryDevices(NC_USB);
+    ASSERT_GE(startup_devices.unbooted, 1);
+
     auto ctime = Time::now();
     {
         InferenceEngine::Core core;
         auto model = FuncTestUtils::TestModel::convReluNormPoolFcModelFP16;
         CNNNetwork network = core.ReadNetwork(model.model_xml_str, model.weights_blob);
-        ASSERT_GE(startup_devices.unbooted, 1);
 
         ExecutableNetwork ret;
         ctime = Time::now();
@@ -232,7 +245,7 @@ TEST_P(MYRIADWatchdog, canTurnoffWatchDogViaConfig) {
         for (int j = 0; j != 20; j++) {
             std::this_thread::sleep_for(std::chrono::milliseconds(1000));
             std::cout << "Time since boot:" << chrono::duration_cast<ms>(Time::now() - ctime).count() << std::endl;
-            if (queryDevices().booted == startup_devices.booted) {
+            if (queryDevices(NC_USB).booted == startup_devices.booted) {
                 SUCCEED() << "All devices gets reset";
                 break;
             }
index 16004b2..bc199ec 100644 (file)
@@ -202,10 +202,9 @@ static ncStatus_t patchSetWdSwitchCommand(char **firmware, size_t *length, const
     }
 
     if(!executeCommandFound) {
-        mvLog(MVLOG_ERROR, "Fail to find execute command");
+        mvLog(MVLOG_WARN, "Fail to find execute command");
         return NC_ERROR;
     }
-
     return patchFirmware(firmware, length, executeCommandIdx,
                          g_setWdSwitchCommandMX, sizeof(g_setWdSwitchCommandMX), wdEnable);
 }
@@ -241,10 +240,9 @@ static ncStatus_t patchSetMemTypeCommand(char **firmware, size_t *length, const
     }
 
     if(!callCommandFound) {
-        mvLog(MVLOG_ERROR, "Fail to find call command");
+        mvLog(MVLOG_WARN, "Fail to find call command");
         return NC_ERROR;
     }
-
     return patchFirmware(firmware, length, callCommandIdx,
                          g_setMemTypeCommandMX, sizeof(g_setMemTypeCommandMX), memType);
 }
@@ -266,18 +264,14 @@ ncStatus_t bootDevice(deviceDesc_t* deviceDescToBoot,
         if(deviceDescToBoot->protocol != X_LINK_PCIE) {
             sc = patchSetWdSwitchCommand(&firmware, &length, bootOptions.wdEnable);
             if(sc) {
-                mvLog(MVLOG_ERROR, "Fail to patch \"Set wd switch value\" command for firmware sc = %d", sc);
-                free(firmware);
-                return sc;
+                mvLog(MVLOG_WARN, "Fail to patch \"Set wd switch value\" command for firmware sc = %d", sc);
             }
-        }
-
-        sc = patchSetMemTypeCommand(&firmware, &length, bootOptions.memType);
-        if(sc) {
-            mvLog(MVLOG_ERROR, "Fail to patch \"Set memory type\" command for firmware sc = %d", sc);
-            free(firmware);
-            return sc;
-        }
+            
+            sc = patchSetMemTypeCommand(&firmware, &length, bootOptions.memType);
+            if(sc) {
+                mvLog(MVLOG_WARN, "Fail to patch \"Set memory type\" command for firmware sc = %d", sc);
+            }
+        }       
     }
 
     XLinkError_t rc = XLinkBootFirmware(deviceDescToBoot, firmware, length);