Syncing from internal gitlab

[#21] Fix issue with mismatch in NN and NN conformance results

[#21,#17] Fixes cmake issues for both issues

- #21, Needed to disable Network folder build when NN_16 is not
  being enabled
- #17, Need to add appropriate posix definitions in order to allow
  proper access to usleep within unistd.h
diff --git a/test_conformance/CMakeLists.txt b/test_conformance/CMakeLists.txt
index 8f1fbef..0b2e247 100644
--- a/test_conformance/CMakeLists.txt
+++ b/test_conformance/CMakeLists.txt
@@ -1,4 +1,4 @@
-# 
+#
 
 # Copyright (c) 2012-2017 The Khronos Group Inc.
 #
@@ -21,7 +21,10 @@
 
 file(GLOB SOURCES "./*.c")
 file(GLOB HEADERS "./*.h")
+
+if(OPENVX_USE_NN_16)
 file(GLOB NETWORK_SOURCES "./Networks/src/*")
+endif(OPENVX_USE_NN_16)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 
diff --git a/test_conformance/Networks/src/common.c b/test_conformance/Networks/src/common.c
index 96c6604..c1a2108 100644
--- a/test_conformance/Networks/src/common.c
+++ b/test_conformance/Networks/src/common.c
@@ -1,7 +1,9 @@
 /** @file common.c
- *  @brief 
- *  This file contains the implementation of the generated utility functions 
+ *  @brief
+ *  This file contains the implementation of the generated utility functions
  */
+#ifdef OPENVX_CONFORMANCE_NEURAL_NETWORKS
+#ifdef OPENVX_USE_NN_16
 
 #include "common.h"
 #include <stdio.h>
@@ -23,12 +25,15 @@
 
             if(pObj->ref)
             {
-                if(pObj->type == VX_TYPE_IMAGE)
+                if(pObj->type == VX_TYPE_TENSOR)
+                    vxReleaseTensor((vx_tensor*)&(pObj->ref));
+                else if(pObj->type == VX_TYPE_SCALAR)
+                    vxReleaseScalar((vx_scalar*)&(pObj->ref));
+#if defined OPENVX_USE_ENHANCED_VISION || OPENVX_CONFORMANCE_VISION
+                else if(pObj->type == VX_TYPE_IMAGE)
                     vxReleaseImage((vx_image*)&(pObj->ref));
                 else if(pObj->type == VX_TYPE_ARRAY)
                     vxReleaseArray((vx_array*)&(pObj->ref));
-                else if(pObj->type == VX_TYPE_SCALAR)
-                    vxReleaseScalar((vx_scalar*)&(pObj->ref));
                 else if(pObj->type == VX_TYPE_REMAP)
                     vxReleaseRemap((vx_remap*)&(pObj->ref));
                 else if(pObj->type == VX_TYPE_CONVOLUTION)
@@ -45,10 +50,9 @@
                     vxReleaseLUT((vx_lut*)&(pObj->ref));
                 else if(pObj->type == VX_TYPE_OBJECT_ARRAY)
                     vxReleaseObjectArray((vx_object_array*)&(pObj->ref));
-				else if(pObj->type == VX_TYPE_TENSOR)
-                    vxReleaseTensor((vx_tensor*)&(pObj->ref));
                 else if(pObj->type == VX_TYPE_DELAY)
                     vxReleaseDelay((vx_delay*)&(pObj->ref));
+#endif
             }
             else if(pObj->pMem)
             {
@@ -156,7 +160,7 @@
         {
             if(0 == strcmp(nodeName, filteredNodesList[i]))
             {
-                bCreateNode = true;                
+                bCreateNode = true;
                 break;
             }
         }
@@ -173,12 +177,12 @@
             return status;
         }
         AddVXObject(pObjectContainer, (vx_reference)*node, VX_TYPE_NODE, nodeName);
-    }    
+    }
     else
     {
         *node = NULL;
     }
-    return VX_SUCCESS;    
+    return VX_SUCCESS;
 }
 
 int WriteLog(const char* format, ...)
