Esempio n. 1
0
/**
 * @testcase         itc_wifimanager_connect_ap_config_p
 * @brief            check initialize, connect, de-initalization operations of wifi manager
 * @scenario         check initialize, connect, de-initalization operations of wifi manager
 * @apicovered       wifi_manager_init, wifi_manager_connect_ap_config, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_connect_ap_config_p(void)
{
	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;
	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	wifi_manager_ap_config_s config;
	wifi_manager_reconnect_config_s reconfig;
	reconfig.type = WIFI_RECONN_INTERVAL;
	reconfig.interval = 10;
	config.ssid_length = strlen(TEST_SSID);
	config.passphrase_length = strlen(TEST_PASSWORD);
	strncpy(config.ssid, TEST_SSID, config.ssid_length + 1);
	strncpy(config.passphrase, TEST_PASSWORD, config.passphrase_length + 1);
	config.ap_auth_type = (wifi_manager_ap_auth_type_e)TEST_AUTH_TYPE;
	config.ap_crypto_type = (wifi_manager_ap_crypto_type_e)TEST_CRYPTO_TYPE;
	printf("AP config: %s(%d), %s(%d), %d %d\n", config.ssid, config.ssid_length, config.passphrase, \
			config.passphrase_length, config.ap_auth_type, config.ap_crypto_type);

	ret =  wifi_manager_connect_ap_config(&config, &reconfig);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_connect_ap", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());
	WIFITEST_WAIT;

	ret = wifi_manager_disconnect_ap();
	TC_ASSERT_EQ_CLEANUP("wifi_manager_disconnect_ap", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());
	WIFITEST_WAIT;

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);

	TC_SUCCESS_RESULT();
}
Esempio n. 2
0
/**
 * @testcase         itc_wifimanager_reremove_n
 * @brief            check initialize, save ap config, get ap config, remove ap config, de-initalization operations of wifi manager
 * @scenario         check initialize, save ap config, get ap config, remove ap config, de-initalization operations of wifi manager
 * @apicovered       wifi_manager_init, wifi_manager_save_config, wifi_manager_get_config, wifi_manager_remove_config wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_reremove_n(void)
{
	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;
	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	wifi_manager_ap_config_s config;
	wifi_manager_ap_config_s gconfig;

	config.ssid_length = strlen(TEST_SSID);
	config.passphrase_length = strlen(TEST_PASSWORD);
	strncpy(config.ssid, TEST_SSID, config.ssid_length + 1);
	strncpy(config.passphrase, TEST_PASSWORD, config.passphrase_length + 1);
	config.ap_auth_type = (wifi_manager_ap_auth_type_e)TEST_AUTH_TYPE;
	config.ap_crypto_type = (wifi_manager_ap_crypto_type_e)TEST_CRYPTO_TYPE;
	printf("AP config: %s(%d), %s(%d), %d %d\n", config.ssid, config.ssid_length, config.passphrase, \
			config.passphrase_length, config.ap_auth_type, config.ap_crypto_type);

	ret =  wifi_manager_save_config(&config);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_save_config", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());

	ret =  wifi_manager_get_config(&gconfig);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_get_config", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());

	ret =  wifi_manager_remove_config();
	TC_ASSERT_EQ_CLEANUP("wifi_manager_remove_config", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());

	ret =  wifi_manager_remove_config();
	TC_ASSERT_NEQ_CLEANUP("wifi_manager_remove_config", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);

	TC_SUCCESS_RESULT();
}
Esempio n. 3
0
static void tc_pthread_pthread_yield(void)
{
	int ret_chk = 0;
	g_bpthreadcallback = false;

	ret_chk = pthread_create(&g_thread1, NULL, thread_yield_callback, NULL);
	TC_ASSERT_EQ("pthread_create", ret_chk, OK);

	sleep(SEC_1);

	TC_ASSERT_EQ_CLEANUP("pthread_yield", g_bpthreadcallback, true, pthread_detach(g_thread1));

	ret_chk = pthread_create(&g_thread2, NULL, thread_yield_callback, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_create", ret_chk, OK, pthread_detach(g_thread2));
	TC_ASSERT_EQ_CLEANUP("pthread_create", g_bpthreadcallback, true, pthread_detach(g_thread2));

	/* wait for threads to exit */
	sleep(SEC_5);

	ret_chk = pthread_join(g_thread1, NULL);
	TC_ASSERT_EQ("pthread_join", ret_chk, OK);

	ret_chk = pthread_join(g_thread2, NULL);
	TC_ASSERT_EQ("pthread_join", ret_chk, OK);

	TC_SUCCESS_RESULT();
}
Esempio n. 4
0
/**
 * @testcase         itc_wifimanager_set_mode_p
 * @brief            to check get info operation of wifi manager
 * @scenario         check get info operation of wifi manager
 * @apicovered       wifi_manager_init, wifi_manager_set_mode, wifi_manager_get_info, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_set_mode_p(void)
{
	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;

	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	wifi_manager_softap_config_s ap_config;

	strncpy(ap_config.ssid, TEST_SOFTAP_SSID,
			strlen(TEST_SOFTAP_SSID) + 1);

	ap_config.channel = TEST_SOFTAP_CHANNEL;
	strncpy(ap_config.passphrase, TEST_SOFTAP_PASSWORD,
			strlen(TEST_SOFTAP_PASSWORD) + 1);

	printf("SoftAP config: %s(%d), %s(%d), %d\n", ap_config.ssid, strlen(TEST_SOFTAP_SSID),
			ap_config.passphrase, strlen(TEST_SOFTAP_PASSWORD), ap_config.channel);

	ret = wifi_manager_set_mode(SOFTAP_MODE, &ap_config);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_set_mode", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());

	ret = wifi_manager_set_mode(STA_MODE, NULL);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_set_mode", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);
	TC_SUCCESS_RESULT();
}
Esempio n. 5
0
/**
* @testcase         itc_pwm_set_enabled_is_enabled_p
* @brief            checks if pwm state is enabled
* @scenario         sets and gets the same pwm period and checks if pwm state is enabled
* @apicovered       iotbus_pwm_is_enabled
* @precondition     opens the pwm_context
* @postcondition    closes the pwm_context
*/
void itc_pwm_set_enabled_is_enabled_p(void)
{
	int device = 0;
	int channel = 1;
	int period = 1000;
	int ret = 0;
	int default_state = 0;
	int get_state = 0;
	iotbus_pwm_context_h h_pwm = iotbus_pwm_open(device, channel);
	TC_ASSERT_NOT_NULL("iotbus_pwm_open", h_pwm);

	ret = iotbus_pwm_set_period(h_pwm, period);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_set_period", ret, OK, iotbus_pwm_close(h_pwm));

	ret = iotbus_pwm_get_period(h_pwm);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_get_period", ret, period, iotbus_pwm_close(h_pwm));

	default_state = iotbus_pwm_is_enabled(h_pwm);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_is_enabled", default_state < OK, false, iotbus_pwm_close(h_pwm));

	iotbus_pwm_state_e e_state = IOTBUS_PWM_ENABLE;
	if (default_state == IOTBUS_PWM_DISABLE) {
		ret = iotbus_pwm_set_enabled(h_pwm, e_state);
		TC_ASSERT_EQ_CLEANUP("iotbus_pwm_set_enabled", ret, OK, iotbus_pwm_close(h_pwm));

		get_state = iotbus_pwm_is_enabled(h_pwm);
		TC_ASSERT_EQ_CLEANUP("iotbus_pwm_is_enabled", get_state, e_state, iotbus_pwm_close(h_pwm); iotbus_pwm_set_enabled(h_pwm, default_state));

		// Restoring default state
		iotbus_pwm_set_enabled(h_pwm, default_state);
	} else {
Esempio n. 6
0
/**
* @testcase        :itc_net_listen_p_multiple_time
* @brief           :listen for socket connections and limit the queue of incoming connections
* @scenario        :create socket, bind it and then listen and repeat multiple times
* @apicovered      :listen()
* @precondition    :open socket
* @postcondition   :close socket
*/
static void itc_net_listen_p_multiple_time(void)
{
	int index;
	int socket_fd;
	int ret;
	struct sockaddr_in sa;

	for (index = 0; index < LOOP_COUNT; index++) {
		socket_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
		TC_ASSERT_GEQ("socket", socket_fd, CONFIG_NFILE_DESCRIPTORS);//If ASSERT FAILS, no need to close(socket_fd) as socket is not created

		memset(&sa, 0, sizeof sa);

		sa.sin_family = AF_INET;
		sa.sin_port = htons(ADDR_PORT);
		sa.sin_addr.s_addr = htonl(INADDR_ANY);

		ret = bind(socket_fd, (struct sockaddr *)&sa, sizeof(sa));
		TC_ASSERT_EQ_CLEANUP("bind", ret, 0, close(socket_fd));

		ret = listen(socket_fd, BACK_LOG);
		TC_ASSERT_EQ_CLEANUP("listen", ret, 0, close(socket_fd));

		ret = close(socket_fd);
		TC_ASSERT_EQ("close", ret, 0);
	}

	TC_SUCCESS_RESULT();
}
Esempio n. 7
0
/**
* @testcase         itc_systemio_iotbus_uart_set_mode_flush_write_read_p
* @brief            To check flush/write/read operation with different parity
* @scenario         uart flush/write/read operation with different parity
* @apicovered       iotbus_uart_set_mode, iotbus_uart_write, iotbus_uart_read, iotbus_uart_flush
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
static void itc_systemio_iotbus_uart_set_mode_flush_write_read_p(void)
{
	int i_bytesize = 8;
	int i_stop_bits = 1;
	int ret = IOTBUS_ERROR_NONE;
	char sz_input_text[BUF_LEN] = "UART READ/WRITE ITC TESTING!";
	char sz_output_text[BUF_LEN];
	int mode[] = { IOTBUS_UART_PARITY_NONE, IOTBUS_UART_PARITY_EVEN, IOTBUS_UART_PARITY_ODD };
	char *mode_str[3] = { "IOTBUS_UART_PARITY_NONE", "IOTBUS_UART_PARITY_EVEN", "IOTBUS_UART_PARITY_ODD" };
	int i_modes = sizeof(mode) / sizeof(int);
	int index = 0;
	int count_fail_mode = 0;
	int count_fail_write = 0;
	int count_fail_read = 0;
	int count_fail_flush = 0;

	iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ("iotbus_uart_init", h_uart, NULL);

	for (index = 0; index < i_modes; index++) {
		ret = iotbus_uart_set_mode(h_uart, i_bytesize, mode[index], i_stop_bits);
		if ((ret != IOTBUS_ERROR_NONE)) {
			SYSIO_ITC_PRINT("iotbus_uart_set_mode failed with PARITY ::%s, stop_bits::%d\n", mode_str[index], i_stop_bits);
			count_fail_mode++;
			continue;
		}

		ret = iotbus_uart_flush(h_uart);
		if ((ret != IOTBUS_ERROR_NONE)) {
			SYSIO_ITC_PRINT("iotbus_uart_flush failed with PARITY ::%s, stop_bits::%d\n", mode_str[index], i_stop_bits);
			count_fail_flush++;
			continue;
		}

		ret = iotbus_uart_write(h_uart, sz_input_text, sizeof(sz_input_text));
		if ((ret < 0)) {
			SYSIO_ITC_PRINT("iotbus_uart_write failed with PARITY ::%s, stop_bits::%d\n", mode_str[index], i_stop_bits);
			count_fail_write++;
			continue;
		}

		usleep(MICROSECOND);

		ret = iotbus_uart_read(h_uart, sz_output_text, sizeof(sz_output_text));
		if ((ret < 0) || (strcmp(sz_input_text, sz_output_text) != 0)) {
			SYSIO_ITC_PRINT("iotbus_uart_read failed with PARITY ::%s, stop_bits::%d\n", mode_str[index], i_stop_bits);
			count_fail_read++;
		}
	}

	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_mode failed count", count_fail_mode, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_flush failed count", count_fail_flush, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_write failed count", count_fail_write, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read failed count", count_fail_read, 0, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_stop(h_uart);
	TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Esempio n. 8
0
/**
* @testcase         itc_systemio_iotbus_uart_write_read_flush_read_p
* @brief            perform write, read, flush, and read data operations over uart bus
* @scenario         perform write, read, flush, and read data operations over uart bus
* @apicovered       iotbus_uart_write, iotbus_uart_read, iotbus_uart_flush
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
static void itc_systemio_iotbus_uart_write_read_flush_read_p(void)
{
	int ret = IOTBUS_ERROR_NONE;
	char sz_input_text[BUF_LEN] = "UART READ/WRITE ITC TESTING!";
	char sz_output_text[BUF_LEN];

	iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ("iotbus_uart_init", h_uart, NULL);

	ret = iotbus_uart_write(h_uart, sz_input_text, sizeof(sz_input_text));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_write", ret < 0, false, iotbus_uart_stop(h_uart));

	usleep(MICROSECOND);

	ret = iotbus_uart_read(h_uart, sz_output_text, sizeof(sz_output_text));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", ret < 0, false, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", strcmp(sz_input_text, sz_output_text), 0, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_flush(h_uart);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_flush", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_read(h_uart, sz_output_text, sizeof(sz_output_text));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", ret == 0, true, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_stop(h_uart);
	TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Esempio n. 9
0
/**
 * @testcase         itc_wifimanager_redisconnect_p
 * @brief            check disconnect operation if AP already disconnected
 * @scenario         check disconnect operation if AP already disconnected
 * @apicovered       wifi_manager_init, wifi_manager_set_mode, wifi_manager_connect_ap, wifi_manager_disconnect_ap, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_redisconnect_p(void)
{
	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;

	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	wifi_manager_ap_config_s config;
	config.ssid_length = strlen(TEST_SSID);
	config.passphrase_length = strlen(TEST_PASSWORD);
	strncpy(config.ssid, TEST_SSID, config.ssid_length + 1);
	strncpy(config.passphrase, TEST_PASSWORD, config.passphrase_length + 1);
	config.ap_auth_type = (wifi_manager_ap_auth_type_e)TEST_AUTH_TYPE;
	config.ap_crypto_type = (wifi_manager_ap_crypto_type_e)TEST_CRYPTO_TYPE;
	printf("AP config: %s(%d), %s(%d), %d %d\n", config.ssid, config.ssid_length, config.passphrase, \
			config.passphrase_length, config.ap_auth_type, config.ap_crypto_type);

	ret = wifi_manager_connect_ap(&config);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_connect_ap", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());
	WIFITEST_WAIT;

	ret = wifi_manager_disconnect_ap();
	TC_ASSERT_EQ_CLEANUP("wifi_manager_disconnect_ap", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());
	WIFITEST_WAIT;

	ret = wifi_manager_disconnect_ap();
	TC_ASSERT_EQ_CLEANUP("wifi_manager_disconnect_ap", ret, WIFI_MANAGER_FAIL, wifi_manager_deinit());
	// wifitest_wait is not required here, as it is already disconnected

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);

	TC_SUCCESS_RESULT();
}
Esempio n. 10
0
/**
* @testcase         itc_systemio_iotbus_uart_set_flow_write_flush_read_p
* @brief            flush, write, and read data over uart bus with set flow
* @scenario         flush, write, and read data over uart bus with set flow
* @apicovered       iotbus_uart_write, iotbus_uart_read, iotbus_uart_set_flowcontrol, iotbus_uart_flush
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
static void itc_systemio_iotbus_uart_set_flow_flush_write_read_p(void)
{
	int i_size = 4;
	int ret = IOTBUS_ERROR_NONE;
	char sz_input_text[BUF_LEN] = "UART READ/WRITE ITC TESTING!";
	char sz_output_text[BUF_LEN];
	int rtscts[4][2] = { {1, 0}, {0, 1}, {1, 1}, {0, 0} };
	int index = 0;
	int count_fail_flowcontrol = 0;
	int count_fail_write = 0;
	int count_fail_read = 0;
	int count_fail_flush = 0;

	iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ("iotbus_uart_init", h_uart, NULL);

	for (index = 0; index < i_size; index++) {
		ret = iotbus_uart_set_flowcontrol(h_uart, rtscts[index][0], rtscts[index][1]);
		if (ret != IOTBUS_ERROR_NONE) {
			SYSIO_ITC_PRINT("iotbus_uart_set_flowcontrol failed with xonxoff ::%d, rtscts::%d\n", rtscts[index][0], rtscts[index][1]);
			count_fail_flowcontrol++;
			continue;
		}

		ret = iotbus_uart_flush(h_uart);
		if (ret != IOTBUS_ERROR_NONE) {
			SYSIO_ITC_PRINT("iotbus_uart_flush failed with xonxoff ::%d, rtscts::%d\n", rtscts[index][0], rtscts[index][1]);
			count_fail_flush++;
			continue;
		}

		ret = iotbus_uart_write(h_uart, sz_input_text, sizeof(sz_input_text));
		if (ret < 0) {
			SYSIO_ITC_PRINT("iotbus_uart_write failed with xonxoff ::%d, rtscts::%d\n", rtscts[index][0], rtscts[index][1]);
			count_fail_write++;
			continue;
		}

		usleep(MICROSECOND);

		ret = iotbus_uart_read(h_uart, sz_output_text, sizeof(sz_output_text));
		if ((ret < 0) || (strcmp(sz_input_text, sz_output_text) != 0)) {
			SYSIO_ITC_PRINT("iotbus_uart_read failed with xonxoff ::%d, rtscts::%d\n", rtscts[index][0], rtscts[index][1]);
			count_fail_read++;
		}
	}

	TC_ASSERT_EQ_CLEANUP("iotbus_uart_flush failed count", count_fail_flush, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_write failed count", count_fail_write, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read failed count", count_fail_read, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_flowcontrol failed count", count_fail_flowcontrol, 0, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_stop(h_uart);
	TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Esempio n. 11
0
/**
* @testcase         itc_systemio_iotbus_uart_set_mode_p_all
* @brief            sets byte size, parity bit and stop bits (all combinations)
* @scenario         sets byte size, parity bit and stop bits (all combinations)
* @apicovered       iotbus_uart_set_mode
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
static void itc_systemio_iotbus_uart_set_mode_p_all(void)
{
	int i_bytesize = 0;
	int i_max_bytesize = 10;
	int i_stop_bits = 0;
	int i_max_stop_bits = 4;
	int ret = IOTBUS_ERROR_NONE;
	int mode[] = { IOTBUS_UART_PARITY_NONE, IOTBUS_UART_PARITY_EVEN, IOTBUS_UART_PARITY_ODD };
	char mode_str[3][BUF_LEN] = { "IOTBUS_UART_PARITY_NONE", "IOTBUS_UART_PARITY_EVEN", "IOTBUS_UART_PARITY_ODD" };
	int i_modes = sizeof(mode) / sizeof(int);
	int index = 0;
	int count_bytesize_fail = 0;
	int count_stopbit_fail = 0;
	int count_fail = 0;

	iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ("iotbus_uart_init", h_uart, NULL);

	for (i_bytesize = 0; i_bytesize < i_max_bytesize; ++i_bytesize) {
		for (i_stop_bits = 0; i_stop_bits < i_max_stop_bits; ++i_stop_bits) {
			for (index = 0; index < i_modes; index++) {
				ret = iotbus_uart_set_mode(h_uart, i_bytesize, mode[index], i_stop_bits);
				if (i_stop_bits < 1 || i_stop_bits > 2) {
					//checking for invalid parameters (stopbits)
					if (ret != IOTBUS_ERROR_INVALID_PARAMETER) {
						SYSIO_ITC_PRINT("iotbus_uart_set_mode failed for stopbits ::%d\n", i_stop_bits);
						count_stopbit_fail++;
					}
				} else if (i_bytesize < 5 || i_bytesize > 8) {
					//checking with invalid parameters (bytessize)
					if (ret != IOTBUS_ERROR_INVALID_PARAMETER) {
						SYSIO_ITC_PRINT("iotbus_uart_set_mode failed for bytesize ::%d\n", i_bytesize);
						count_bytesize_fail++;
					}
				} else {
					//checking with valid parameters
					if (ret != IOTBUS_ERROR_NONE) {
						SYSIO_ITC_PRINT("iotbus_uart_set_mode failed UART_PARITY::%s, bytesize::%d, stopbits::%d \n", mode_str[index], i_bytesize, i_stop_bits);
						count_fail++;
					}
				}
			}
		}
	}
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_mode fail_count with bytesize", count_bytesize_fail, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_mode fail_count with stopbit", count_stopbit_fail, 0, iotbus_uart_stop(h_uart));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_mode fail_count", count_fail, 0, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_stop(h_uart);
	TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Esempio n. 12
0
static void tc_pthread_pthread_findjoininfo_destroyjoin(void)
{
	int ret_chk;
	g_bpthreadcallback = false;

	ret_chk = pthread_create(&g_thread1, NULL, findjoininfo_callback, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_create", ret_chk, OK, pthread_detach(g_thread1));

	pthread_join(g_thread1, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_join", g_bpthreadcallback, true, pthread_detach(g_thread1));

	TC_SUCCESS_RESULT();
}
Esempio n. 13
0
/**
 * @testcase         itc_wifimanager_connect_long_ssid_p
 * @brief            check connection with very long SSID
 * @scenario         check connection with very long SSID
 * @apicovered       wifi_manager_init, wifi_manager_set_mode, wifi_manager_connect_ap, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_connect_long_ssid_p(void)
{
	const char ssid[] = "qwertyuiopalokasdasdjasdkajshdukekukzhjdshdkjsdksjdsdadsasdasdasd";
	const char passphrase[] = "ashfdkjasfhkjsdhksahfkjdhsjfkhsdjahfkjashdfkjhasjkdhfkfdhksjafhsdaashdkjfksdhfkjashdjfhsajkdfh";

	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;
	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	wifi_manager_ap_config_s config;
	config.ssid_length = strlen(ssid);
	config.passphrase_length = strlen(passphrase);
	strncpy(config.ssid, ssid, sizeof(config.ssid));
	strncpy(config.passphrase, passphrase, sizeof(config.passphrase));
	config.ap_auth_type = (wifi_manager_ap_auth_type_e)TEST_AUTH_TYPE;
	config.ap_crypto_type = (wifi_manager_ap_crypto_type_e)TEST_CRYPTO_TYPE;
	printf("AP config: %s(%d), %s(%d), %d %d\n", config.ssid, config.ssid_length, config.passphrase, \
			config.passphrase_length, config.ap_auth_type, config.ap_crypto_type);

	ret = wifi_manager_connect_ap(&config);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_connect_ap", ret, WIFI_MANAGER_INVALID_ARGS, wifi_manager_deinit());

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);
	TC_SUCCESS_RESULT();
}
Esempio n. 14
0
void itc_mqtt_subscribe_unsubscribe_p(void)
{
	int res;
	g_mqtt_client_handle = mqtt_init_client(&g_mqtt_client_config);
	TC_ASSERT_NEQ("mqtt_init_client", g_mqtt_client_handle, NULL);
	res = mqtt_connect(g_mqtt_client_handle, CONFIG_ITC_MQTT_BROKER_ADDR, CONFIG_ITC_MQTT_BROKER_PORT, 0);
	TC_ASSERT_EQ_CLEANUP("mqtt_connect", res, 0, mqtt_deinit_client(g_mqtt_client_handle));
	ITC_MQTT_WAIT_SIGNAL;

	res = mqtt_subscribe(g_mqtt_client_handle, ITC_MQTT_TOPIC, 0);
	TC_ASSERT_EQ_CLEANUP("mqtt_subscribe", res, 0,
		mqtt_disconnect(g_mqtt_client_handle); mqtt_deinit_client(g_mqtt_client_handle));

	res = mqtt_unsubscribe(g_mqtt_client_handle, ITC_MQTT_TOPIC);
	TC_ASSERT_EQ_CLEANUP("mqtt_unsubscribe", res, 0,
		mqtt_disconnect(g_mqtt_client_handle); mqtt_deinit_client(g_mqtt_client_handle));

	res = mqtt_disconnect(g_mqtt_client_handle);
	TC_ASSERT_EQ("mqtt_disconnect", res, 0);
	ITC_MQTT_WAIT_SIGNAL;

	res = mqtt_deinit_client(g_mqtt_client_handle);
	TC_ASSERT_EQ("mqtt_deinit_client", res, 0);
	TC_SUCCESS_RESULT();
}
Esempio n. 15
0
/**
* @fn                   :tc_driver_adc_open_close
* @brief                :Test the adc driver open and close
* @scenario             :Test the adc driver open and close
* API's covered         :open, close
* Preconditions         :none
* Postconditions        :none
* @return               :void
*/
static void tc_driver_adc_open_close(void)
{
	int fd = 0;
	int ret = 0;

	/* Positive test cases */
	fd = open("/dev/adc0", O_RDONLY);
	TC_ASSERT_GT("adc_open", fd, 0);

	ret = close(fd);
	TC_ASSERT_EQ("adc_close", ret, OK);

	/* Negative test cases */
	int count = 0;
	int fds[255] = { 0, };
	for (count = 0; count < 255; count++) {
		fds[count] = open("/dev/adc0", O_RDONLY);
		if (fds[count] < 0) {
			TC_ASSERT_EQ_CLEANUP("adc_open", errno, EMFILE, close_fds(fds, --count));
			break;
		}
	}

	close_fds(fds, --count);

	TC_SUCCESS_RESULT();
}
Esempio n. 16
0
/**
 * @testcase         itc_wifimanager_connect_ap_n
 * @brief            connecting with invalid configuration parameters
 * @scenario         connecting with invalid configuration parameters
 * @apicovered       wifi_manager_init, wifi_manager_set_mode, wifi_manager_connect_ap, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_connect_ap_n(void)
{
	char ssid[] = "";
	char passphrase[] = "";

	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;
	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	wifi_manager_ap_config_s config;
	config.ssid_length = strlen(ssid);
	config.passphrase_length = strlen(passphrase);
	strncpy(config.ssid, ssid, config.ssid_length + 1);
	strncpy(config.passphrase, passphrase, config.passphrase_length + 1);
	config.ap_auth_type = (wifi_manager_ap_auth_type_e)TEST_AUTH_TYPE;
	config.ap_crypto_type = (wifi_manager_ap_crypto_type_e)TEST_CRYPTO_TYPE;
	printf("AP config: %s(%d), %s(%d), %d %d\n", config.ssid, config.ssid_length, config.passphrase, \
			config.passphrase_length, config.ap_auth_type, config.ap_crypto_type);

	ret = wifi_manager_connect_ap(&config);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_connect_ap", ret, WIFI_MANAGER_FAIL, wifi_manager_deinit());

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);
	TC_SUCCESS_RESULT();
}
Esempio n. 17
0
/**
* @fn                   :tc_timer_timer_create_delete
* @brief                :Create and delete a POSIX per-process timer
* @scenario             :Create and delete a POSIX per-process timer
* API's covered         :timer_create, timer_delete
* Preconditions         :none
* Postconditions        :none
* @return               :void
*/
static void tc_timer_timer_create_delete(void)
{
	int ret_chk = 0;
	timer_t timer_id;
	timer_t gtimer_id;
	clockid_t clockid = CLOCK_REALTIME;
	struct sigevent st_sigevent;
	struct posix_timer_s *st_ret_prt;
	struct itimerspec st_timer_spec_val;
	/* Set and enable alarm */
	st_sigevent.sigev_notify = SIGEV_SIGNAL;
	st_sigevent.sigev_signo = sig_no;
	st_sigevent.sigev_value.sival_ptr = &timer_id;

	ret_chk = timer_create(clockid, &st_sigevent, &timer_id);
	TC_ASSERT_NEQ("timer_create", ret_chk, ERROR);
	TC_ASSERT_NOT_NULL("timer_create", timer_id);

	st_ret_prt = (struct posix_timer_s *)timer_id;
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_value.sival_ptr, st_sigevent.sigev_value.sival_ptr, timer_delete(timer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_signo, st_sigevent.sigev_signo, timer_delete(timer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_crefs, 1, timer_delete(timer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_owner, getpid(), timer_delete(timer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_delay, 0, timer_delete(timer_id));

	st_timer_spec_val.it_value.tv_sec = 1;
	st_timer_spec_val.it_value.tv_nsec = 0;

	st_timer_spec_val.it_interval.tv_sec = 1;
	st_timer_spec_val.it_interval.tv_nsec = 0;

	ret_chk = timer_settime(timer_id, 0, &st_timer_spec_val, NULL);
	TC_ASSERT_EQ_ERROR_CLEANUP("timer_settime", ret_chk, OK, errno, timer_delete(timer_id));

	ret_chk = timer_delete(timer_id);
	TC_ASSERT_NEQ("timer_delete", ret_chk, ERROR);

	ret_chk = timer_create(CLOCK_REALTIME, NULL, &gtimer_id);
	TC_ASSERT_NEQ("timer_create", ret_chk, ERROR);

	st_ret_prt = (struct posix_timer_s *)gtimer_id;

	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_value.sival_ptr, st_ret_prt, timer_delete(gtimer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_crefs, 1, timer_delete(gtimer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_owner, getpid(), timer_delete(gtimer_id));
	TC_ASSERT_EQ_CLEANUP("timer_create", st_ret_prt->pt_delay, 0, timer_delete(gtimer_id));

	ret_chk = timer_delete(gtimer_id);
	TC_ASSERT_NEQ("timer_delete", ret_chk, ERROR);
	TC_SUCCESS_RESULT();
}
Esempio n. 18
0
void itc_mqtt_connect_n_reconnect(void)
{
	int res;
	g_mqtt_client_handle = mqtt_init_client(&g_mqtt_client_config);
	TC_ASSERT_NEQ("mqtt_init_client", g_mqtt_client_handle, NULL);

	// MQTT Connect
	res = mqtt_connect(g_mqtt_client_handle, CONFIG_ITC_MQTT_BROKER_ADDR,	CONFIG_ITC_MQTT_BROKER_PORT, 0);
	TC_ASSERT_EQ_CLEANUP("mqtt_connect", res, 0, mqtt_deinit_client(g_mqtt_client_handle));
	ITC_MQTT_WAIT_SIGNAL;

	// MQTT re-Connect
	res = mqtt_connect(g_mqtt_client_handle, CONFIG_ITC_MQTT_BROKER_ADDR,	CONFIG_ITC_MQTT_BROKER_PORT, 0);
	TC_ASSERT_EQ_CLEANUP("mqtt_connect", res, 0, mqtt_deinit_client(g_mqtt_client_handle));
	if (g_mqtt_client_handle != NULL) {
		TC_ASSERT_EQ_CLEANUP("mqtt_connect", g_mqtt_client_handle->state, MQTT_CLIENT_STATE_CONNECTED,
			mqtt_disconnect(g_mqtt_client_handle); mqtt_deinit_client(g_mqtt_client_handle));
	}
Esempio n. 19
0
/**
* @testcase         itc_pwm_set_get_period_p
* @brief            sets and gets the pwm period
* @scenario         sets and gets the same pwm period
* @apicovered       iotbus_pwm_set_period, iotbus_pwm_get_period
* @precondition     opens the pwm_context
* @postcondition    closes the pwm_context
*/
void itc_pwm_set_get_period_p(void)
{
    int device = 0;
    int channel = 1;
    int period = 1000;
    int ret = 0;
    iotbus_pwm_context_h h_pwm = iotbus_pwm_open(device, channel);
    TC_ASSERT_NOT_NULL("iotbus_pwm_open", h_pwm);

	ret = iotbus_pwm_set_period(h_pwm, period);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_set_period", ret, OK, iotbus_pwm_close(h_pwm));

	ret = iotbus_pwm_get_period(h_pwm);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_get_period", ret, period, iotbus_pwm_close(h_pwm));

    ret = iotbus_pwm_close(h_pwm);
    TC_ASSERT_EQ("iotbus_pwm_close", ret, OK);

    TC_SUCCESS_RESULT();
}
Esempio n. 20
0
/**
* @testcase         itc_pwm_set_get_duty_cycle_p
* @brief            sets and gets the pwm duty cycle
* @scenario         sets and gets the same pwm duty cycle
* @apicovered       iotbus_pwm_set_duty_cycle, iotbus_pwm_get_duty_cycle
* @precondition     opens the pwm_context
* @postcondition    closes the pwm_context
*/
void itc_pwm_set_get_duty_cycle_p(void)
{
    int device = 0;
    int channel = 1;
    int cycle = 20;
    int ret = 0;
    iotbus_pwm_context_h h_pwm = iotbus_pwm_open(device, channel);
    TC_ASSERT_NOT_NULL("iotbus_pwm_open", h_pwm);

	ret = iotbus_pwm_set_duty_cycle(h_pwm, cycle);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_set_duty_cycle", ret, OK, iotbus_pwm_close(h_pwm));

	ret = iotbus_pwm_get_duty_cycle(h_pwm);
	TC_ASSERT_EQ_CLEANUP("iotbus_pwm_get_duty_cycle", ret, cycle, iotbus_pwm_close(h_pwm));

    ret = iotbus_pwm_close(h_pwm);
    TC_ASSERT_EQ("iotbus_pwm_close", ret, OK);

    TC_SUCCESS_RESULT();
}
Esempio n. 21
0
static void utc_taskmanager_getinfo_with_pid_p(void)
{
	tm_appinfo_t *ret;

	ret = task_manager_getinfo_with_pid(pid_tm_utc, TM_RESPONSE_WAIT_INF);
	TC_ASSERT_NEQ_CLEANUP("task_manager_getinfo_with_pid", ret, NULL, task_manager_clean_info(&ret));
	TC_ASSERT_EQ_CLEANUP("task_manager_getinfo_with_pid", ret->handle, handle_tm_utc, task_manager_clean_info(&ret));

	(void)task_manager_clean_info(&ret);
	TC_SUCCESS_RESULT();
}
Esempio n. 22
0
/**
* @fn                   :tc_pthread_pthread_kill
* @brief                :send a signal to a thread
* @Scenario             :The pthread_kill() function sends the signal sig to thread, a thread
*                        in the same process as the caller.  The signal is asynchronously
*                        directed to thread.
* API's covered         :pthread_kill, pthread_join
* Preconditions         :none
* Postconditions        :none
* @return               :void
*/
static void tc_pthread_pthread_kill(void)
{
	int ret_chk;
	g_bpthreadcallback = false;

	ret_chk = pthread_create(&g_thread1, NULL, thread_kill_func_callback, NULL);
	if (ret_chk != OK) {
		tckndbg("ERROR pthread_create FAIL\n");
		pthread_detach(g_thread1);
	}
	sleep(SEC_2);

	ret_chk = pthread_kill(g_thread1, SIGUSR1);
	sleep(SEC_1);
	TC_ASSERT_EQ_CLEANUP("pthread_kill", ret_chk, OK, pthread_detach(g_thread1));
	TC_ASSERT_EQ_CLEANUP("pthread_kill", g_bpthreadcallback, true, pthread_detach(g_thread1));
	pthread_join(g_thread1, NULL);

	TC_SUCCESS_RESULT();
}
Esempio n. 23
0
/**
* @fn                   :tc_pthread_pthread_cancel_setcancelstate
* @brief                :set  cancelability state and type and sends a cancellation request to a thread
* @Scenario             :The pthread_setcancelstate() sets the cancelability state of the calling
*                        thread to the value given in state. The pthread_cancel() function sends a cancellation request to the thread thread.
*                        Whether and when the target thread reacts to the cancellation request depends
*                        on two attributes that are under the control of that thread:
*                        its cancelability state and type
* API's covered         :pthread_setcancelstate, pthread_cancel
* Preconditions         :none
* Postconditions        :none
* @return               :void
*/
static void tc_pthread_pthread_cancel_setcancelstate(void)
{
	int ret_chk;
	g_bpthreadcallback = false;

	ret_chk = pthread_create(&g_thread1, NULL, cancel_state_func, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_create", ret_chk, OK, pthread_detach(g_thread1));

	sleep(SEC_1);
	/* this cancel request goes to pending if cancel is disabled */
	ret_chk = pthread_cancel(g_thread1);
	TC_ASSERT_EQ_CLEANUP("pthread_cancel", ret_chk, OK, pthread_detach(g_thread1));

	sleep(SEC_3);
	TC_ASSERT("pthread_cancel", g_bpthreadcallback);

	ret_chk = pthread_detach(g_thread1);
	TC_ASSERT_EQ("pthread_detach", ret_chk, OK);

	TC_SUCCESS_RESULT();
}
Esempio n. 24
0
/**
 * @testcase         itc_wifimanager_average_stoping_ap
 * @brief            to check average time taken while deinit wifi
 * @scenario         to check average time taken while deinit wifi
 * @apicovered       wifi_manager_init, wifi_manager_set_mode, wifi_manager_connect_ap, wifi_manager_disconnect_ap, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_average_stoping_ap(void)
{
	int i = 0;
	double average = 0.0f;
	struct timeval start_t;
	struct timeval end_t;
	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;

	wifi_manager_ap_config_s config;
	config.ssid_length = strlen(TEST_SSID);
	config.passphrase_length = strlen(TEST_PASSWORD);
	strncpy(config.ssid, TEST_SSID, config.ssid_length + 1);
	strncpy(config.passphrase, TEST_PASSWORD, config.passphrase_length + 1);
	config.ap_auth_type = (wifi_manager_ap_auth_type_e)TEST_AUTH_TYPE;
	config.ap_crypto_type = (wifi_manager_ap_crypto_type_e)TEST_CRYPTO_TYPE;
	printf("AP config: %s(%d), %s(%d), %d %d\n", config.ssid, config.ssid_length, config.passphrase, \
			config.passphrase_length, config.ap_auth_type, config.ap_crypto_type);

	for (i = 1; i <= LOOP_SIZE; i++) {
		ret = wifi_manager_init(&wifi_callbacks);
		TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

		ret = wifi_manager_connect_ap(&config);
		TC_ASSERT_EQ_CLEANUP("wifi_manager_connect_ap", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());
		WIFITEST_WAIT;

		ret = wifi_manager_disconnect_ap();
		TC_ASSERT_EQ_CLEANUP("wifi_manager_disconnect_ap", ret, WIFI_MANAGER_SUCCESS, wifi_manager_deinit());
		WIFITEST_WAIT;

		gettimeofday(&start_t, NULL);
		ret = wifi_manager_deinit();
		TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);
		gettimeofday(&end_t, NULL);
		average += diff_time(&start_t, &end_t);
	}

	printf("\n[Average wifi deinitialization time: %.2f ms]\n", average / (LOOP_SIZE * 1000));
	TC_SUCCESS_RESULT();
}
Esempio n. 25
0
/**
* @fn                   :tc_pthread_pthread_set_get_schedparam
* @brief                :set/get scheduling policy and parameters of a thread
* @Scenario             :The pthread_setschedparam() function sets the scheduling policy and
*                        parameters of the thread , Policy specifies the new scheduling policy for thread.
*                        The pthread_getschedparam() function returns the scheduling policy and parameters
*                        of the thread thread, in the buffers pointed to by policy and param, respectively.
* API's covered          :pthread_setschedparam, pthread_getschedparam
* Preconditions         :none
* Postconditions        :none
* @return               :void
*/
static void tc_pthread_pthread_set_get_schedparam(void)
{
	int ret_chk;
	struct sched_param st_setparam;
	struct sched_param st_getparam;
	int getpolicy;
	int setpolicy = SCHED_FIFO;

	memset(&st_setparam, 0, sizeof(st_setparam));

	st_setparam.sched_priority = SCHED_PRIORITY;

	ret_chk = pthread_create(&g_thread1, NULL, threadfunc_sched, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_create", ret_chk, OK, pthread_detach(g_thread1));
	sleep(SEC_2);

	ret_chk = pthread_setschedparam(g_thread1, setpolicy, &st_setparam);
	TC_ASSERT_EQ_CLEANUP("pthread_setschedparam", ret_chk, OK, pthread_detach(g_thread1));

	sleep(SEC_1);

	ret_chk = pthread_getschedparam(g_thread1, &getpolicy, &st_getparam);
	TC_ASSERT_EQ_CLEANUP("pthread_getschedparam", ret_chk, OK, pthread_detach(g_thread1));
	TC_ASSERT_EQ_CLEANUP("pthread_getschedparam", getpolicy, setpolicy, pthread_detach(g_thread1));
	TC_ASSERT_EQ_CLEANUP("pthread_getschedparam", st_getparam.sched_priority, st_setparam.sched_priority, pthread_detach(g_thread1));

	ret_chk = pthread_join(g_thread1, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_join", ret_chk, OK, pthread_detach(g_thread1));

	TC_SUCCESS_RESULT();
}
Esempio n. 26
0
void itc_mqtt_publish_p(void)
{
	int res;
	g_mqtt_client_handle = mqtt_init_client(&g_mqtt_client_config);
	TC_ASSERT_NEQ("mqtt_init_client", g_mqtt_client_handle, NULL);
	res = mqtt_connect(g_mqtt_client_handle, CONFIG_ITC_MQTT_BROKER_ADDR, CONFIG_ITC_MQTT_BROKER_PORT, 0);
	TC_ASSERT_EQ_CLEANUP("mqtt_connect", res, 0, mqtt_deinit_client(g_mqtt_client_handle));
	ITC_MQTT_WAIT_SIGNAL;

	res = mqtt_publish(g_mqtt_client_handle, ITC_MQTT_TOPIC, g_mqtt_msg, sizeof(g_mqtt_msg), 0, 0);
	TC_ASSERT_EQ_CLEANUP("mqtt_publish", res, 0,
		mqtt_disconnect(g_mqtt_client_handle); mqtt_deinit_client(g_mqtt_client_handle));
	ITC_MQTT_WAIT_SIGNAL;

	res = mqtt_disconnect(g_mqtt_client_handle);
	TC_ASSERT_EQ_CLEANUP("mqtt_disconnect", res, 0, mqtt_deinit_client(g_mqtt_client_handle));
	ITC_MQTT_WAIT_SIGNAL;

	res = mqtt_deinit_client(g_mqtt_client_handle);
	TC_ASSERT_EQ("mqtt_deinit_client", res, 0);
	TC_SUCCESS_RESULT();
}
Esempio n. 27
0
/**
* @fn                   :tc_pthread_pthread_set_getspecific
* @brief                :thread-specific data management
* @Scenario             :The pthread_getspecific() function shall return the value currently bound
*                        to the specified key on behalf of the calling thread.
*                        The pthread_setspecific() function shall associate a thread-specific value
*                        with a key obtained via a previous call to pthread_key_create().
* API's covered         :pthread_setspecific, pthread_getspecific, pthread_key_create
* Preconditions         :pthread_key_create
* Postconditions        :none
* @return               :void
*/
static void tc_pthread_pthread_key_create_set_getspecific(void)
{
	int ret_chk;
	g_bpthreadcallback = false;
	g_tlskey = 0;

	/* Cannot create keys more than PTHREAD_KEYS_MAX, Not able to delete key */
	ret_chk = pthread_key_create(&g_tlskey, NULL);
	TC_ASSERT_EQ("pthread_key_create", ret_chk, OK);

	sleep(SEC_2);

	ret_chk = pthread_create(&g_thread1, NULL, func_set_get_callback, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_create", ret_chk, OK, pthread_detach(g_thread1));

	ret_chk = pthread_join(g_thread1, NULL);
	TC_ASSERT_EQ_CLEANUP("pthread_join", ret_chk, OK, pthread_detach(g_thread1));

	TC_ASSERT_EQ("pthread_join", g_bpthreadcallback, true);

	TC_SUCCESS_RESULT();
}
Esempio n. 28
0
/**
 * @testcase         itc_wifimanager_connect_set_mode_n
 * @brief            set mode with NULL config
 * @scenario         set mode with NULL config
 * @apicovered       wifi_manager_set_mode, wifi_manager_init, wifi_manager_deinit
 * @precondition     none
 * @postcondition    none
 */
static void itc_wifimanager_connect_set_mode_n(void)
{
	wifi_manager_result_e ret = WIFI_MANAGER_FAIL;
	ret = wifi_manager_init(&wifi_callbacks);
	TC_ASSERT_EQ("wifi_manager_init", ret, WIFI_MANAGER_SUCCESS);

	ret = wifi_manager_set_mode(SOFTAP_MODE, NULL);
	TC_ASSERT_EQ_CLEANUP("wifi_manager_set_mode", ret, WIFI_MANAGER_INVALID_ARGS, wifi_manager_deinit());

	ret = wifi_manager_deinit();
	TC_ASSERT_EQ("wifi_manager_deinit", ret, WIFI_MANAGER_SUCCESS);
	TC_SUCCESS_RESULT();
}
Esempio n. 29
0
/**
* @testcase         itc_systemio_iotbus_uart_flush_p
* @brief            flushes uart buffer
* @scenario         flushes uart buffer
* @apicovered       iotbus_uart_flush
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
void itc_systemio_iotbus_uart_flush_p(void)
{
	int ret = IOTBUS_ERROR_NONE;
	iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ("iotbus_uart_init", h_uart, NULL);

	ret = iotbus_uart_flush(h_uart);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_flush", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart));

	ret = iotbus_uart_stop(h_uart);
	TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Esempio n. 30
0
static void utc_taskmanager_unicast_n(void)
{
	int ret;
	tm_msg_t send_msg;
	send_msg.msg_size = strlen(TM_SAMPLE_MSG) + 1;
	send_msg.msg = malloc(send_msg.msg_size);
	TC_ASSERT_NEQ("task_manager_unicast", send_msg.msg, NULL);

	strncpy(send_msg.msg, TM_SAMPLE_MSG, send_msg.msg_size);
	
	ret = task_manager_unicast(tm_sample_handle, &send_msg, NULL, TM_INVALID_TIMEOUT);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, TM_INVALID_PARAM, free(send_msg.msg));

	ret = task_manager_unicast(TM_INVALID_HANDLE, &send_msg, NULL, TM_NO_RESPONSE);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, TM_INVALID_PARAM, free(send_msg.msg));

	send_msg.msg_size = 0;
	ret = task_manager_unicast(tm_sample_handle, &send_msg, NULL, TM_NO_RESPONSE);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, TM_INVALID_PARAM, free(send_msg.msg));

	free(send_msg.msg);

	TC_SUCCESS_RESULT();
}