[Test] file name for test
authorJaeyun Jung <jy1210.jung@samsung.com>
Wed, 21 Aug 2024 07:45:37 +0000 (16:45 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 21 Aug 2024 09:28:16 +0000 (18:28 +0900)
Code clean, update file name for custom library test and fix indent.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
include/nnstreamer-edge-custom.h
tests/CMakeLists.txt
tests/nnstreamer-edge-custom-test.c [new file with mode: 0644]
tests/nnstreamer-edge-custom.c [deleted file]
tests/unittest_nnstreamer-edge.cc

index 5fee205b5b72552fc01c297372a0f5319be9a393..eee65048562db35db8f28360cfcf343b390271d6 100644 (file)
@@ -20,7 +20,9 @@ extern "C" {
 #endif /* __cplusplus */
 
 /**
- * @brief NNStreamer Edge custom connection definition. This is used to define a custom connsction. The user should implement the functions and provide them using nns_edge_custom_get_instance(). Refer to the example in nnstreamer-edge-custom.c for more details.
+ * @brief NNStreamer Edge custom connection definition. This is used to define a custom connection.
+ * The user should implement the functions and provide them using nns_edge_custom_get_instance().
+ * Refer to the example in nnstreamer-edge-custom-test.c for more details.
  */
 typedef struct _NnsEdgeCustomDef
 {
@@ -43,7 +45,6 @@ typedef struct _NnsEdgeCustomDef
  */
 void* nns_edge_custom_get_instance ();
 
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 0d8447630a4961ce2d9599a6fb4e2d63dad40bba..5a919be5442bbc28514fe7c94ee183344b4d7905 100644 (file)
@@ -5,17 +5,16 @@ TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge ${TEST_REQUIRE_PKGS_LDFLAGS} ${NN
 INSTALL (TARGETS unittest_nnstreamer-edge DESTINATION ${BIN_INSTALL_DIR})
 
 # Custom connection lib for unit test
-SET(NNS_EDGE_CUSTOM_LIB_NAME nnstreamer-edge-custom-test)
-SET(NNS_EDGE_CUSTOM_SRCS ${NNS_EDGE_SRCS} nnstreamer-edge-custom.c)
-ADD_LIBRARY(${NNS_EDGE_CUSTOM_LIB_NAME} SHARED ${NNS_EDGE_CUSTOM_SRCS})
-SET_TARGET_PROPERTIES(${NNS_EDGE_CUSTOM_LIB_NAME} PROPERTIES VERSION ${SO_VERSION})
-TARGET_INCLUDE_DIRECTORIES(${NNS_EDGE_CUSTOM_LIB_NAME} PRIVATE ${EDGE_REQUIRE_PKGS_INCLUDE_DIRS} ${INCLUDE_DIR} ${NNS_EDGE_SRC_DIR})
-TARGET_LINK_LIBRARIES(${NNS_EDGE_CUSTOM_LIB_NAME} ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME})
-INSTALL (TARGETS ${NNS_EDGE_CUSTOM_LIB_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+SET(NNS_EDGE_CUSTOM_TEST_LIB_NAME nnstreamer-edge-custom-test)
+SET(NNS_EDGE_CUSTOM_SRCS ${NNS_EDGE_SRCS} nnstreamer-edge-custom-test.c)
+ADD_LIBRARY(${NNS_EDGE_CUSTOM_TEST_LIB_NAME} SHARED ${NNS_EDGE_CUSTOM_SRCS})
+TARGET_INCLUDE_DIRECTORIES(${NNS_EDGE_CUSTOM_TEST_LIB_NAME} PRIVATE ${EDGE_REQUIRE_PKGS_INCLUDE_DIRS} ${INCLUDE_DIR} ${NNS_EDGE_SRC_DIR})
+TARGET_LINK_LIBRARIES(${NNS_EDGE_CUSTOM_TEST_LIB_NAME} ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME})
+INSTALL (TARGETS ${NNS_EDGE_CUSTOM_TEST_LIB_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
 ADD_EXECUTABLE(unittest_nnstreamer-edge-custom unittest_nnstreamer-edge-custom.cc)
 TARGET_INCLUDE_DIRECTORIES(unittest_nnstreamer-edge-custom PRIVATE ${EDGE_REQUIRE_PKGS_INCLUDE_DIRS} ${INCLUDE_DIR} ${NNS_EDGE_SRC_DIR})
-TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge-custom ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME} ${NNS_EDGE_CUSTOM_LIB_NAME})
+TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge-custom ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME} ${NNS_EDGE_CUSTOM_TEST_LIB_NAME})
 INSTALL (TARGETS unittest_nnstreamer-edge-custom DESTINATION ${BIN_INSTALL_DIR})
 
 # AITT test
diff --git a/tests/nnstreamer-edge-custom-test.c b/tests/nnstreamer-edge-custom-test.c
new file mode 100644 (file)
index 0000000..48f599f
--- /dev/null
@@ -0,0 +1,201 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * Copyright (C) 2024 Gichan Jang <gichan2.jang@samsung.com>
+ *
+ * @file   nnstreamer-edge-custom-test.c
+ * @date   16 Aug 2024
+ * @brief  NNStreamer-edge custom connection for test.
+ * @see    https://github.com/nnstreamer/nnstreamer-edge
+ * @author Gichan Jang <gichan2.jang@samsung.com>
+ * @bug    No known bugs except for NYI items
+ */
+
+#include "nnstreamer-edge-custom.h"
+#include "nnstreamer-edge-log.h"
+#include "nnstreamer-edge-util.h"
+#include "nnstreamer-edge.h"
+
+typedef struct
+{
+  int is_connected;
+  char *peer_address;
+  nns_edge_event_cb event_cb;
+  void *user_data;
+} nns_edge_custom_test_s;
+
+static int
+nns_edge_custom_close (void *priv)
+{
+  if (!priv) {
+    nns_edge_loge ("Invalid param, priv should not be null.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+
+  SAFE_FREE (custom_h->peer_address);
+  SAFE_FREE (custom_h);
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static const char *
+nns_edge_custom_get_description ()
+{
+  return "custom";
+}
+
+static int
+nns_edge_custom_create (void **priv)
+{
+  if (!priv) {
+    nns_edge_loge ("Invalid param, handle should not be null.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) calloc (1, sizeof (nns_edge_custom_test_s));
+  if (!custom_h) {
+    nns_edge_loge ("Failed to allocate memory for edge custom handle.");
+    return NNS_EDGE_ERROR_OUT_OF_MEMORY;
+  }
+
+  *priv = custom_h;
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static int
+nns_edge_custom_start (void *priv)
+{
+  if (!priv) {
+    nns_edge_loge ("Invalid param, priv should not be null.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+  custom_h->is_connected = 0;
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static int
+nns_edge_custom_stop (void *priv)
+{
+  if (!priv) {
+    nns_edge_loge ("Invalid param, priv should not be null.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+  custom_h->is_connected = 0;
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static int
+nns_edge_custom_connect (void *priv)
+{
+  if (!priv) {
+    nns_edge_loge ("Invalid param, priv is NULL");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+  custom_h->is_connected = 1;
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static int
+nns_edge_custom_subscribe (void *priv)
+{
+  return NNS_EDGE_ERROR_NOT_SUPPORTED;
+}
+
+static int
+nns_edge_custom_is_connected (void *priv)
+{
+  if (!priv) {
+    nns_edge_loge ("Invalid param, handle should not be null.");
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+
+  if (custom_h->is_connected == 1)
+    return NNS_EDGE_ERROR_NONE;
+
+  return NNS_EDGE_ERROR_CONNECTION_FAILURE;
+}
+
+static int
+nns_edge_custom_set_event_cb (void *priv, nns_edge_event_cb cb, void *user_data)
+{
+  if (!priv || !cb) {
+    nns_edge_loge ("Invalid param, cb(%p)", cb);
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static int
+nns_edge_custom_send_data (void *priv, nns_edge_data_h data_h)
+{
+  if (!priv || !data_h) {
+    nns_edge_loge ("Invalid param, data_h(%p)", data_h);
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static int
+nns_edge_custom_set_option (void *priv, const char *key, const char *value)
+{
+  if (!priv || !key || !value) {
+    nns_edge_loge ("Invalid param, key(%s), value(%s)", key, value);
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+
+  if (strcasecmp (key, "PEER_ADDRESS") == 0) {
+    SAFE_FREE (custom_h->peer_address);
+    custom_h->peer_address = nns_edge_strdup (value);
+  } else {
+    nns_edge_loge ("key(%s) does not supported.", key);
+    return NNS_EDGE_ERROR_INVALID_PARAMETER;
+  }
+
+  return NNS_EDGE_ERROR_NONE;
+}
+
+static char *
+nns_edge_custom_get_option (void *priv, const char *key)
+{
+  if (!priv || !key) {
+    nns_edge_loge ("Invalid param, key(%s)", key);
+    return NULL;
+  }
+  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
+  if (strcasecmp (key, "PEER_ADDRESS") == 0)
+    return nns_edge_strdup (custom_h->peer_address);
+
+  return NULL;
+}
+
+nns_edge_custom_s edge_custom_h = {
+  .nns_edge_custom_get_description = nns_edge_custom_get_description,
+  .nns_edge_custom_create = nns_edge_custom_create,
+  .nns_edge_custom_close = nns_edge_custom_close,
+  .nns_edge_custom_start = nns_edge_custom_start,
+  .nns_edge_custom_stop = nns_edge_custom_stop,
+  .nns_edge_custom_connect = nns_edge_custom_connect,
+  .nns_edge_custom_subscribe = nns_edge_custom_subscribe,
+  .nns_edge_custom_is_connected = nns_edge_custom_is_connected,
+  .nns_edge_custom_set_event_cb = nns_edge_custom_set_event_cb,
+  .nns_edge_custom_send_data = nns_edge_custom_send_data,
+  .nns_edge_custom_set_option = nns_edge_custom_set_option,
+  .nns_edge_custom_get_option = nns_edge_custom_get_option
+};
+
+void *
+nns_edge_custom_get_instance ()
+{
+  return &edge_custom_h;
+}
diff --git a/tests/nnstreamer-edge-custom.c b/tests/nnstreamer-edge-custom.c
deleted file mode 100644 (file)
index 7dc6586..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-/**
- * Copyright (C) 2024 Gichan Jang <gichan2.jang@samsung.com>
- *
- * @file   nnstreamer-edge-custom.c
- * @date   16 Aug 2024
- * @brief  NNStreamer-edge custom connection for test.
- * @see    https://github.com/nnstreamer/nnstreamer-edge
- * @author Gichan Jang <gichan2.jang@samsung.com>
- * @bug    No known bugs except for NYI items
- */
-
-#include "nnstreamer-edge-custom.h"
-#include "nnstreamer-edge-log.h"
-#include "nnstreamer-edge-util.h"
-#include "nnstreamer-edge.h"
-
-typedef struct
-{
-  int is_connected;
-  char *peer_address;
-  nns_edge_event_cb event_cb;
-  void *user_data;
-} nns_edge_custom_test_s;
-
-static int
-nns_edge_custom_close (void *priv)
-{
-  if (!priv) {
-    nns_edge_loge ("Invalid param, priv should not be null.");
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-
-  SAFE_FREE (custom_h->peer_address);
-  SAFE_FREE (custom_h);
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static const char *
-nns_edge_custom_get_description ()
-{
-  return "custom";
-}
-
-static int
-nns_edge_custom_create (void **priv)
-{
-  if (!priv) {
-    nns_edge_loge ("Invalid param, handle should not be null.");
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) calloc (1, sizeof (nns_edge_custom_test_s));
-  if (!custom_h) {
-    nns_edge_loge ("Failed to allocate memory for edge custom handle.");
-    return NNS_EDGE_ERROR_OUT_OF_MEMORY;
-  }
-
-  *priv = custom_h;
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static int
-nns_edge_custom_start (void *priv)
-{
-  if (!priv) {
-    nns_edge_loge ("Invalid param, priv should not be null.");
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-  custom_h->is_connected = 0;
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static int
-nns_edge_custom_stop (void *priv)
-{
-  if (!priv) {
-    nns_edge_loge ("Invalid param, priv should not be null.");
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-  custom_h->is_connected = 0;
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static int
-nns_edge_custom_connect (void *priv)
-{
-  if (!priv) {
-    nns_edge_loge ("Invalid param, priv is NULL");
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-  custom_h->is_connected = 1;
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static int
-nns_edge_custom_subscribe (void *priv)
-{
-  return NNS_EDGE_ERROR_NOT_SUPPORTED;
-}
-
-static int
-nns_edge_custom_is_connected (void *priv)
-{
-  if (!priv) {
-    nns_edge_loge ("Invalid param, handle should not be null.");
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-
-  if (custom_h->is_connected == 1)
-    return NNS_EDGE_ERROR_NONE;
-
-  return NNS_EDGE_ERROR_CONNECTION_FAILURE;
-}
-
-static int
-nns_edge_custom_set_event_cb (void *priv, nns_edge_event_cb cb, void *user_data)
-{
-  if (!priv || !cb) {
-    nns_edge_loge ("Invalid param, cb(%p)", cb);
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static int
-nns_edge_custom_send_data (void *priv, nns_edge_data_h data_h)
-{
-  if (!priv || !data_h) {
-    nns_edge_loge ("Invalid param, data_h(%p)", data_h);
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static int
-nns_edge_custom_set_option (void *priv, const char *key, const char *value)
-{
-  if (!priv || !key || !value) {
-    nns_edge_loge ("Invalid param, key(%s), value(%s)", key, value);
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-
-  if (strcasecmp (key, "PEER_ADDRESS") == 0) {
-    SAFE_FREE (custom_h->peer_address);
-    custom_h->peer_address = nns_edge_strdup (value);
-  } else {
-    nns_edge_loge ("key(%s) does not supported.", key);
-    return NNS_EDGE_ERROR_INVALID_PARAMETER;
-  }
-
-  return NNS_EDGE_ERROR_NONE;
-}
-
-static char *
-nns_edge_custom_get_option (void *priv, const char *key)
-{
-  if (!priv || !key) {
-    nns_edge_loge ("Invalid param, key(%s)", key);
-    return NULL;
-  }
-  nns_edge_custom_test_s *custom_h = (nns_edge_custom_test_s *) priv;
-  if (strcasecmp (key, "PEER_ADDRESS") == 0)
-    return nns_edge_strdup (custom_h->peer_address);
-
-  return NULL;
-}
-
-nns_edge_custom_s edge_custom_h = {
-  .nns_edge_custom_get_description = nns_edge_custom_get_description,
-  .nns_edge_custom_create = nns_edge_custom_create,
-  .nns_edge_custom_close = nns_edge_custom_close,
-  .nns_edge_custom_start = nns_edge_custom_start,
-  .nns_edge_custom_stop = nns_edge_custom_stop,
-  .nns_edge_custom_connect = nns_edge_custom_connect,
-  .nns_edge_custom_subscribe = nns_edge_custom_subscribe,
-  .nns_edge_custom_is_connected = nns_edge_custom_is_connected,
-  .nns_edge_custom_set_event_cb = nns_edge_custom_set_event_cb,
-  .nns_edge_custom_send_data = nns_edge_custom_send_data,
-  .nns_edge_custom_set_option = nns_edge_custom_set_option,
-  .nns_edge_custom_get_option = nns_edge_custom_get_option
-};
-
-void *
-nns_edge_custom_get_instance ()
-{
-  return &edge_custom_h;
-}
index 1461b1ab671ff133e5d074f783aa7cbe369008d2..e9d252cfdf8c9f84e7a3daae5138dc03185c634a 100644 (file)
@@ -2082,7 +2082,6 @@ TEST(edgeData, deserializeInvalidParam04_n)
   SAFE_FREE (data);
 }
 
-
 /**
  * @brief Serialize and deserialize the edge-data.
  */
@@ -2164,7 +2163,6 @@ TEST(edgeDataSerialize, normal)
   SAFE_FREE (serialized_data);
 }
 
-
 /**
  * @brief Serialize edge-data - invalid param.
  */