@@ -196,9 +200,9 @@
 {
     static char allVxStatusEnumsContainer[1024];
     static char* statusArray[VX_SUCCESS - VX_STATUS_MIN + 1];
-	static bool firstTime = true;
-	if (firstTime)
-	{
+    static bool firstTime = true;
+    if (firstTime)
+    {
         size_t index = 0;
         for (int i = VX_STATUS_MIN; i <= VX_SUCCESS; ++i)
         {
@@ -209,7 +213,7 @@
             else if (i == VX_ERROR_INVALID_SCOPE) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_SCOPE");
             else if (i == VX_ERROR_INVALID_NODE) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_NODE");
             else if (i == VX_ERROR_INVALID_GRAPH) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_GRAPH");
-		    else if (i == VX_ERROR_INVALID_TYPE) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_TYPE");
+            else if (i == VX_ERROR_INVALID_TYPE) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_TYPE");
             else if (i == VX_ERROR_INVALID_VALUE) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_VALUE");
             else if (i == VX_ERROR_INVALID_DIMENSION) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_DIMENSION");
             else if (i == VX_ERROR_INVALID_FORMAT) strcpy(allVxStatusEnumsContainer + index, "VX_ERROR_INVALID_FORMAT");
@@ -230,8 +234,8 @@
             else strcpy(allVxStatusEnumsContainer + index, "Unknown error");
             statusArray[i - VX_STATUS_MIN] = allVxStatusEnumsContainer + index;
             index += strlen(allVxStatusEnumsContainer + index) + 1;
-	    }
-		firstTime = false;
+        }
+        firstTime = false;
     }
     return statusArray;
 }
@@ -247,3 +251,6 @@
     }
     return statusContainer[vxStatus - VX_STATUS_MIN];
 }
+
+#endif
+#endif
diff --git a/test_engine/CMakeLists.txt b/test_engine/CMakeLists.txt
index 5ab87db..fda2415 100644
--- a/test_engine/CMakeLists.txt
+++ b/test_engine/CMakeLists.txt
@@ -1,4 +1,4 @@
-# 
+#
 
 # Copyright (c) 2012-2017 The Khronos Group Inc.
 #
@@ -22,6 +22,9 @@
 file(GLOB SOURCES "./*.c")
 file(GLOB HEADERS "./*.h")
 
+# Following is added for accessing prototype of usleep() in unistd.h
+add_definitions( -D_XOPEN_SOURCE=700 -D_GNU_SOURCE=1 )
+
 add_library(${target} STATIC ${SOURCES} ${HEADERS})
 target_include_directories(${target} PUBLIC ${CMAKE_SOURCE_DIR})
 target_link_libraries(${target} PUBLIC openvx-interface)
diff --git a/test_engine/test_engine.c b/test_engine/test_engine.c
index c9538c3..b3bb51e 100644
--- a/test_engine/test_engine.c
+++ b/test_engine/test_engine.c
@@ -919,15 +919,25 @@
                     if (strncmp(enhanced_vision_test[i], test_name, sizeof(enhanced_vision_test[i]) - 1) == 0) {
                         conformance_enhanced_vision_status = 1;
                         i = enhance_vision_num;
-            }
-        }
+                    }
+                }
 #endif
+#ifdef OPENVX_CONFORMANCE_NEURAL_NETWORKS
 #ifdef OPENVX_USE_NN
                 if (strncmp("TensorNN", test_name, sizeof("TensorNN") - 1) == 0) {
                     total_openvx_failed_nn_tests ++;
+                    total_openvx_failed_neural_networks_tests ++;
                 }
                 else
 #endif
+#ifdef OPENVX_USE_NN_16
+                if (strncmp("TensorNetworks", test_name, sizeof("TensorNetworks") - 1) == 0) {
+                    total_openvx_failed_nn_tests ++;
+                    total_openvx_failed_neural_networks_tests ++;
+                }
+                else
+#endif
+#endif
 #ifdef OPENVX_USE_IX
                 if (strncmp("ExtensionObject", test_name, sizeof("ExtensionObject") - 1) == 0) {
                     total_openvx_failed_ix_tests ++;
@@ -958,20 +968,6 @@
                 }
                 else
 #endif
-#ifdef OPENVX_CONFORMANCE_NEURAL_NETWORKS
-#ifdef OPENVX_USE_NN
-                if (strncmp("TensorNN", test_name, sizeof("TensorNN") - 1) == 0) {
-                    total_openvx_failed_neural_networks_tests ++;
-                }
-                else
-#endif
-#ifdef OPENVX_USE_NN_16
-                if (strncmp("TensorNetworks", test_name, sizeof("TensorNetworks") - 1) == 0) {
-                    total_openvx_failed_neural_networks_tests ++;
-                }
-                else
-#endif
-#endif
 #ifdef OPENVX_CONFORMANCE_NNEF_IMPORT
                 if (strncmp("TensorNNEFImport", test_name, sizeof("TensorNNEFImport") - 1) == 0) {
                     total_openvx_failed_nnef_tests ++;