[Tensor Decoder] Add test case
authorjijoong.moon <jijoong.moon@samsung.com>
Tue, 12 Jun 2018 07:57:25 +0000 (16:57 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Thu, 14 Jun 2018 07:43:47 +0000 (16:43 +0900)
Add test case for Tensor Decoder. Currently test case which width is
not divided by 4 is not supported.

- Add RGB 640x480

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
common/test/unittest_common.cpp
packaging/nnstreamer.spec
packaging/testcase_tensor_decoder.tar.gz [new file with mode: 0644]
tensor_converter/tensor_converter.c
tensor_decoder/tensordec.c
tensor_filter/tensor_filter.c
tensor_filter/tensor_filter_tensorflow_lite.c
tests/nnstreamer_decoder/.gitignore [new file with mode: 0644]
tests/nnstreamer_decoder/generateGoldenTestResult.py [new file with mode: 0755]
tests/nnstreamer_decoder/runTest.sh [new file with mode: 0755]
tests/testAPI.sh

index d3a0446..3cf59dc 100644 (file)
 #include <unistd.h>
 #include <tensor_common.h>
 
-TEST(common_get_tensor_type, int32_1) {
-  EXPECT_EQ(get_tensor_type("int32"), _NNS_INT32);
+TEST (common_get_tensor_type, int32_1)
+{
+  EXPECT_EQ (get_tensor_type ("int32"), _NNS_INT32);
 }
-TEST(common_get_tensor_type, int32_2) {
-  EXPECT_EQ(get_tensor_type("INT32"), _NNS_INT32);
+
+TEST (common_get_tensor_type, int32_2)
+{
+  EXPECT_EQ (get_tensor_type ("INT32"), _NNS_INT32);
 }
-TEST(common_get_tensor_type, int32_3) {
-  EXPECT_EQ(get_tensor_type("iNt32"), _NNS_INT32);
+
+TEST (common_get_tensor_type, int32_3)
+{
+  EXPECT_EQ (get_tensor_type ("iNt32"), _NNS_INT32);
 }
-TEST(common_get_tensor_type, int32_4) {
-  EXPECT_EQ(get_tensor_type("InT32"), _NNS_INT32);
+
+TEST (common_get_tensor_type, int32_4)
+{
+  EXPECT_EQ (get_tensor_type ("InT32"), _NNS_INT32);
 }
-TEST(common_get_tensor_type, int32_5) {
-  EXPECT_EQ(get_tensor_type("InT322"), _NNS_END);
+
+TEST (common_get_tensor_type, int32_5)
+{
+  EXPECT_EQ (get_tensor_type ("InT322"), _NNS_END);
 }
-TEST(common_get_tensor_type, int32_6) {
-  EXPECT_EQ(get_tensor_type("int3"), _NNS_END);
+
+TEST (common_get_tensor_type, int32_6)
+{
+  EXPECT_EQ (get_tensor_type ("int3"), _NNS_END);
 }
 
 
-TEST(common_get_tensor_type, int16_1) {
-  EXPECT_EQ(get_tensor_type("int16"), _NNS_INT16);
+TEST (common_get_tensor_type, int16_1)
+{
+  EXPECT_EQ (get_tensor_type ("int16"), _NNS_INT16);
 }
-TEST(common_get_tensor_type, int16_2) {
-  EXPECT_EQ(get_tensor_type("INT16"), _NNS_INT16);
+
+TEST (common_get_tensor_type, int16_2)
+{
+  EXPECT_EQ (get_tensor_type ("INT16"), _NNS_INT16);
 }
-TEST(common_get_tensor_type, int16_3) {
-  EXPECT_EQ(get_tensor_type("iNt16"), _NNS_INT16);
+
+TEST (common_get_tensor_type, int16_3)
+{
+  EXPECT_EQ (get_tensor_type ("iNt16"), _NNS_INT16);
 }
-TEST(common_get_tensor_type, int16_4) {
-  EXPECT_EQ(get_tensor_type("InT16"), _NNS_INT16);
+
+TEST (common_get_tensor_type, int16_4)
+{
+  EXPECT_EQ (get_tensor_type ("InT16"), _NNS_INT16);
 }
-TEST(common_get_tensor_type, int16_5) {
-  EXPECT_EQ(get_tensor_type("InT162"), _NNS_END);
+
+TEST (common_get_tensor_type, int16_5)
+{
+  EXPECT_EQ (get_tensor_type ("InT162"), _NNS_END);
 }
-TEST(common_get_tensor_type, int16_6) {
-  EXPECT_EQ(get_tensor_type("int1"), _NNS_END);
+
+TEST (common_get_tensor_type, int16_6)
+{
+  EXPECT_EQ (get_tensor_type ("int1"), _NNS_END);
 }
 
 
-TEST(common_get_tensor_type, int8_1) {
-  EXPECT_EQ(get_tensor_type("int8"), _NNS_INT8);
+TEST (common_get_tensor_type, int8_1)
+{
+  EXPECT_EQ (get_tensor_type ("int8"), _NNS_INT8);
 }
-TEST(common_get_tensor_type, int8_2) {
-  EXPECT_EQ(get_tensor_type("INT8"), _NNS_INT8);
+
+TEST (common_get_tensor_type, int8_2)
+{
+  EXPECT_EQ (get_tensor_type ("INT8"), _NNS_INT8);
 }
-TEST(common_get_tensor_type, int8_3) {
-  EXPECT_EQ(get_tensor_type("iNt8"), _NNS_INT8);
+
+TEST (common_get_tensor_type, int8_3)
+{
+  EXPECT_EQ (get_tensor_type ("iNt8"), _NNS_INT8);
 }
-TEST(common_get_tensor_type, int8_4) {
-  EXPECT_EQ(get_tensor_type("InT8"), _NNS_INT8);
+
+TEST (common_get_tensor_type, int8_4)
+{
+  EXPECT_EQ (get_tensor_type ("InT8"), _NNS_INT8);
 }
-TEST(common_get_tensor_type, int8_5) {
-  EXPECT_EQ(get_tensor_type("InT82"), _NNS_END);
+
+TEST (common_get_tensor_type, int8_5)
+{
+  EXPECT_EQ (get_tensor_type ("InT82"), _NNS_END);
 }
-TEST(common_get_tensor_type, int8_6) {
-  EXPECT_EQ(get_tensor_type("int3"), _NNS_END);
+
+TEST (common_get_tensor_type, int8_6)
+{
+  EXPECT_EQ (get_tensor_type ("int3"), _NNS_END);
 }
 
 
-TEST(common_get_tensor_type, uint32_1) {
-  EXPECT_EQ(get_tensor_type("uint32"), _NNS_UINT32);
+TEST (common_get_tensor_type, uint32_1)
+{
+  EXPECT_EQ (get_tensor_type ("uint32"), _NNS_UINT32);
 }
-TEST(common_get_tensor_type, uint32_2) {
-  EXPECT_EQ(get_tensor_type("UINT32"), _NNS_UINT32);
+
+TEST (common_get_tensor_type, uint32_2)
+{
+  EXPECT_EQ (get_tensor_type ("UINT32"), _NNS_UINT32);
 }
-TEST(common_get_tensor_type, uint32_3) {
-  EXPECT_EQ(get_tensor_type("uiNt32"), _NNS_UINT32);
+
+TEST (common_get_tensor_type, uint32_3)
+{
+  EXPECT_EQ (get_tensor_type ("uiNt32"), _NNS_UINT32);
 }
-TEST(common_get_tensor_type, uint32_4) {
-  EXPECT_EQ(get_tensor_type("UInT32"), _NNS_UINT32);
+
+TEST (common_get_tensor_type, uint32_4)
+{
+  EXPECT_EQ (get_tensor_type ("UInT32"), _NNS_UINT32);
 }
-TEST(common_get_tensor_type, uint32_5) {
-  EXPECT_EQ(get_tensor_type("UInT322"), _NNS_END);
+
+TEST (common_get_tensor_type, uint32_5)
+{
+  EXPECT_EQ (get_tensor_type ("UInT322"), _NNS_END);
 }
-TEST(common_get_tensor_type, uint32_6) {
-  EXPECT_EQ(get_tensor_type("uint3"), _NNS_END);
+
+TEST (common_get_tensor_type, uint32_6)
+{
+  EXPECT_EQ (get_tensor_type ("uint3"), _NNS_END);
 }
 
 
-TEST(common_get_tensor_type, uint16_1) {
-  EXPECT_EQ(get_tensor_type("uint16"), _NNS_UINT16);
+TEST (common_get_tensor_type, uint16_1)
+{
+  EXPECT_EQ (get_tensor_type ("uint16"), _NNS_UINT16);
 }
-TEST(common_get_tensor_type, uint16_2) {
-  EXPECT_EQ(get_tensor_type("UINT16"), _NNS_UINT16);
+
+TEST (common_get_tensor_type, uint16_2)
+{
+  EXPECT_EQ (get_tensor_type ("UINT16"), _NNS_UINT16);
 }
-TEST(common_get_tensor_type, uint16_3) {
-  EXPECT_EQ(get_tensor_type("uiNt16"), _NNS_UINT16);
+
+TEST (common_get_tensor_type, uint16_3)
+{
+  EXPECT_EQ (get_tensor_type ("uiNt16"), _NNS_UINT16);
 }
-TEST(common_get_tensor_type, uint16_4) {
-  EXPECT_EQ(get_tensor_type("UInT16"), _NNS_UINT16);
+
+TEST (common_get_tensor_type, uint16_4)
+{
+  EXPECT_EQ (get_tensor_type ("UInT16"), _NNS_UINT16);
 }
-TEST(common_get_tensor_type, uint16_5) {
-  EXPECT_EQ(get_tensor_type("UInT162"), _NNS_END);
+
+TEST (common_get_tensor_type, uint16_5)
+{
+  EXPECT_EQ (get_tensor_type ("UInT162"), _NNS_END);
 }
-TEST(common_get_tensor_type, uint16_6) {
-  EXPECT_EQ(get_tensor_type("uint1"), _NNS_END);
+
+TEST (common_get_tensor_type, uint16_6)
+{
+  EXPECT_EQ (get_tensor_type ("uint1"), _NNS_END);
 }
 
 
-TEST(common_get_tensor_type, uint8_1) {
-  EXPECT_EQ(get_tensor_type("uint8"), _NNS_UINT8);
+TEST (common_get_tensor_type, uint8_1)
+{
+  EXPECT_EQ (get_tensor_type ("uint8"), _NNS_UINT8);
 }
-TEST(common_get_tensor_type, uint8_2) {
-  EXPECT_EQ(get_tensor_type("UINT8"), _NNS_UINT8);
+
+TEST (common_get_tensor_type, uint8_2)
+{
+  EXPECT_EQ (get_tensor_type ("UINT8"), _NNS_UINT8);
 }
-TEST(common_get_tensor_type, uint8_3) {
-  EXPECT_EQ(get_tensor_type("uiNt8"), _NNS_UINT8);
+
+TEST (common_get_tensor_type, uint8_3)
+{
+  EXPECT_EQ (get_tensor_type ("uiNt8"), _NNS_UINT8);
 }
-TEST(common_get_tensor_type, uint8_4) {
-  EXPECT_EQ(get_tensor_type("UInT8"), _NNS_UINT8);
+
+TEST (common_get_tensor_type, uint8_4)
+{
+  EXPECT_EQ (get_tensor_type ("UInT8"), _NNS_UINT8);
 }
-TEST(common_get_tensor_type, uint8_5) {
-  EXPECT_EQ(get_tensor_type("UInT82"), _NNS_END);
+
+TEST (common_get_tensor_type, uint8_5)
+{
+  EXPECT_EQ (get_tensor_type ("UInT82"), _NNS_END);
 }
-TEST(common_get_tensor_type, uint8_6) {
-  EXPECT_EQ(get_tensor_type("uint3"), _NNS_END);
+
+TEST (common_get_tensor_type, uint8_6)
+{
+  EXPECT_EQ (get_tensor_type ("uint3"), _NNS_END);
 }
 
 
-TEST(common_get_tensor_type, float32_1) {
-  EXPECT_EQ(get_tensor_type("float32"), _NNS_FLOAT32);
+TEST (common_get_tensor_type, float32_1)
+{
+  EXPECT_EQ (get_tensor_type ("float32"), _NNS_FLOAT32);
 }
-TEST(common_get_tensor_type, float32_2) {
-  EXPECT_EQ(get_tensor_type("FLOAT32"), _NNS_FLOAT32);
+
+TEST (common_get_tensor_type, float32_2)
+{
+  EXPECT_EQ (get_tensor_type ("FLOAT32"), _NNS_FLOAT32);
 }
-TEST(common_get_tensor_type, float32_3) {
-  EXPECT_EQ(get_tensor_type("float32"), _NNS_FLOAT32);
+
+TEST (common_get_tensor_type, float32_3)
+{
+  EXPECT_EQ (get_tensor_type ("float32"), _NNS_FLOAT32);
 }
-TEST(common_get_tensor_type, float32_4) {
-  EXPECT_EQ(get_tensor_type("FloaT32"), _NNS_FLOAT32);
+
+TEST (common_get_tensor_type, float32_4)
+{
+  EXPECT_EQ (get_tensor_type ("FloaT32"), _NNS_FLOAT32);
 }
-TEST(common_get_tensor_type, float32_5) {
-  EXPECT_EQ(get_tensor_type("FloaT322"), _NNS_END);
+
+TEST (common_get_tensor_type, float32_5)
+{
+  EXPECT_EQ (get_tensor_type ("FloaT322"), _NNS_END);
 }
-TEST(common_get_tensor_type, float32_6) {
-  EXPECT_EQ(get_tensor_type("float3"), _NNS_END);
+
+TEST (common_get_tensor_type, float32_6)
+{
+  EXPECT_EQ (get_tensor_type ("float3"), _NNS_END);
 }
 
 
 
-TEST(common_get_tensor_type, float64_1) {
-  EXPECT_EQ(get_tensor_type("float64"), _NNS_FLOAT64);
+TEST (common_get_tensor_type, float64_1)
+{
+  EXPECT_EQ (get_tensor_type ("float64"), _NNS_FLOAT64);
 }
-TEST(common_get_tensor_type, float64_2) {
-  EXPECT_EQ(get_tensor_type("FLOAT64"), _NNS_FLOAT64);
+
+TEST (common_get_tensor_type, float64_2)
+{
+  EXPECT_EQ (get_tensor_type ("FLOAT64"), _NNS_FLOAT64);
 }
-TEST(common_get_tensor_type, float64_3) {
-  EXPECT_EQ(get_tensor_type("float64"), _NNS_FLOAT64);
+
+TEST (common_get_tensor_type, float64_3)
+{
+  EXPECT_EQ (get_tensor_type ("float64"), _NNS_FLOAT64);
 }
-TEST(common_get_tensor_type, float64_4) {
-  EXPECT_EQ(get_tensor_type("FloaT64"), _NNS_FLOAT64);
+
+TEST (common_get_tensor_type, float64_4)
+{
+  EXPECT_EQ (get_tensor_type ("FloaT64"), _NNS_FLOAT64);
 }
-TEST(common_get_tensor_type, float64_5) {
-  EXPECT_EQ(get_tensor_type("FloaT642"), _NNS_END);
+
+TEST (common_get_tensor_type, float64_5)
+{
+  EXPECT_EQ (get_tensor_type ("FloaT642"), _NNS_END);
 }
-TEST(common_get_tensor_type, float64_6) {
-  EXPECT_EQ(get_tensor_type("float6"), _NNS_END);
+
+TEST (common_get_tensor_type, float64_6)
+{
+  EXPECT_EQ (get_tensor_type ("float6"), _NNS_END);
 }
 
 
-static const gcharteststrv[] = {
+static const gchar *teststrv[] = {
   "abcde",
   "ABCDEF",
   "1234",
@@ -182,65 +270,81 @@ static const gchar* teststrv[] = {
   "tester",
   NULL
 };
-TEST(common_find_key_strv, case1) {
-  EXPECT_EQ(find_key_strv(teststrv, "abcde"), 0);
+
+TEST (common_find_key_strv, case1)
+{
+  EXPECT_EQ (find_key_strv (teststrv, "abcde"), 0);
 }
-TEST(common_find_key_strv, case2) {
-  EXPECT_EQ(find_key_strv(teststrv, "ABCDE"), 0);
+
+TEST (common_find_key_strv, case2)
+{
+  EXPECT_EQ (find_key_strv (teststrv, "ABCDE"), 0);
 }
-TEST(common_find_key_strv, case3) {
-  EXPECT_EQ(find_key_strv(teststrv, "1234"), 2);
+
+TEST (common_find_key_strv, case3)
+{
+  EXPECT_EQ (find_key_strv (teststrv, "1234"), 2);
 }
-TEST(common_find_key_strv, case4) {
-  EXPECT_EQ(find_key_strv(teststrv, "tester"), 4);
+
+TEST (common_find_key_strv, case4)
+{
+  EXPECT_EQ (find_key_strv (teststrv, "tester"), 4);
 }
-TEST(common_find_key_strv, case5) {
-  EXPECT_EQ(find_key_strv(teststrv, "abcabcd"), -1);
+
+TEST (common_find_key_strv, case5)
+{
+  EXPECT_EQ (find_key_strv (teststrv, "abcabcd"), -1);
 }
 
 
-TEST(common_get_tensor_dimension, case1) {
+TEST (common_get_tensor_dimension, case1)
+{
   uint32_t dim[NNS_TENSOR_RANK_LIMIT];
-  int rank = get_tensor_dimension("345:123:433:177", dim);
-  EXPECT_EQ(rank, 4);
-  EXPECT_EQ(dim[0], 345);
-  EXPECT_EQ(dim[1], 123);
-  EXPECT_EQ(dim[2], 433);
-  EXPECT_EQ(dim[3], 177);
+  int rank = get_tensor_dimension ("345:123:433:177", dim);
+  EXPECT_EQ (rank, 4);
+  EXPECT_EQ (dim[0], 345);
+  EXPECT_EQ (dim[1], 123);
+  EXPECT_EQ (dim[2], 433);
+  EXPECT_EQ (dim[3], 177);
 }
 
 
-TEST(common_get_tensor_dimension, case2) {
+TEST (common_get_tensor_dimension, case2)
+{
   uint32_t dim[NNS_TENSOR_RANK_LIMIT];
-  int rank = get_tensor_dimension("345:123:433", dim);
-  EXPECT_EQ(rank, 3);
-  EXPECT_EQ(dim[0], 345);
-  EXPECT_EQ(dim[1], 123);
-  EXPECT_EQ(dim[2], 433);
-  EXPECT_EQ(dim[3], 1);
+  int rank = get_tensor_dimension ("345:123:433", dim);
+  EXPECT_EQ (rank, 3);
+  EXPECT_EQ (dim[0], 345);
+  EXPECT_EQ (dim[1], 123);
+  EXPECT_EQ (dim[2], 433);
+  EXPECT_EQ (dim[3], 1);
 }
 
-TEST(common_get_tensor_dimension, case3) {
+TEST (common_get_tensor_dimension, case3)
+{
   uint32_t dim[NNS_TENSOR_RANK_LIMIT];
-  int rank = get_tensor_dimension("345:123", dim);
-  EXPECT_EQ(rank, 2);
-  EXPECT_EQ(dim[0], 345);
-  EXPECT_EQ(dim[1], 123);
-  EXPECT_EQ(dim[2], 1);
-  EXPECT_EQ(dim[3], 1);
+  int rank = get_tensor_dimension ("345:123", dim);
+  EXPECT_EQ (rank, 2);
+  EXPECT_EQ (dim[0], 345);
+  EXPECT_EQ (dim[1], 123);
+  EXPECT_EQ (dim[2], 1);
+  EXPECT_EQ (dim[3], 1);
 }
 
-TEST(common_get_tensor_dimension, case4) {
+TEST (common_get_tensor_dimension, case4)
+{
   uint32_t dim[NNS_TENSOR_RANK_LIMIT];
-  int rank = get_tensor_dimension("345", dim);
-  EXPECT_EQ(rank, 1);
-  EXPECT_EQ(dim[0], 345);
-  EXPECT_EQ(dim[1], 1);
-  EXPECT_EQ(dim[2], 1);
-  EXPECT_EQ(dim[3], 1);
+  int rank = get_tensor_dimension ("345", dim);
+  EXPECT_EQ (rank, 1);
+  EXPECT_EQ (dim[0], 345);
+  EXPECT_EQ (dim[1], 1);
+  EXPECT_EQ (dim[2], 1);
+  EXPECT_EQ (dim[3], 1);
 }
 
-int main(int argc, char **argv) {
-  testing::InitGoogleTest(&argc, argv);
-  return RUN_ALL_TESTS();
+int
+main (int argc, char **argv)
+{
+  testing::InitGoogleTest (&argc, argv);
+  return RUN_ALL_TESTS ();
 }
index f6d532f..2c849fd 100644 (file)
@@ -10,6 +10,7 @@ License:      LGPL-2.1+ and Apache-2.0
 Source0:       nnstreamer-%{version}.tar.gz
 Source1001:    nnstreamer.manifest
 Source2001:    testcase_tensor_converter.tar.gz
+Source2002:    testcase_tensor_decoder.tar.gz
 
 Requires:      gstreamer >= 1.8.0
 Requires:      libdlog
@@ -74,6 +75,9 @@ pushd tests
 pushd nnstreamer_converter
 tar -xf %{SOURCE2001}
 popd
+pushd nnstreamer_decoder
+tar -xf %{SOURCE2002}
+popd
 export SKIPGEN=YES
 ./testAll.sh
 popd
diff --git a/packaging/testcase_tensor_decoder.tar.gz b/packaging/testcase_tensor_decoder.tar.gz
new file mode 100644 (file)
index 0000000..4414ec9
Binary files /dev/null and b/packaging/testcase_tensor_decoder.tar.gz differ
index 2101a31..81f2f03 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
  * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
  * Copyright (C) 2018 MyungJoo Ham <myungjoo.ham@samsung.com>
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
@@ -66,7 +66,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif
 
 #include <string.h>
index 09aee4c..a5f6fcd 100644 (file)
@@ -66,7 +66,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif
 
 #include <string.h>
index eb76792..a755334 100644 (file)
@@ -73,7 +73,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif
 
 #include <gst/gst.h>
@@ -433,8 +433,7 @@ gst_tensor_filter_set_property (GObject * object, guint prop_id,
       g_assert (filter->inputConfigured == FALSE && value);
       /* Once configures, it cannot be changed in runtime */
       {
-        int rank =
-            get_tensor_dimension (g_value_get_string (value),
+        int rank = get_tensor_dimension (g_value_get_string (value),
             filter->inputDimension);
         g_assert (rank > 0 && rank <= NNS_TENSOR_RANK_LIMIT);
         filter->inputConfigured = TRUE;
@@ -450,8 +449,7 @@ gst_tensor_filter_set_property (GObject * object, guint prop_id,
       g_assert (filter->outputConfigured == FALSE && value);
       /* Once configures, it cannot be changed in runtime */
       {
-        int rank =
-            get_tensor_dimension (g_value_get_string (value),
+        int rank = get_tensor_dimension (g_value_get_string (value),
             filter->outputDimension);
         g_assert (rank > 0 && rank <= NNS_TENSOR_RANK_LIMIT);
         filter->outputConfigured = TRUE;
index ecdb41a..5713703 100644 (file)
@@ -60,7 +60,7 @@
 static int
 tflite_invoke (GstTensor_Filter * filter, uint8_t * inptr, uint8_t * outptr)
 {
-  return 0;                    /* NYI */
+  return 0;                     /* NYI */
 }
 
 /**
@@ -82,7 +82,7 @@ tflite_getOutputDim (GstTensor_Filter * filter, uint32_t * outputDimension,
     tensor_type * type)
 {
   /* @TODO fill in *outputDimension (uint32_t[MAX_RANK]), *type */
-  return 0;                    /* NYI */
+  return 0;                     /* NYI */
 }
 
 GstTensor_Filter_Framework NNS_support_tensorflow_lite = {
diff --git a/tests/nnstreamer_decoder/.gitignore b/tests/nnstreamer_decoder/.gitignore
new file mode 100644 (file)
index 0000000..e2b85d5
--- /dev/null
@@ -0,0 +1,4 @@
+*.log
+*.tensor
+*.png
+*.raw
diff --git a/tests/nnstreamer_decoder/generateGoldenTestResult.py b/tests/nnstreamer_decoder/generateGoldenTestResult.py
new file mode 100755 (executable)
index 0000000..86572b0
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+
+##
+# Copyright (C) 2018 Samsung Electronics
+# License: Apache-2.0
+#
+# @file generateGoldenTestResult.py
+# @brief Generate golden test results for test cases
+# @author Jijoong Moon <jijoong.moon@samsung.com>
+#
+
+from __future__ import print_function
+
+from struct import *
+from PIL import Image
+import random
+
+##
+# @brief Generate Golden Test Case 01, a randomly generated PNG image
+# @return (string, string_size, expected_size)
+#
+def genCase01_PNG_random(colorType, width, height):
+    string = ""
+    string_size = 0
+    sizePerPixel = 3
+    if (colorType == 'BGRx'):
+        sizePerPixel = 4
+    expected_size = width * height * sizePerPixel
+    img = Image.new('RGB', (width, height))
+    imgbin = []
+
+    # The result has no stride for other/tensor types.
+
+    if (colorType == 'BGRx'):
+        for y in range(0, height):
+            for x in range(0, width):
+                pval = (random.randrange(256), random.randrange(256), random.randrange(256))
+                pixel = pack('BBBB', pval[2], pval[1], pval[0], 255)
+                string += pixel
+                imgbin.append(pval)
+                string_size += 4
+    else:
+        # Assume RGB
+        for y in range(0, height):
+            for x in range(0, width):
+                pval = (random.randrange(256), random.randrange(256), random.randrange(256))
+                pixel = pack('BBB', pval[0], pval[1], pval[2])
+                string += pixel
+                imgbin.append(pval)
+                string_size += 3
+
+    img.putdata(imgbin)
+    img.save('testcase01_'+colorType+'_'+str(width)+'x'+str(height)+'.png')
+    return (string, string_size, expected_size)
+
+##
+# @brief Write the generated data
+#
+genCase01_PNG_random('RGB', 640, 480)
+genCase01_PNG_random('BGRx', 640, 480)
+genCase01_PNG_random('RGB', 642, 480)
+genCase01_PNG_random('BGRx', 642, 480)
diff --git a/tests/nnstreamer_decoder/runTest.sh b/tests/nnstreamer_decoder/runTest.sh
new file mode 100755 (executable)
index 0000000..906dc3d
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+source ../testAPI.sh
+
+if [ "$SKIPGEN" == "YES" ]
+then
+  echo "Test Case Generation Skipped"
+  sopath=$2
+else
+  echo "Test Case Generation Started"
+  python generateGoldenTestResult.py
+  sopath=$1
+fi
+
+function do_test {
+    param="${4}_gen_golden_data"
+    gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=testcase01_${1}_${2}x${3}.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=${1},width=${2},height=${3},framerate=0/1 ! filesink location=\"testcase01_${1}_${2}x${3}.golden.raw\" sync=true" $param
+
+    gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=testcase01_${1}_${2}x${3}.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=${1},width=${2},height=${3},framerate=0/1 ! tensor_converter ! tensordec ! filesink location=\"testcase01_${1}_${2}x${3}.log\" sync=true" ${4}
+
+    compareAllSizeLimit testcase01_${1}_${2}x${3}.log testcase01_${1}_${2}x${3}.golden.raw ${4}
+}
+
+do_test RGB 640 480 1
+
+report
+
index 985c396..88d7609 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 if [[ $# -eq 0 ]]; then
-       PATH_TO_PLUGIN="$PWD/../build/tensor_converter:$PWD/../build/tensor_filter"
+       PATH_TO_PLUGIN="$PWD/../build/tensor_converter:$PWD/../build/tensor_filter:$PWD/../build/tensor_decoder"
 else
        PATH_TO_PLUGIN="$1"
 fi