From 940f7a42fbdc8df585996d6239b6899ee48d149f Mon Sep 17 00:00:00 2001 From: Jaeyun Jung Date: Mon, 13 Mar 2023 15:52:01 +0900 Subject: [PATCH] [Test] name to root directory Fix name to root directory, use prefix 'MLAPI_'. Signed-off-by: Jaeyun Jung --- debian/rules | 2 + packaging/machine-learning-api.spec | 3 + tests/capi/unittest_capi_inference.cc | 14 ++--- tests/capi/unittest_capi_inference_latency.cc | 2 +- tests/capi/unittest_capi_inference_nnfw_runtime.cc | 2 +- tests/capi/unittest_capi_inference_single.cc | 70 +++++++++++----------- tests/meson.build | 4 +- 7 files changed, 51 insertions(+), 46 deletions(-) diff --git a/debian/rules b/debian/rules index 3a00c01..413303c 100755 --- a/debian/rules +++ b/debian/rules @@ -16,6 +16,8 @@ ROOT_DIR:=$(shell pwd) export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) export BUILDDIR=build +export MLAPI_SOURCE_ROOT_PATH=$(ROOT_DIR) +export MLAPI_BUILD_ROOT_PATH=${MLAPI_SOURCE_ROOT_PATH}/${BUILDDIR} export JAVA_DIR ?= $(shell echo 'System.out.println(java.lang.System.getProperty("java.home"));' | jshell -) %: diff --git a/packaging/machine-learning-api.spec b/packaging/machine-learning-api.spec index c5fc8ab..9dc4674 100644 --- a/packaging/machine-learning-api.spec +++ b/packaging/machine-learning-api.spec @@ -364,6 +364,9 @@ meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir ninja -C build %{?_smp_mflags} +export MLAPI_SOURCE_ROOT_PATH=$(pwd) +export MLAPI_BUILD_ROOT_PATH=$(pwd)/%{builddir} + # Run test %if 0%{?unit_test} bash %{test_script} ./tests/capi/unittest_capi_inference_single diff --git a/tests/capi/unittest_capi_inference.cc b/tests/capi/unittest_capi_inference.cc index f83f82f..9541a95 100644 --- a/tests/capi/unittest_capi_inference.cc +++ b/tests/capi/unittest_capi_inference.cc @@ -1451,7 +1451,7 @@ check_orange_output (const ml_tensors_data_h data, const ml_tensors_info_h info, gsize raw_content_len; gchar *orange_raw_file; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* supposed to run test in build directory */ if (root_path == NULL) root_path = ".."; @@ -1500,7 +1500,7 @@ TEST (nnstreamer_capi_src, pngfile) gchar *orange_png_file, *pipeline; uint8_t *content; gsize content_len; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* supposed to run test in build directory */ if (root_path == NULL) root_path = ".."; @@ -4176,7 +4176,7 @@ TEST (nnstreamer_capi_element, set_property_string_01_p) ml_pipeline_element_h filter_h = nullptr; gchar *pipeline, *test_model; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* Skip this test if enable-tensorflow-lite is false */ if (!is_enabled_tensorflow_lite) @@ -4240,7 +4240,7 @@ TEST (nnstreamer_capi_element, set_property_string_03_n) ml_pipeline_element_h filter_h = nullptr; gchar *pipeline, *test_model; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* Skip this test if enable-tensorflow-lite is false */ if (!is_enabled_tensorflow_lite) @@ -4327,7 +4327,7 @@ TEST (nnstreamer_capi_element, get_property_string_01_p) gchar *pipeline, *test_model; gchar *ret_prop; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* Skip this test if enable-tensorflow-lite is false */ if (!is_enabled_tensorflow_lite) @@ -4406,7 +4406,7 @@ TEST (nnstreamer_capi_element, get_property_string_03_n) gchar *pipeline, *test_model; gchar *ret_prop; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* Skip this test if enable-tensorflow-lite is false */ if (!is_enabled_tensorflow_lite) @@ -4457,7 +4457,7 @@ TEST (nnstreamer_capi_element, get_property_string_04_n) ml_pipeline_element_h filter_h = nullptr; gchar *pipeline, *test_model; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* Skip this test if enable-tensorflow-lite is false */ if (!is_enabled_tensorflow_lite) diff --git a/tests/capi/unittest_capi_inference_latency.cc b/tests/capi/unittest_capi_inference_latency.cc index 43a56f6..22cf9d2 100644 --- a/tests/capi/unittest_capi_inference_latency.cc +++ b/tests/capi/unittest_capi_inference_latency.cc @@ -33,7 +33,7 @@ class nnstreamer_capi_singleshot_latency : public ::testing::Test */ virtual void SetUp () { - root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); /* supposed to run test in build directory */ if (root_path == NULL) root_path = ".."; diff --git a/tests/capi/unittest_capi_inference_nnfw_runtime.cc b/tests/capi/unittest_capi_inference_nnfw_runtime.cc index 550884c..f57ecab 100644 --- a/tests/capi/unittest_capi_inference_nnfw_runtime.cc +++ b/tests/capi/unittest_capi_inference_nnfw_runtime.cc @@ -77,7 +77,7 @@ protected: ml_tensors_info_create (&out_res); /* supposed to run test in build directory */ - root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); if (root_path == NULL) { root_path = ".."; } diff --git a/tests/capi/unittest_capi_inference_single.cc b/tests/capi/unittest_capi_inference_single.cc index 713149b..ad0fd5e 100644 --- a/tests/capi/unittest_capi_inference_single.cc +++ b/tests/capi/unittest_capi_inference_single.cc @@ -40,7 +40,7 @@ TEST (nnstreamer_capi_singleshot, invoke_invalid_param_01_n) ml_tensors_info_h in_info; ml_tensors_data_h input, output; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -96,7 +96,7 @@ TEST (nnstreamer_capi_singleshot, invoke_invalid_param_02_n) ml_tensors_data_h input, output; ml_tensor_dimension in_dim; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -180,7 +180,7 @@ TEST (nnstreamer_capi_singleshot, invoke_01) char *name = NULL; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -302,7 +302,7 @@ TEST (nnstreamer_capi_singleshot, invoke_02) ml_tensors_data_h input, output; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -363,7 +363,7 @@ benchmark_single (const gboolean no_alloc, const gboolean no_timeout, const int unsigned long open_duration = 0, invoke_duration = 0, close_duration = 0; gint64 start, end; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -598,7 +598,7 @@ TEST (nnstreamer_capi_singleshot, invoke_04) void *data_ptr; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model, *test_file; gchar *contents = NULL; gsize len = 0; @@ -751,7 +751,7 @@ TEST (nnstreamer_capi_singleshot, unavailable_fw_tf_n) ml_tensor_dimension in_dim, out_dim; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -803,7 +803,7 @@ TEST (nnstreamer_capi_singleshot, open_fail_01_n) ml_single_h single; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -865,7 +865,7 @@ TEST (nnstreamer_capi_singleshot, open_fail_02_n) ml_tensor_dimension in_dim, out_dim; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -969,7 +969,7 @@ TEST (nnstreamer_capi_singleshot, open_dynamic) unsigned int count = 0; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1131,7 +1131,7 @@ TEST (nnstreamer_capi_singleshot, invoke_timeout) ml_single_h single; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1214,7 +1214,7 @@ skip_test: */ TEST (nnstreamer_capi_singleshot, parallel_runs) { - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; const gint num_threads = 3; const gint num_cases = 3; @@ -1273,7 +1273,7 @@ TEST (nnstreamer_capi_singleshot, parallel_runs) */ TEST (nnstreamer_capi_singleshot, close_while_running) { - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; pthread_t thread; single_shot_thread_data ss_data; @@ -1329,7 +1329,7 @@ TEST (nnstreamer_capi_singleshot, set_input_info_fail_01_n) ml_tensors_info_h in_info; ml_tensor_dimension in_dim; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1387,7 +1387,7 @@ TEST (nnstreamer_capi_singleshot, set_input_info_fail_02_n) unsigned int count = 0; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1453,7 +1453,7 @@ TEST (nnstreamer_capi_singleshot, set_input_info_success) ml_tensor_dimension in_dim; ml_tensors_data_h input, output; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1529,7 +1529,7 @@ TEST (nnstreamer_capi_singleshot, set_input_info_success_01) size_t data_size; float *data; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1686,7 +1686,7 @@ TEST (nnstreamer_capi_singleshot, property_01_p) void *data; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1764,7 +1764,7 @@ TEST (nnstreamer_capi_singleshot, property_02_n) int status; char *prop_value = NULL; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1839,7 +1839,7 @@ TEST (nnstreamer_capi_singleshot, property_03_n) void *data; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -1959,7 +1959,7 @@ TEST (nnstreamer_capi_singleshot, property_04_p) size_t data_size; float *data; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -2060,7 +2060,7 @@ TEST (nnstreamer_capi_singleshot, invoke_05) char *name = NULL; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -2173,7 +2173,7 @@ TEST (nnstreamer_capi_singleshot, open_dir) ml_single_h single; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -2214,7 +2214,7 @@ TEST (nnstreamer_capi_singleshot, invoke_06) void *data_ptr; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model, *test_file; guint8 *contents_uint8 = NULL; gfloat *contents_float = NULL; @@ -2385,7 +2385,7 @@ TEST (nnstreamer_capi_singleshot, invoke_07) void *data_ptr; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -2507,7 +2507,7 @@ TEST (nnstreamer_capi_singleshot, open_fail_03_n) ml_tensors_info_h in_info, out_info; ml_tensor_dimension in_dim, out_dim; int status; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -2582,7 +2582,7 @@ TEST (nnstreamer_capi_singleshot, invoke_08_n) int status; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; gfloat *contents_float = NULL; @@ -2665,7 +2665,7 @@ TEST (nnstreamer_capi_singleshot, invoke_09_n) int status; size_t data_size; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; gfloat *contents_float = NULL; @@ -3173,7 +3173,7 @@ TEST (nnstreamer_capi_singleshot, invoke_dynamic_success_01_p) ml_tensor_type_e tmp_type = ML_TENSOR_TYPE_UNKNOWN; ml_tensor_dimension tmp_dim; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -3316,7 +3316,7 @@ TEST (nnstreamer_capi_singleshot, invoke_dynamic_success_02_p) ml_tensor_type_e tmp_type = ML_TENSOR_TYPE_UNKNOWN; ml_tensor_dimension tmp_dim, in_dim; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -3461,7 +3461,7 @@ TEST (nnstreamer_capi_singleshot, invoke_dynamic_fail_n) ml_tensors_info_h in_info, out_info; ml_tensors_data_h input, output; - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -3630,7 +3630,7 @@ TEST (nnstreamer_capi_ml_option, tensorflow_lite) status = ml_option_create (&option); EXPECT_EQ (status, ML_ERROR_NONE); - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -3728,7 +3728,7 @@ TEST (nnstreamer_capi_ml_option, tensorflow1_lite) status = ml_option_create (&option); EXPECT_EQ (status, ML_ERROR_NONE); - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); gchar *test_model; /* supposed to run test in build directory */ @@ -3885,7 +3885,7 @@ skip_test: */ TEST (nnstreamer_capi_internal, validate_model_file_02_n) { - const gchar *sroot_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *sroot_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); const gchar cf_name[] = "libnnstreamer_customfilter_passthrough_variable" SO_FILE_EXTENSION; gchar *lib_path = NULL; gchar *test_model1 = NULL; @@ -3966,7 +3966,7 @@ skip_test: */ TEST (nnstreamer_capi_internal, validate_model_file_03_n) { - const gchar *root_path = g_getenv ("NNSTREAMER_SOURCE_ROOT_PATH"); + const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH"); int status; ml_nnfw_type_e nnfw; gchar *test_dir1, *test_dir2; diff --git a/tests/meson.build b/tests/meson.build index 04cd483..bbbddeb 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -4,8 +4,8 @@ unittest_install_dir = join_paths(unittest_base_dir,'tests') # Set dependency and test-env testenv = environment() -testenv.set('NNSTREAMER_SOURCE_ROOT_PATH', meson.source_root()) -testenv.set('NNSTREAMER_BUILD_ROOT_PATH', meson.build_root()) +testenv.set('MLAPI_SOURCE_ROOT_PATH', meson.source_root()) +testenv.set('MLAPI_BUILD_ROOT_PATH', meson.build_root()) gtest_dep = dependency('gtest', required: false) if gtest_dep.found() -- 2.7.4