[fix/tests] Fix mem-leak issues in some unittests
authorYongjoo Ahn <yongjoo1.ahn@samsung.com>
Fri, 18 Feb 2022 03:19:16 +0000 (12:19 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 28 Feb 2022 05:33:00 +0000 (14:33 +0900)
- Fix minor mem-leak in lua, snpe, tvm unittests

Signed-off-by: Yongjoo Ahn <yongjoo1.ahn@samsung.com>
tests/nnstreamer_filter_lua/unittest_filter_lua.cc
tests/nnstreamer_filter_snpe/unittest_filter_snpe.cc
tests/nnstreamer_filter_tvm/unittest_filter_tvm.cc

index 82b5847..e8e5f31 100644 (file)
@@ -347,6 +347,8 @@ TEST (nnstreamerFilterLua, getModelInfo00)
   EXPECT_EQ (out_info.info[0].type, _NNS_UINT8);
 
   sp->close (&prop, &data);
+  gst_tensors_info_free (&in_info);
+  gst_tensors_info_free (&out_info);
   g_free (model_file);
 }
 
@@ -523,7 +525,7 @@ TEST (nnstreamerFilterLua, invoke02_n)
   output.data = g_malloc (output.size);
   ((float *) input.data)[0] = 10.0;
 
-  /* unsucessful invoke with NULL priv_data */
+  /* unsuccessful invoke with NULL priv_data */
   ret = sp->invoke (NULL, NULL, NULL, &input, &output);
   EXPECT_NE (ret, 0);
 
@@ -719,7 +721,7 @@ TEST (nnstreamerFilterLua, reload00)
 
   gchar *model_file2 = g_build_filename (
       root_path, "tests", "test_models", "models", "scaler.lua", NULL);
-  ASSERT_TRUE (g_file_test (model_file, G_FILE_TEST_EXISTS));
+  ASSERT_TRUE (g_file_test (model_file2, G_FILE_TEST_EXISTS));
 
   const gchar *model_files2[] = {
     model_file2,
@@ -790,6 +792,7 @@ TEST (nnstreamerFilterLua, reload00)
 
 
   g_free (model_file);
+  g_free (model_file2);
   g_free (input.data);
   g_free (output.data);
   sp->close (&prop, &data);
index 1c20c48..7acd1f6 100644 (file)
@@ -93,6 +93,8 @@ TEST (nnstreamerFilterSnpe, getModelInfo00)
   EXPECT_EQ (out_info.info[0].type, _NNS_FLOAT32);
 
   sp->close (&prop, &data);
+  gst_tensors_info_free (&in_info);
+  gst_tensors_info_free (&out_info);
   g_free (model_file);
 }
 
index 19ec196..9a7496c 100644 (file)
@@ -14,6 +14,7 @@
 #include <gst/gst.h>
 #include <unittest_util.h>
 
+#include <tensor_common.h>
 #include <nnstreamer_plugin_api_filter.h>
 #include <nnstreamer_util.h>
 
@@ -178,6 +179,8 @@ TEST (nnstreamerFilterTvm, getModelInfo00)
   EXPECT_EQ (out_info.info[0].type, _NNS_FLOAT32);
 
   sp->close (&prop, &data);
+  gst_tensors_info_free (&in_info);
+  gst_tensors_info_free (&out_info);
   g_free (model_file);
 }