From c3599f0a567496df9bed0c36bbb0d1a17c83e573 Mon Sep 17 00:00:00 2001 From: HyoungJoo Ahn Date: Thu, 7 May 2020 12:42:07 +0900 Subject: [PATCH] [Unittest/IIO] add the negative case: base dir testcase for the logic with invalid base dir Signed-off-by: HyoungJoo Ahn --- tests/nnstreamer_source/unittest_src_iio.cc | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/nnstreamer_source/unittest_src_iio.cc b/tests/nnstreamer_source/unittest_src_iio.cc index 18bcf20..7feaa82 100644 --- a/tests/nnstreamer_source/unittest_src_iio.cc +++ b/tests/nnstreamer_source/unittest_src_iio.cc @@ -1709,6 +1709,39 @@ TEST (test_tensor_src_iio, set_frequency_n) } /** + * @brief test the logic with invalid base dir + */ +TEST (test_tensor_src_iio, set_base_dir_n) +{ + iio_dev_dir_struct *dev0; + GstHarness *hrnss = NULL; + GstElement *src_iio = NULL; + GstStateChangeReturn status; + + /** Make device */ + dev0 = make_full_device (DATA, 16); + ASSERT_NE (dev0, nullptr); + + /** setup */ + hrnss = gst_harness_new_empty (); + ASSERT_TRUE (hrnss != NULL); + gst_harness_add_parse (hrnss, ELEMENT_NAME); + src_iio = gst_harness_find_element (hrnss, ELEMENT_NAME); + ASSERT_TRUE (src_iio != NULL); + + /** setup properties */ + g_object_set (src_iio, "iio-base-dir", "/not/existed/path", NULL); + g_object_set (src_iio, "dev-dir", dev0->dev_dir, NULL); + g_object_set (src_iio, "device", DEVICE_NAME, NULL); + + status = gst_element_set_state (src_iio, GST_STATE_PAUSED); + EXPECT_NE (status, GST_STATE_CHANGE_NO_PREROLL); + + /** teardown */ + gst_harness_teardown (hrnss); +} + +/** * @brief Main function for unit test. */ int -- 2.7.4