Ejemplo n.º 1
0
/**
* @testcase          :itc_net_inet_ntop_p
* @brief             :function  converts  the network address structure src 
*                     in the af address family into a character string*
* @scenario          :passing hex value in inet_ntop
* @apicovered        :inet_ntop()
* @precondition      :None
* @postcondition     :None
*/
static void itc_net_inet_ntop_p(void)
{
#ifdef CONFIG_NET_IPv4
	struct in_addr in_addr;
	char dst[INET_ADDRSTRLEN];
	in_addr.s_addr = 0x17071994;
#endif

#ifdef CONFIG_NET_IPv6
	struct in6_addr in6_addr;
	char dst6[INET6_ADDRSTRLEN];
	in6_addr.s6_addr32[0] = 0x17071994;
	in6_addr.s6_addr32[1] = 0x17071994;
	in6_addr.s6_addr32[2] = 0x17071994;
	in6_addr.s6_addr32[3] = 0x17071994;
#endif
	const char *ret;

#ifdef CONFIG_NET_IPv4
	ret = inet_ntop(AF_INET, &in_addr, dst, INET_ADDRSTRLEN);
	TC_ASSERT_NEQ("inet_ntop", ret, NULL);
#endif

#ifdef CONFIG_NET_IPv6
	ret = inet_ntop(AF_INET6, &in6_addr, dst6, INET6_ADDRSTRLEN);
	TC_ASSERT_NEQ("inet_ntop", ret, NULL);
#endif

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 2
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();
}
Ejemplo n.º 3
0
static void utc_taskmanager_getinfo_with_group_p(void)
{
	if (!sample_info) {
		sample_info = (tm_appinfo_t *)task_manager_getinfo_with_handle(tm_sample_handle, TM_RESPONSE_WAIT_INF);
		TC_ASSERT_NEQ("task_manager_getinfo_with_handle", sample_info, NULL);
	}

	group_list_info = (tm_appinfo_list_t *)task_manager_getinfo_with_group(sample_info->tm_gid, TM_RESPONSE_WAIT_INF);
	TC_ASSERT_NEQ("task_manager_getinfo_with_group", group_list_info, NULL);

	task_manager_clean_infolist(&group_list_info);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 4
0
static void utc_taskmanager_getinfo_with_handle_p(void)
{
	sample_info = (tm_appinfo_t *)task_manager_getinfo_with_handle(tm_sample_handle, TM_RESPONSE_WAIT_INF);
	TC_ASSERT_NEQ("task_manager_getinfo_with_handle", sample_info, NULL);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 5
0
static void utc_taskmanager_clean_info_p(void)
{
	task_manager_clean_info(&sample_info);
	TC_ASSERT_NEQ("task_manager_clean_info", (tm_appinfo_t *)&sample_info, NULL);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 6
0
static void utc_taskmanager_getinfo_with_name_p(void)
{
	sample_list_info = (tm_appinfo_list_t *)task_manager_getinfo_with_name(TM_SAMPLE_NAME, TM_RESPONSE_WAIT_INF);
	TC_ASSERT_NEQ("task_manager_getinfo_with_name", sample_list_info, NULL);

	TC_SUCCESS_RESULT();
}
Ejemplo 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();
}
Ejemplo 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();
}
Ejemplo n.º 9
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();
}
Ejemplo n.º 10
0
static void utc_taskmanager_unicast_p(void)
{
	int ret;
	int sleep_cnt = 0;
	tm_msg_t reply_msg;
	tm_msg_t send_msg;

	cb_flag = false;

	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_NO_RESPONSE);
	TC_ASSERT_EQ("task_manager_unicast", ret, OK);
	while (1) {
		sleep(1);
		if (flag) {
			break;
		}
		TC_ASSERT_LEQ_CLEANUP("task_manager_unicast", sleep_cnt, 10, free(send_msg.msg));
		sleep_cnt++;
	}

	free(send_msg.msg);

	send_msg.msg_size = strlen(TM_SYNC_SEND_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_SYNC_SEND_MSG, send_msg.msg_size);

	ret = task_manager_unicast(tm_not_builtin_handle, &send_msg, &reply_msg, TM_RESPONSE_WAIT_INF);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, OK, free(send_msg.msg));
	if (strncmp((char *)reply_msg.msg, (char *)TM_SYNC_RECV_MSG, strlen(TM_SYNC_RECV_MSG)) == 0) {
		cb_flag = true;
	} else {
		cb_flag = false;
	}

	free(send_msg.msg);
	free(reply_msg.msg);
	TC_SUCCESS_RESULT();
}
Ejemplo n.º 11
0
/**
   * @testcase		   :tc_net_shutdown_send_p
   * @brief		   :
   * @scenario		   :
   * @apicovered	   :shutdown()
   * @precondition	   :
   * @postcondition	   :
   */
