%attr(755,root,root) %{_bindir}/wifi-aware-test
%attr(755,root,root) %{_bindir}/wifi-aware-publish-test
%attr(755,root,root) %{_bindir}/wifi-aware-subscribe-test
+%attr(755,root,root) %{_bindir}/wifi-aware-publish-matching-filter-test
+%attr(755,root,root) %{_bindir}/wifi-aware-subscribe-matching-filter-test
%files cts-verifier
#%manifest wifi-aware-test.manifest
INSTALL(TARGETS wifi-aware-test RUNTIME DESTINATION ${BIN_DIR})
INSTALL(TARGETS wifi-aware-publish-test RUNTIME DESTINATION ${BIN_DIR})
INSTALL(TARGETS wifi-aware-subscribe-test RUNTIME DESTINATION ${BIN_DIR})
+INSTALL(TARGETS wifi-aware-publish-matching-filter-test RUNTIME DESTINATION ${BIN_DIR})
+INSTALL(TARGETS wifi-aware-subscribe-matching-filter-test RUNTIME DESTINATION ${BIN_DIR})
--- /dev/null
+/*
+ * Wi-Fi Aware Test Program
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __WIFI_AWARE_MATCHING_FILTER_TEST_H__
+#define __WIFI_AWARE_MATCHING_FILTER_TEST_H__
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ DUMMY_TEST_NUM = 0,
+
+ // Sol / Active
+ POSITIVE_TEST_01,
+ POSITIVE_TEST_02,
+ POSITIVE_TEST_03,
+ POSITIVE_TEST_04,
+
+ POSITIVE_TEST_05,
+ POSITIVE_TEST_06,
+ POSITIVE_TEST_07,
+
+ POSITIVE_TEST_08,
+ POSITIVE_TEST_09,
+ POSITIVE_TEST_10,
+
+ // Unsol / Passive
+ POSITIVE_TEST_11,
+ POSITIVE_TEST_12,
+ POSITIVE_TEST_13,
+ POSITIVE_TEST_14,
+
+ POSITIVE_TEST_15,
+ POSITIVE_TEST_16,
+ POSITIVE_TEST_17,
+
+ POSITIVE_TEST_18,
+ POSITIVE_TEST_19,
+ POSITIVE_TEST_20,
+
+ ///// custom ///
+ POSITIVE_TEST_21,
+ POSITIVE_TEST_22,
+ POSITIVE_TEST_23,
+ POSITIVE_TEST_24,
+
+ POSITIVE_TEST_25,
+ POSITIVE_TEST_26,
+ POSITIVE_TEST_27,
+
+ POSITIVE_TEST_28,
+ POSITIVE_TEST_29,
+ POSITIVE_TEST_30,
+
+ // Sol / Active
+ NEGATIVE_TEST_01,
+ NEGATIVE_TEST_02,
+ NEGATIVE_TEST_03,
+
+ // Unsol / Passive
+ NEGATIVE_TEST_04,
+ NEGATIVE_TEST_05,
+ NEGATIVE_TEST_06,
+
+ //// custom
+ NEGATIVE_TEST_07,
+ NEGATIVE_TEST_08,
+ NEGATIVE_TEST_09,
+
+ INVALID,
+}test_case_e;
+
+#define RESET_COLOR "\e[m"
+#define MAKE_RED "\e[31m"
+#define MAKE_GREEN "\e[32m"
+
+#define __FUNC_ENTER__ printf("%s() entering...\n", __func__)
+#define __FUNC_EXIT__ printf("%s() leaving...\n", __func__)
+
+#define PRINT_START(x) printf(MAKE_GREEN "Running test: %dth..." RESET_COLOR "\n", x)
+
+#define MAX_INIT_NUM 1024
+
+#define SERVICE_NAME "matching filter test"
+#define PUB_SSI "Extra bytes in the publisher discovery"
+#define MSG_PUB_TO_SUB "Ready"
+#define PORT 1234
+
+#define MAX_SERVICE_NAME_LEN 255
+#define MAX_SPECIFIC_INFO_LEN 1024
+#define MAX_MATCH_FILTER_LEN 255
+
+typedef struct {
+ size_t len;
+ unsigned char values[MAX_MATCH_FILTER_LEN];
+} matching_filter_format_t;
+
+#define MATCHING_FILTER_FORMAT_NUM 8
+
+matching_filter_format_t test_matching_filter[MATCHING_FILTER_FORMAT_NUM]
+ = { {5, {0, 0, 0, 0, 0}}, // <0><0><0><0><0> -> wildcard
+ {10, {1, 1, 1, 2, 1, 3, 1, 4, 1, 5}}, // <1,1,><1,2><1,3><1,4><1,5> -> value filter 1
+ {10, {1, 1, 1, 2, 1, 1, 1, 4, 1, 5}}, // <1,1,><1,2><1,1><1,4><1,5> -> value filter 2
+ {6, {0, 1, 2, 0, 1, 4}}, // <0><1,2><0><1,4> -> value filter 3
+ {8, {0, 1, 2, 1, 3, 0, 1, 5}}, // <0><1,2><1,3><0><1,5> -> value filter 4
+ {6, {1, 1, 0, 1, 3, 0}}, // <1,1><0><1,3><0> -> value filter 5
+ {8, {1, 1, 0, 1, 3, 0, 1, 5}}, // <1,1><0><1,3><0><1,5> -> value filter 6
+ {0, {0, }}, // No filter
+};
+
+#ifdef __cplusplu
+}
+#endif
+
+#endif /* __WIFI_AWARE_MATCHING_FILTER_TEST_H__ */
--- /dev/null
+/*
+ * Wi-Fi Aware
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "wifi-aware.h"
+#include "wifi-aware-matching-filter-test.h"
+
+#define RET_IF_LOOP_IS_NULL()\
+ do {\
+ if (!g_main_loop_p) {\
+ printf("Loop was not initialized\n");\
+ return;\
+ } \
+ } while (0)
+
+static GMainLoop *g_main_loop_p;
+
+static test_case_e g_current_test = DUMMY_TEST_NUM;
+static bool g_initialized = false;
+static bool g_enabled = false;
+
+static bool g_test_result = false;
+
+static wifi_aware_session_h g_wifi_aware_session = NULL;
+static wifi_aware_publish_h g_publish_handle = NULL;
+
+void test_init();
+void test_deinit();
+
+static void __print_test_result(int num, bool result)
+{
+ char test_name[20] = {0, };
+
+ if (num < NEGATIVE_TEST_01)
+ snprintf(test_name, 19, "%s %d", "Positivie Test", num);
+ else
+ snprintf(test_name, 19, "%s %d", "Negative Test", num - NEGATIVE_TEST_01 + 1);
+
+ if (result)
+ printf(MAKE_GREEN"[%s] is pass."RESET_COLOR"\n", test_name);
+ else
+ printf(MAKE_RED"[%s] is fail."RESET_COLOR"\n", test_name);
+
+ printf("Please enter to run the next test..\n");
+}
+
+void test_quit()
+{
+ RET_IF_LOOP_IS_NULL();
+
+ g_main_loop_quit(g_main_loop_p);
+
+ return;
+}
+
+static void __published_cb(wifi_aware_session_h session,
+ wifi_aware_error_e error, void *user_data)
+{
+ printf("published..!\n");
+ if (error == WIFI_AWARE_ERROR_NONE)
+ g_test_result = true;
+ else
+ g_test_result = false;
+
+ __print_test_result(g_current_test, g_test_result);
+}
+
+static bool __set_default_configures(void)
+{
+ unsigned char specific_info[MAX_SPECIFIC_INFO_LEN + 1] = {0, };
+
+ int ret = wifi_aware_session_create(WIFI_AWARE_SESSION_PUBLISH, &g_wifi_aware_session);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ ret = wifi_aware_publish_create(&g_publish_handle);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ ret = wifi_aware_publish_set_service_name(g_publish_handle, SERVICE_NAME);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ size_t len = strlen(PUB_SSI);
+ memcpy(specific_info, PUB_SSI, len);
+ ret = wifi_aware_publish_set_service_specific_info(g_publish_handle, specific_info, len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ ret = wifi_aware_publish_enable_ranging(g_publish_handle, false);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ return true;
+}
+
+static void __enabled_cb(wifi_aware_error_e error, void *user_data)
+{
+ if (error == WIFI_AWARE_ERROR_NONE)
+ g_enabled = true;
+ else
+ g_enabled = false;
+
+ g_main_loop_quit(g_main_loop_p);
+}
+
+void clear_resources()
+{
+ if (g_publish_handle)
+ wifi_aware_publish_destroy(g_publish_handle);
+ g_publish_handle = NULL;
+
+ if (g_wifi_aware_session) {
+ wifi_aware_session_stop(g_wifi_aware_session);
+ wifi_aware_session_unset_message_received_cb(g_wifi_aware_session);
+ wifi_aware_session_unset_terminated_cb(g_wifi_aware_session);
+ wifi_aware_session_destroy(g_wifi_aware_session);
+ }
+ g_wifi_aware_session = NULL;
+
+ g_test_result = false;
+}
+
+void test_init()
+{
+ int ret = 0;
+
+ RET_IF_LOOP_IS_NULL();
+
+ if (g_initialized == false) {
+ ret = wifi_aware_initialize();
+ if (ret != WIFI_AWARE_ERROR_NONE) {
+ g_main_loop_quit(g_main_loop_p);
+ return;
+ }
+ g_initialized = true;
+ }
+
+ if (g_enabled == false) {
+ ret = wifi_aware_enable(__enabled_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE) {
+ g_main_loop_quit(g_main_loop_p);
+ return;
+ }
+ }
+}
+
+void test_deinit()
+{
+ wifi_aware_disable();
+ wifi_aware_deinitialize();
+}
+
+void test_sol_no_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_SOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // no filter
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_sol_wildcard_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_SOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><0><0><0><0>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[0].values, test_matching_filter[0].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_sol_value_filter_1()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_SOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><1,2><1,3><1,4><1,5>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[1].values, test_matching_filter[1].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_sol_value_filter_2()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_SOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><1,2><1,1><1,4><1,5>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[2].values, test_matching_filter[2].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_sol_value_filter_4()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_SOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><1,2><1,3><0><1,5>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[4].values, test_matching_filter[4].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_sol_value_filter_5()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_SOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><0><1,3><0>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[5].values, test_matching_filter[5].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_no_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // no filter
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_wildcard_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><0><0><0><0>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[0].values, test_matching_filter[0].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_value_filter_1(void)
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[1].values, test_matching_filter[1].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_value_filter_2()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><1,2><1,1><1,4><1,5>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[2].values, test_matching_filter[2].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_value_filter_3()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><1,2><0><1,4>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[3].values, test_matching_filter[3].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_value_filter_4()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><1,2><1,3><0><1,5>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[4].values, test_matching_filter[4].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_value_filter_5()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><0><1,3><0>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[5].values, test_matching_filter[5].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_unsol_value_filter_6()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_publish_set_type(g_publish_handle, WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><0><1,3><0><1,5>
+ ret = wifi_aware_publish_set_match_filter(g_publish_handle,
+ test_matching_filter[6].values, test_matching_filter[6].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_publish(g_wifi_aware_session, g_publish_handle, __published_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+typedef void (*test_func)(void);
+test_func g_menu_func[] = {
+ [0] = NULL,
+
+ [POSITIVE_TEST_01] = test_sol_no_filter,
+ [POSITIVE_TEST_02] = test_sol_wildcard_filter,
+ [POSITIVE_TEST_03] = test_sol_no_filter,
+ [POSITIVE_TEST_04] = test_sol_value_filter_1,
+
+ [POSITIVE_TEST_05] = test_sol_value_filter_1,
+ [POSITIVE_TEST_06] = test_sol_wildcard_filter,
+ [POSITIVE_TEST_07] = test_sol_value_filter_1,
+
+ [POSITIVE_TEST_08] = test_sol_value_filter_1,
+ [POSITIVE_TEST_09] = test_sol_value_filter_4,
+ [POSITIVE_TEST_10] = test_sol_value_filter_1,
+
+ [POSITIVE_TEST_11] = test_unsol_no_filter,
+ [POSITIVE_TEST_12] = test_unsol_no_filter,
+ [POSITIVE_TEST_13] = test_unsol_wildcard_filter,
+ [POSITIVE_TEST_14] = test_unsol_value_filter_1,
+
+ [POSITIVE_TEST_15] = test_unsol_wildcard_filter,
+ [POSITIVE_TEST_16] = test_unsol_value_filter_1,
+ [POSITIVE_TEST_17] = test_unsol_value_filter_1,
+
+ [POSITIVE_TEST_18] = test_unsol_value_filter_6,
+ [POSITIVE_TEST_19] = test_unsol_value_filter_1,
+ [POSITIVE_TEST_20] = test_unsol_value_filter_1,
+
+ // custom: unsol + active
+ [POSITIVE_TEST_21] = test_unsol_no_filter,
+ [POSITIVE_TEST_22] = test_unsol_wildcard_filter,
+ [POSITIVE_TEST_23] = test_unsol_no_filter,
+ [POSITIVE_TEST_24] = test_unsol_value_filter_1,
+
+ [POSITIVE_TEST_25] = test_unsol_value_filter_1,
+ [POSITIVE_TEST_26] = test_unsol_wildcard_filter,
+ [POSITIVE_TEST_27] = test_unsol_value_filter_1,
+
+ [POSITIVE_TEST_28] = test_unsol_value_filter_1,
+ [POSITIVE_TEST_29] = test_unsol_value_filter_4,
+ [POSITIVE_TEST_30] = test_unsol_value_filter_1,
+
+
+ [NEGATIVE_TEST_01] = test_sol_no_filter,
+ [NEGATIVE_TEST_02] = test_sol_value_filter_2,
+ [NEGATIVE_TEST_03] = test_sol_value_filter_5,
+
+ [NEGATIVE_TEST_04] = test_unsol_no_filter,
+ [NEGATIVE_TEST_05] = test_unsol_value_filter_1,
+ [NEGATIVE_TEST_06] = test_unsol_value_filter_3,
+
+ // custom test: unsol + active
+ [NEGATIVE_TEST_07] = test_unsol_no_filter,
+ [NEGATIVE_TEST_08] = test_unsol_value_filter_2,
+ [NEGATIVE_TEST_09] = test_unsol_value_filter_5,
+
+
+ [INVALID] = NULL,
+};
+
+static gboolean __test_terminal_read_std_input(GIOChannel * source,
+ GIOCondition condition, gpointer user_data)
+{
+ int fd = 0;
+ static char buf[1024];
+ int n = read(fd, buf, 1024);
+
+ if (n == 0) {
+ printf("Error: read() from stdin returns 0.\n");
+ } else if (n < 0) {
+ printf("input: read, err\n");
+ } else {
+ ++g_current_test;
+ if (g_current_test == INVALID) {
+ printf("Test is finished..\n");
+ g_main_loop_quit(g_main_loop_p);
+ return TRUE;
+ }
+ clear_resources();
+ g_menu_func[g_current_test]();
+ }
+ return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ g_main_loop_p = g_main_loop_new(NULL, FALSE);
+
+ printf(MAKE_GREEN"\nThis is Matching filter test on Publisher side"RESET_COLOR"\n");
+
+ test_init();
+ g_main_loop_run(g_main_loop_p);
+ if (!g_enabled) {
+ printf(MAKE_RED"Can not start test.."RESET_COLOR"\n");
+ g_main_loop_unref(g_main_loop_p);
+ return 0;
+ }
+
+ int std_input_fd = 0;
+ GIOChannel *gio2 = g_io_channel_unix_new(std_input_fd);
+ g_io_add_watch(gio2, G_IO_IN, (GIOFunc) __test_terminal_read_std_input, NULL);
+ g_io_channel_unref(gio2);
+
+ printf("Please enter to start test..\n");
+
+ g_main_loop_run(g_main_loop_p);
+
+ g_main_loop_unref(g_main_loop_p);
+ test_deinit();
+
+ return 0;
+}
--- /dev/null
+/*
+ * Wi-Fi Aware
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "wifi-aware.h"
+#include "wifi-aware-matching-filter-test.h"
+
+#define RET_IF_LOOP_IS_NULL()\
+ do {\
+ if (!g_main_loop_p) {\
+ printf("Loop was not initialized\n");\
+ return;\
+ } \
+ } while (0)
+
+#define SUBSCRIBE_TIMEOUT 7000
+
+static GMainLoop *g_main_loop_p;
+static guint g_timeout_id = 0;
+
+static test_case_e g_current_test = DUMMY_TEST_NUM;
+static bool g_initialized = false;
+static bool g_enabled = false;
+
+static bool g_test_result = false;
+
+static wifi_aware_session_h g_wifi_aware_session = NULL;
+static wifi_aware_subscribe_h g_subscribe_handle = NULL;
+
+void test_init();
+void test_deinit();
+
+static void __print_test_result(int num, bool result)
+{
+ char test_name[20] = {0, };
+
+ if (num < NEGATIVE_TEST_01)
+ snprintf(test_name, 19, "%s %d", "Positivie Test", num);
+ else
+ snprintf(test_name, 19, "%s %d", "Negative Test", num - NEGATIVE_TEST_01 + 1);
+
+ if (result)
+ printf(MAKE_GREEN"[%s] is pass."RESET_COLOR"\n", test_name);
+ else
+ printf(MAKE_RED"[%s] is fail."RESET_COLOR"\n", test_name);
+
+ printf("Prease enter to run the next test...\n");
+}
+
+void test_quit()
+{
+ RET_IF_LOOP_IS_NULL();
+
+ g_main_loop_quit(g_main_loop_p);
+
+ return;
+}
+
+static void clear_resources()
+{
+ if (g_subscribe_handle)
+ wifi_aware_subscribe_destroy(g_subscribe_handle);
+ g_subscribe_handle = NULL;
+
+ if (g_wifi_aware_session) {
+ wifi_aware_session_stop(g_wifi_aware_session);
+ wifi_aware_session_unset_message_received_cb(g_wifi_aware_session);
+ wifi_aware_session_unset_service_discovered_cb(g_wifi_aware_session);
+ wifi_aware_session_unset_terminated_cb(g_wifi_aware_session);
+ wifi_aware_session_destroy(g_wifi_aware_session);
+ }
+ g_wifi_aware_session = NULL;
+
+ g_test_result = false;
+}
+
+static gboolean __subscribed_timeout_handler(gpointer user_data)
+{
+ printf("Not discovered! reached timeout!\n");
+
+ if (g_current_test >= NEGATIVE_TEST_01)
+ g_test_result = true;
+ else
+ g_test_result = false;
+
+ __print_test_result(g_current_test, g_test_result);
+ clear_resources();
+ return FALSE;
+}
+
+static void __subscribed_cb(wifi_aware_session_h session,
+ wifi_aware_error_e error, void *user_data)
+{
+ if (error == WIFI_AWARE_ERROR_NONE)
+ g_timeout_id = g_timeout_add(SUBSCRIBE_TIMEOUT, __subscribed_timeout_handler, session);
+ else
+ g_main_loop_quit(g_main_loop_p);
+}
+
+static void __service_discovered_cb(wifi_aware_session_h session,
+ wifi_aware_peer_h peer,
+ const unsigned char *service_specific_info, size_t service_specific_info_len,
+ int distance, void *user_data)
+{
+ printf("discovered!!\n");
+ if (g_current_test >= NEGATIVE_TEST_01)
+ g_test_result = false;
+ else
+ g_test_result = true;
+
+ if (g_timeout_id > 0) {
+ g_source_remove(g_timeout_id);
+ g_timeout_id = 0;
+ }
+ __print_test_result(g_current_test, g_test_result);
+ wifi_aware_session_unset_service_discovered_cb(g_wifi_aware_session);
+}
+
+static bool __set_default_configures(void)
+{
+ unsigned char specific_info[MAX_SPECIFIC_INFO_LEN + 1] = {0, };
+
+ int ret = wifi_aware_session_create(WIFI_AWARE_SESSION_SUBSCRIBE, &g_wifi_aware_session);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ ret = wifi_aware_subscribe_create(&g_subscribe_handle);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ ret = wifi_aware_subscribe_set_service_name(g_subscribe_handle, SERVICE_NAME);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ ret = wifi_aware_session_set_service_discovered_cb(g_wifi_aware_session,
+ __service_discovered_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ size_t len = strlen(PUB_SSI);
+ memcpy(specific_info, PUB_SSI, len);
+ ret = wifi_aware_subscribe_set_service_specific_info(g_subscribe_handle, specific_info, len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ return false;
+
+ return true;
+}
+
+static void __enabled_cb(wifi_aware_error_e error, void *user_data)
+{
+ if (error == WIFI_AWARE_ERROR_NONE)
+ g_enabled = true;
+ else
+ g_enabled = false;
+
+ g_main_loop_quit(g_main_loop_p);
+}
+
+void test_init()
+{
+ int ret = 0;
+
+ RET_IF_LOOP_IS_NULL();
+
+ if (g_initialized == false) {
+ ret = wifi_aware_initialize();
+ if (ret != WIFI_AWARE_ERROR_NONE) {
+ g_main_loop_quit(g_main_loop_p);
+ return;
+ }
+ g_initialized = true;
+ }
+
+ if (g_enabled == false) {
+ ret = wifi_aware_enable(__enabled_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE) {
+ g_main_loop_quit(g_main_loop_p);
+ return;
+ }
+ }
+}
+
+void test_deinit()
+{
+ wifi_aware_disable();
+ wifi_aware_deinitialize();
+}
+
+void test_active_no_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // No filter
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_active_wildcard_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><0><0><0><0>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[0].values, test_matching_filter[0].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_active_value_filter_1()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><1,2><1,3><1,4><1,5>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[1].values, test_matching_filter[1].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_active_value_filter_3()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><1,2><0><1,4>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[3].values, test_matching_filter[3].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_active_value_filter_6()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><0><1,3><0><1,5>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[6].values, test_matching_filter[6].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_passive_no_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // No filter
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_passive_wildcard_filter()
+{
+ PRINT_START(g_current_test);
+
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><0><0><0><0>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[0].values, test_matching_filter[0].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_passive_value_filter_1()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><1,2><1,3><1,4><1,5>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[1].values, test_matching_filter[1].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_passive_value_filter_2()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><1,2><1,1><1,4><1,5>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[2].values, test_matching_filter[2].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_passive_value_filter_4()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <0><1,2><1,3><0><1,5>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[4].values, test_matching_filter[4].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+void test_passive_value_filter_5()
+{
+ PRINT_START(g_current_test);
+ if (__set_default_configures() == false)
+ goto ERR;
+
+ int ret = wifi_aware_subscribe_set_type(g_subscribe_handle, WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ // <1,1><0><1,3><0>
+ ret = wifi_aware_subscribe_set_match_filter(g_subscribe_handle,
+ test_matching_filter[5].values, test_matching_filter[5].len);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+
+ ret = wifi_aware_session_subscribe(g_wifi_aware_session,
+ g_subscribe_handle, __subscribed_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ goto ERR;
+ return;
+
+ERR:
+ g_test_result = false;
+ __print_test_result(g_current_test, g_test_result);
+}
+
+typedef void (*test_func)(void);
+test_func g_menu_func[] = {
+ [0] = NULL,
+ // active
+ [POSITIVE_TEST_01] = test_active_no_filter,
+ [POSITIVE_TEST_02] = test_active_no_filter,
+ [POSITIVE_TEST_03] = test_active_wildcard_filter,
+ [POSITIVE_TEST_04] = test_active_no_filter,
+
+ [POSITIVE_TEST_05] = test_active_wildcard_filter,
+ [POSITIVE_TEST_06] = test_active_value_filter_1,
+ [POSITIVE_TEST_07] = test_active_value_filter_1,
+
+ [POSITIVE_TEST_08] = test_active_value_filter_6,
+ [POSITIVE_TEST_09] = test_active_value_filter_1,
+ [POSITIVE_TEST_10] = test_active_value_filter_3,
+
+ // passive
+ [POSITIVE_TEST_11] = test_passive_no_filter,
+ [POSITIVE_TEST_12] = test_passive_wildcard_filter,
+ [POSITIVE_TEST_13] = test_passive_no_filter,
+ [POSITIVE_TEST_14] = test_passive_no_filter,
+
+ [POSITIVE_TEST_15] = test_passive_value_filter_1,
+ [POSITIVE_TEST_16] = test_passive_wildcard_filter,
+ [POSITIVE_TEST_17] = test_passive_value_filter_1,
+
+ [POSITIVE_TEST_18] = test_passive_value_filter_1,
+ [POSITIVE_TEST_19] = test_passive_value_filter_4,
+ [POSITIVE_TEST_20] = test_passive_value_filter_5,
+
+ // custom: unsol + active
+ [POSITIVE_TEST_21] = test_active_no_filter,
+ [POSITIVE_TEST_22] = test_active_no_filter,
+ [POSITIVE_TEST_23] = test_active_wildcard_filter,
+ [POSITIVE_TEST_24] = test_active_no_filter,
+
+ [POSITIVE_TEST_25] = test_active_wildcard_filter,
+ [POSITIVE_TEST_26] = test_active_value_filter_1,
+ [POSITIVE_TEST_27] = test_active_value_filter_1,
+
+ [POSITIVE_TEST_28] = test_active_value_filter_6,
+ [POSITIVE_TEST_29] = test_active_value_filter_1,
+ [POSITIVE_TEST_30] = test_active_value_filter_3,
+
+ // active
+ [NEGATIVE_TEST_01] = test_active_value_filter_1,
+ [NEGATIVE_TEST_02] = test_active_value_filter_1,
+ [NEGATIVE_TEST_03] = test_active_value_filter_1,
+
+ // passive
+ [NEGATIVE_TEST_04] = test_passive_value_filter_1,
+ [NEGATIVE_TEST_05] = test_passive_value_filter_2,
+ [NEGATIVE_TEST_06] = test_passive_value_filter_1,
+
+ // custom: unsol + active
+ [NEGATIVE_TEST_07] = test_active_value_filter_1,
+ [NEGATIVE_TEST_08] = test_active_value_filter_1,
+ [NEGATIVE_TEST_09] = test_active_value_filter_1,
+
+ [INVALID] = NULL,
+};
+
+static gboolean __test_terminal_read_std_input(GIOChannel * source,
+ GIOCondition condition, gpointer user_data)
+{
+ int fd = 0;
+ static char buf[1024];
+ int n = read(fd, buf, 1024);
+
+ if (n == 0) {
+ printf("Error: read() from stdin returns 0.\n");
+ } else if (n < 0) {
+ printf("input: read, err\n");
+ } else {
+ ++g_current_test;
+ if (g_current_test == INVALID) {
+ printf("Test is finished..\n");
+ g_main_loop_quit(g_main_loop_p);
+ return TRUE;
+ }
+ clear_resources();
+ g_menu_func[g_current_test]();
+ }
+ return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ g_main_loop_p = g_main_loop_new(NULL, FALSE);
+
+ printf(MAKE_GREEN"\nThis is Matching filter test on Subscriber side"RESET_COLOR"\n");
+
+ test_init();
+ g_main_loop_run(g_main_loop_p);
+ if (!g_enabled) {
+ printf(MAKE_RED"Can not start test.."RESET_COLOR"\n");
+ g_main_loop_unref(g_main_loop_p);
+ return 0;
+ }
+
+ int std_input_fd = 0;
+ GIOChannel *gio2 = g_io_channel_unix_new(std_input_fd);
+ g_io_add_watch(gio2, G_IO_IN, (GIOFunc) __test_terminal_read_std_input, NULL);
+ g_io_channel_unref(gio2);
+
+ printf("Please enter to start test..\n");
+
+ g_main_loop_run(g_main_loop_p);
+
+ g_main_loop_unref(g_main_loop_p);
+ test_deinit();
+
+ return 0;
+}