From 3b724d29b03c48ea190004b056a59fd7680d96b1 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 13 Mar 2019 11:33:10 +0900 Subject: [PATCH] [Tizen/API] Add unittest skeleton for Tizen-CAPI (TCT candidate) This is to be the basis of TCT (Tizen Compliance Test) in the future. Testing construction & destruction of nnstreamer pipelines with different elements. Signed-off-by: MyungJoo Ham --- packaging/nnstreamer.spec | 1 + tests/meson.build | 5 +++ tests/tizen_capi/meson.build | 13 ++++++ tests/tizen_capi/unittest_tizen_capi.cpp | 69 ++++++++++++++++++++++++++++++++ tizen-api/meson.build | 9 ++++- 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 tests/tizen_capi/meson.build create mode 100644 tests/tizen_capi/unittest_tizen_capi.cpp diff --git a/packaging/nnstreamer.spec b/packaging/nnstreamer.spec index 14adbec..d045a29 100644 --- a/packaging/nnstreamer.spec +++ b/packaging/nnstreamer.spec @@ -176,6 +176,7 @@ ninja -C build %{?_smp_mflags} ./tests/unittest_common ./tests/unittest_sink --gst-plugin-path=. ./tests/unittest_plugins --gst-plugin-path=. + LD_LIBRARY_PATH=tizen-api ./tests/tizen_capi/unittest_tizen_capi --gst-plugin-path=. popd pushd tests ssat -n diff --git a/tests/meson.build b/tests/meson.build index b651dc5..1f9fb4a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -87,3 +87,8 @@ if gtest_dep.found() test('unittest_plugins', unittest_plugins, args: ['--gst-plugin-path=..']) endif + +# Tizen C-API +if get_option('enable-tizen-capi') + subdir('tizen_capi') +endif diff --git a/tests/tizen_capi/meson.build b/tests/tizen_capi/meson.build new file mode 100644 index 0000000..b69c5ec --- /dev/null +++ b/tests/tizen_capi/meson.build @@ -0,0 +1,13 @@ +tizen_apptest_deps = [ + capi_base_common_dep, + dlog_dep, + tizen_capi_dep, + gtest_dep +] + +unittest_tizen_capi = executable('unittest_tizen_capi', + 'unittest_tizen_capi.cpp', + dependencies: [tizen_apptest_deps], + install: false +) +test('unittest_tizen_capi', unittest_tizen_capi, args: ['--gst-plugin-path=../..']) diff --git a/tests/tizen_capi/unittest_tizen_capi.cpp b/tests/tizen_capi/unittest_tizen_capi.cpp new file mode 100644 index 0000000..3ba9570 --- /dev/null +++ b/tests/tizen_capi/unittest_tizen_capi.cpp @@ -0,0 +1,69 @@ +/** + * @file unittest_tizen_capi.cpp + * @date 13 Mar 2019 + * @brief Unit test for Tizen CAPI of NNStreamer. Basis of TCT in the future. + * @see https://github.com/nnsuite/nnstreamer + * @author MyungJoo Ham + * @bug No known bugs + */ + +#include +#include + +/** + * @brief Test NNStreamer pipeline construct & destruct + */ +TEST (nnstreamer_capi_construct_destruct, dummy_01) +{ + const char *pipeline = "videotestsrc num_buffers=2 ! fakesink"; + nns_pipeline_h handle; + int status = nns_pipeline_construct (pipeline, &handle); + + EXPECT_EQ (status, NNS_ERROR_NONE); + + status = nns_pipeline_destroy (handle); + + EXPECT_EQ (status, NNS_ERROR_NONE); +} + +/** + * @brief Test NNStreamer pipeline construct & destruct + */ +TEST (nnstreamer_capi_construct_destruct, dummy_02) +{ + const char *pipeline = "videotestsrc num_buffers=2 ! videoconvert ! videoscale ! video/x-raw,format=RGBx,width=224,height=224 ! tensor_converter ! fakesink"; + nns_pipeline_h handle; + int status = nns_pipeline_construct (pipeline, &handle); + + EXPECT_EQ (status, NNS_ERROR_NONE); + + status = nns_pipeline_destroy (handle); + + EXPECT_EQ (status, NNS_ERROR_NONE); +} + +/** + * @brief Test NNStreamer pipeline construct & destruct + */ +TEST (nnstreamer_capi_construct_destruct, dummy_03) +{ + const char *pipeline = "videotestsrc num_buffers=2 ! videoconvert ! videoscale ! video/x-raw,format=RGBx,width=224,height=224 ! tensor_converter ! valve name=valvex ! tensor_sink name=sinkx"; + nns_pipeline_h handle; + int status = nns_pipeline_construct (pipeline, &handle); + + EXPECT_EQ (status, NNS_ERROR_NONE); + + status = nns_pipeline_destroy (handle); + + EXPECT_EQ (status, NNS_ERROR_NONE); +} + +/** + * @brief Main gtest + */ +int main (int argc, char **argv) +{ + testing::InitGoogleTest (&argc, argv); + + return RUN_ALL_TESTS (); +} diff --git a/tizen-api/meson.build b/tizen-api/meson.build index 8d4b7b1..5d896c1 100644 --- a/tizen-api/meson.build +++ b/tizen-api/meson.build @@ -39,7 +39,7 @@ tizen_deps = [ ] gst_app_dep = dependency('gstreamer-app-1.0') -shared_library ('capi-nnstreamer', +tizen_capi_lib = shared_library ('capi-nnstreamer', capi_main, dependencies: [nnstreamer_dep, glib_dep, gst_dep, gst_app_dep, tizen_deps], include_directories: [ @@ -61,6 +61,13 @@ static_library ('capi-nnstreamer', install_dir: nnstreamer_libdir, ) +tizen_capi_dep = declare_dependency(link_with: tizen_capi_lib, + include_directories: [ + inc, + nninc + ] +) + configure_file(input: 'capi-nnstreamer.pc.in', output: 'capi-nnstreamer.pc', install: true, install_dir: join_paths(nnstreamer_libdir, 'pkgconfig'), -- 2.7.4