void tc_net_shutdown_send_p(int fd)
{
	int ret = shutdown(fd, SHUT_WR);

	TC_ASSERT_NEQ("shutdown", ret, -1);
	TC_SUCCESS_RESULT();

}
Ejemplo n.º 12
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();
}
Ejemplo n.º 13
0
static void SetUp(void)
{
	FILE *fp;
	fp = fopen(file_path, "w");
	TC_ASSERT_NEQ("fopen", fp, NULL);
	TC_ASSERT_NEQ_CLEANUP("fputs", fputs(test_data, fp), EOF, fclose(fp));
	TC_ASSERT_EQ("fclose", fclose(fp), OK);
	g_flag = 1;
}
Ejemplo n.º 14
0
void itc_mqtt_init_deinit_client_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_deinit_client(g_mqtt_client_handle);
	TC_ASSERT_EQ("mqtt_deinit_client", res, 0);
	TC_SUCCESS_RESULT();
}
Ejemplo n.º 15
0
/**
* @testcase         itc_systemio_iotbus_uart_init_stop_p
* @brief            initializes and closes uart_context
* @scenario         initializes and closes uart_context
* @apicovered       iotbus_uart_init, iotbus_uart_stop
* @precondition     none
* @postcondition    none
*/
void itc_systemio_iotbus_uart_init_stop_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_stop(h_uart);
	TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 16
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();
}
Ejemplo n.º 17
0
void tc_fs_smartfs_mksmartfs(void)
{
	int ret;
	ret = mksmartfs(SMARTFS_DEV_PATH, 1);
	TC_ASSERT_EQ("mksmartfs", ret, OK);
	ret = mksmartfs(INVALID_PATH, 1);
	TC_ASSERT_NEQ("mksmartfs", ret, OK);
	ret = mksmartfs(SMARTFS_DEV_PATH, 0);
	TC_ASSERT_EQ("mksmartfs", ret, OK);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 18
0
static void tc_pthread_pthread_detach(void)
{
	int ret_chk;
	pthread_t new_th;

	/* Create the thread */
	ret_chk = pthread_create(&new_th, NULL, do_nothing_thread, NULL);
	TC_ASSERT_EQ("pthread_create", ret_chk, OK);

	/* Wait 'till the thread returns.
	 * The thread could have ended by the time we try to join, so
	 * don't worry about it, just so long as other errors don't
	 * occur. The point is to make sure the thread has ended execution. */
	ret_chk = pthread_join(new_th, NULL);
	TC_ASSERT_NEQ("pthread_join", ret_chk, EDEADLK);

	/* Detach the non-existant thread. */
	ret_chk = pthread_detach(new_th);
	TC_ASSERT_NEQ("pthread_detach", ret_chk, OK);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 19
0
/**
* @testcase          :itc_net_netdb_getaddrinfo_n
* @brief             :getaddrinfo() returns one or more addrinfo structures
* @scenario          :passing invalid node and service
* @apicovered        :getaddrinfo()
* @precondition      :None
* @postcondition     :None
*/
static void itc_net_netdb_getaddrinfo_n(void)
{

	struct addrinfo hints;
	struct addrinfo *res;
	int ret;

	memset(&hints, 0, sizeof hints);
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_DGRAM;

	ret = getaddrinfo(NULL, NULL, &hints, &res);
	TC_ASSERT_NEQ("getaddrinfo", ret, 0);
	TC_SUCCESS_RESULT();
}
Ejemplo n.º 20
0
/**
* @testcase         itc_systemio_iotbus_uart_set_baudrate_p
* @brief            sets uart baud rate
* @scenario         sets uart baud rate
* @apicovered       iotbus_uart_set_baudrate
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
void itc_systemio_iotbus_uart_set_baudrate_p(void)
{
	int i_baudrate = 115200;
	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_set_baudrate(h_uart, i_baudrate);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_baudrate", 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();;
}
Ejemplo n.º 21
0
/**
* @testcase         itc_systemio_iotbus_uart_set_baudrate_n
* @brief            sets uart baud rate
* @scenario         sets uart baud rate
* @apicovered       iotbus_uart_set_baudrate
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
static void itc_systemio_iotbus_uart_set_baudrate_n(void)
{
	int i_baudrate = -115200; // invalid baudrate
	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_set_baudrate(h_uart, i_baudrate);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_baudrate", ret, IOTBUS_ERROR_INVALID_PARAMETER, iotbus_uart_stop(h_uart));

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

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 22
0
void itc_mqtt_connect_disconnect_n(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, NULL, CONFIG_ITC_MQTT_BROKER_PORT, 0);
	TC_ASSERT_EQ("mqtt_connect", res, -1);

	//MQTT Disconnect
	res = mqtt_disconnect(g_mqtt_client_handle);
	TC_ASSERT_EQ_CLEANUP("mqtt_disconnect", res, 0, mqtt_deinit_client(g_mqtt_client_handle));

	res = mqtt_deinit_client(g_mqtt_client_handle);
	TC_ASSERT_EQ("mqtt_deinit_client", res, 0);
	TC_SUCCESS_RESULT();
}
Ejemplo n.º 23
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));
	}
Ejemplo n.º 24
0
/**
* @testcase         itc_systemio_iotbus_uart_set_flowcontrol_p
* @brief            set flow control settings
* @scenario         set flow control settings
* @apicovered       iotbus_uart_set_flowcontrol
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
void itc_systemio_iotbus_uart_set_flowcontrol_p(void)
{
	int i_size = 4;
	int ret = IOTBUS_ERROR_NONE;
	int rtscts[4][2] = { {1, 0}, {0, 1}, {1, 1}, {0, 0} };
	int index = 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]);
		TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_flowcontrol", 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();
}
Ejemplo n.º 25
0
static void utc_taskmanager_getinfo_with_group_n(void)
{
	tm_appinfo_list_t *ret;
	ret = (tm_appinfo_list_t *)task_manager_getinfo_with_group(TM_INVALID_HANDLE, TM_NO_RESPONSE);
	TC_ASSERT_EQ("task_manager_getinfo_with_group", ret, NULL);

	if (!sample_info) {
		sample_info = (tm_appinfo_t *)task_manager_getinfo_with_handle(tm_sample_handle, TM_RESPONSE_WAIT_INF);
		TC_ASSERT_NEQ("task_manager_getinfo_with_handle", sample_info, NULL);
	}

	ret = (tm_appinfo_list_t *)task_manager_getinfo_with_group(sample_info->tm_gid, TM_INVALID_TIMEOUT);
	TC_ASSERT_EQ("task_manager_getinfo_with_group", ret, NULL);

	ret = (tm_appinfo_list_t *)task_manager_getinfo_with_group(sample_info->tm_gid, TM_NO_RESPONSE);
	TC_ASSERT_EQ("task_manager_getinfo_with_group", ret, NULL);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 26
0
void itc_mqtt_connect_disconnect_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);

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

	//MQTT Disconnect
	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();
}
Ejemplo n.º 27
0
/**
* @testcase         itc_systemio_iotbus_uart_set_mode_p
* @brief            sets byte size, parity bit and stop bits
* @scenario         sets byte size, parity bit and stop bits
* @apicovered       iotbus_uart_set_mode
* @precondition     initializes uart_context
* @postcondition    closes uart_context
*/
void itc_systemio_iotbus_uart_set_mode_p(void)
{
	int i_bytesize = 8;
	int i_stop_bits = 1;
	int ret = IOTBUS_ERROR_NONE;
	int mode[] = { IOTBUS_UART_PARITY_NONE, IOTBUS_UART_PARITY_EVEN, IOTBUS_UART_PARITY_ODD };
	int i_modes = sizeof(mode) / sizeof(int);
	int index = 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);
		TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_mode", 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();
}
Ejemplo n.º 28
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();
}
Ejemplo n.º 29
0
/**
* @testcase        :itc_net_listen_n_after_socket_close
* @brief           :listen for socket connections and limit the queue of incoming connections
* @scenario        :create socket, bind, close socket and then listen
* @apicovered      :listen()
* @precondition    :open socket, close socket
* @postcondition   :none
*/
static void itc_net_listen_n_after_socket_close(void)
{
	struct sockaddr_in sa;
	int socket_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
	TC_ASSERT_GEQ("socket", socket_fd, CONFIG_NFILE_DESCRIPTORS);

	memset(&sa, 0, sizeof sa);

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

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

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

	ret = listen(socket_fd, BACK_LOG);
	TC_ASSERT_NEQ("listen", ret, 0);

	TC_SUCCESS_RESULT();
}
Ejemplo n.º 30
0
/**
* @fn                   :tc_timer_timer_set_get_time
* @brief                :arm/disarm and fetch state of POSIX per-process timer
* @scenario             :arm/disarm and fetch state of POSIX per-process timer
* API's covered         :timer_create, timer_settime, timer_gettime
* Preconditions         :Creation of timer_id(timer_create)
* Postconditions        :none
* @return               :void
*/
static void tc_timer_timer_set_get_time(void)
{
	int ret_chk = ERROR;
	clockid_t clockid = CLOCK_REALTIME;
	struct sigevent st_sigevent;
	struct itimerspec st_timer_spec_set;
	struct itimerspec st_timer_spec_get;
	timer_t timer_id;

	/* 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_timer_spec_set.it_interval.tv_sec = 1;
	st_timer_spec_set.it_interval.tv_nsec = 0;	/* interval; */
	st_timer_spec_set.it_value.tv_sec = 1;
	st_timer_spec_set.it_value.tv_nsec = 0;	/* expire; */

	ret_chk = timer_settime(timer_id, 0, &st_timer_spec_set, NULL);	/* Flag =1 :TIMER_ABSTIME */
	TC_ASSERT_EQ_ERROR_CLEANUP("timer_settime", ret_chk, OK, errno, timer_delete(timer_id));

	usleep(USECINT);

	ret_chk = timer_gettime(timer_id, &st_timer_spec_get);
	TC_ASSERT_EQ_ERROR_CLEANUP("timer_gettime", ret_chk, OK, errno, timer_delete(timer_id));
	TC_ASSERT_GEQ_CLEANUP("timer_gettime", st_timer_spec_get.it_interval.tv_nsec, st_timer_spec_set.it_interval.tv_nsec, timer_delete(timer_id));
	TC_ASSERT_GEQ_CLEANUP("timer_gettime", st_timer_spec_get.it_interval.tv_sec, st_timer_spec_set.it_interval.tv_sec, timer_delete(timer_id));
	TC_ASSERT_GEQ_CLEANUP("timer_gettime", st_timer_spec_get.it_value.tv_sec, st_timer_spec_set.it_value.tv_sec, timer_delete(timer_id));
	TC_ASSERT_GEQ_CLEANUP("timer_gettime", st_timer_spec_get.it_value.tv_nsec, st_timer_spec_set.it_value.tv_nsec, timer_delete(timer_id));

	timer_delete(timer_id);
	TC_SUCCESS_RESULT();
}