Esempio n. 1
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. 2
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;
}
Esempio n. 3
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. 4
0
/**
* @testcase         itc_systemio_iotbus_uart_write_read_flush_multi_p_multi_handle
* @brief            write, read, flush data over uart bus with multi handler
* @scenario         write, read, flush data over uart bus with multi handler
* @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_p_multi_handle(void)
{
	int ret = IOTBUS_ERROR_NONE;
	char sz_input_text1[BUF_LEN] = "UART READ/WRITE ITC TESTING!";
	char sz_input_text2[BUF_LEN] = "UART READ/WRITE ITC TESTING1!";
	char sz_output_text[BUF_LEN];

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

	iotbus_uart_context_h h_uart2 = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ_CLEANUP("iotbus_uart_init", h_uart2, NULL, iotbus_uart_stop(h_uart1));

	ret = iotbus_uart_write(h_uart1, sz_input_text1, sizeof(sz_input_text1));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_write", ret < 0, false, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));

	ret = iotbus_uart_write(h_uart2, sz_input_text2, sizeof(sz_input_text2));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_write", ret < 0, false, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));

	usleep(MICROSECOND);

	ret = iotbus_uart_read(h_uart1, sz_output_text, sizeof(sz_output_text));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", ret < 0, false, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", strcmp(sz_input_text1, sz_output_text), 0, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));

	ret = iotbus_uart_read(h_uart2, sz_output_text, sizeof(sz_output_text));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", ret < 0, false, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_read", strcmp(sz_input_text2, sz_output_text), 0, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));

	ret = iotbus_uart_flush(h_uart1);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_flush", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));

	ret = iotbus_uart_flush(h_uart2);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_flush", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart1); iotbus_uart_stop(h_uart2));

	ret = iotbus_uart_stop(h_uart2);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart1));

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

	TC_SUCCESS_RESULT();
}
Esempio n. 5
0
/**
* @testcase         itc_systemio_iotbus_uart_init_stop_p_multi_handle
* @brief            initializes and closes uart_context
* @scenario         initializes and closes uart_context
* @apicovered       iotbus_uart_init, iotbus_uart_stop
* @precondition     none
* @postcondition    none
*/
static void itc_systemio_iotbus_uart_init_stop_p_multi_handle(void)
{
	int ret = IOTBUS_ERROR_NONE;

	iotbus_uart_context_h h_uart1 = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ("iotbus_uart_init1", h_uart1, NULL);

	iotbus_uart_context_h h_uart2 = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ_CLEANUP("iotbus_uart_init2", h_uart2, NULL, iotbus_uart_stop(h_uart1));

	iotbus_uart_context_h h_uart3 = iotbus_uart_init(DEVPATH);
	TC_ASSERT_NEQ_CLEANUP("iotbus_uart_init3", h_uart3, NULL, iotbus_uart_stop(h_uart2); iotbus_uart_stop(h_uart1));

	ret = iotbus_uart_stop(h_uart3);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_stop3", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart2); iotbus_uart_stop(h_uart1));

	ret = iotbus_uart_stop(h_uart2);
	TC_ASSERT_EQ_CLEANUP("iotbus_uart_stop2", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart1));

	ret = iotbus_uart_stop(h_uart1);
	TC_ASSERT_EQ("iotbus_uart_stop1", ret, IOTBUS_ERROR_NONE);

	TC_SUCCESS_RESULT();
}
Esempio n. 6
0
/**
* @fn                   :tc_timer_timer_initialize
* @brief                :Boot up configuration of the POSIX timer facility.
* @brief                :Boot up configuration of the POSIX timer facility.
* API's covered         :timer_initialize
* Preconditions         :Creation of timer_id(timer_create)
* Postconditions        :none
* @return               :void
*/
static void tc_timer_timer_initialize(void)
{
	timer_t timer_id;
	clockid_t clockid = CLOCK_REALTIME;
	struct sigevent st_sigevent;
	FAR struct posix_timer_s *timer;
	FAR struct posix_timer_s *next;

	int initalloc_cnt = 0;
	int initfree_cnt = 0;
	int createalloc_cnt = 0;
	int createfree_cnt = 0;
	int finalalloc_cnt = 0;
	int finalfree_cnt = 0;

	/* Set and enable alarm */
	st_sigevent.sigev_notify = SIGEV_SIGNAL;
	st_sigevent.sigev_signo = sig_no;
	st_sigevent.sigev_value.sival_ptr = &timer_id;

	/* check the count for g_alloctimers and g_freetimers after timer_initialize */
	timer_initialize();

	for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) {
		next = timer->flink;
		initalloc_cnt++;
	}

	for (timer = (FAR struct posix_timer_s *)g_freetimers.head; timer; timer = next) {
		next = timer->flink;
		initfree_cnt++;
	}

	/* check the count for g_alloctimers and g_freetimers after create now they change */
	timer_create(clockid, &st_sigevent, &timer_id);

	for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) {
		next = timer->flink;
		createalloc_cnt++;
	}

	for (timer = (FAR struct posix_timer_s *)g_freetimers.head; timer; timer = next) {
		next = timer->flink;
		createfree_cnt++;
	}

	/* check the count for g_alloctimers and g_freetimers after timer_initialize now they change to original value */
	timer_initialize();

	for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) {
		next = timer->flink;
		finalalloc_cnt++;
	}

	for (timer = (FAR struct posix_timer_s *)g_freetimers.head; timer; timer = next) {
		next = timer->flink;
		finalfree_cnt++;
	}

	TC_ASSERT_EQ_CLEANUP("timer_initialise", initalloc_cnt, finalalloc_cnt, timer_delete(timer_id));
	TC_ASSERT_EQ_CLEANUP("timer_initialise", initfree_cnt, finalfree_cnt, timer_delete(timer_id));
	TC_ASSERT_NEQ_CLEANUP("timer_initialise", createalloc_cnt, finalalloc_cnt, timer_delete(timer_id));
	TC_ASSERT_NEQ_CLEANUP("timer_initialise", createfree_cnt, finalfree_cnt, timer_delete(timer_id));

	timer_delete(timer_id);
	TC_SUCCESS_RESULT();
}