Beispiel #1
0
END_TEST

START_TEST(test_group_both_set)
{
    struct tevent_req *req;

    test_ctx->ctx->allow_groups = discard_const(ulist_1);
    test_ctx->ctx->deny_groups = discard_const(ulist_1);

    req = simple_access_check_send(test_ctx, test_ctx->ev,
                                   test_ctx->ctx, "u1");
    fail_unless(test_ctx != NULL, "Cannot create request\n");
    tevent_req_set_callback(req, simple_access_check_done, test_ctx);

    test_loop(test_ctx);
    test_ctx->done = false;

    fail_unless(test_ctx->error == EOK, "access_simple_check failed.");
    fail_unless(test_ctx->access_granted == false,
                "Access granted while user is in deny list.");

    req = simple_access_check_send(test_ctx, test_ctx->ev,
                                   test_ctx->ctx, "u3");
    fail_unless(test_ctx != NULL, "Cannot create request\n");
    tevent_req_set_callback(req, simple_access_check_done, test_ctx);

    test_loop(test_ctx);

    fail_unless(test_ctx->error == EOK, "access_simple_check failed.");
    fail_unless(test_ctx->access_granted == false,
                "Access granted while user is not in allow list.");
}
Beispiel #2
0
int			get_next_line(int const fd, char **line)
{
	static int		index = -1;
	static char		str[BUFF_SIZE + 4];
	static int		ret;
	int				i;

	ft_init_var(&i, line);
	ft_test_index(&index, &ret, fd, str);
	while (ret != -1 && str[i + index] != '\n' && str[i + index] != EOF)
	{
		if (i + index == ret)
		{
			if (ft_join(line, i, index, str) != -1
					&& (i = test_loop(&ret, str, fd)) == 1)
				return (0);
			if (i == -1)
				return (-1);
			index = 0;
		}
		else
			i++;
	}
	if (ret == -1 || ft_join(line, i, index, str) == -1)
		return (-1);
	index = i + index + 1;
	return (1);
}
Beispiel #3
0
int
main(int argc, char *argv[])
{
	int raw_sock, tcp_sock, udp_sock;

	if (geteuid() != 0)
		errx(-1, "FAIL: root privilege required");

	raw_sock = socket(PF_INET, SOCK_RAW, 0);
	if (raw_sock == -1)
		err(-1, "FAIL: socket(PF_INET, SOCK_RAW)");

	tcp_sock = socket(PF_INET, SOCK_STREAM, 0);
	if (raw_sock == -1)
		err(-1, "FAIL: socket(PF_INET, SOCK_STREAM)");

	udp_sock = socket(PF_INET, SOCK_DGRAM, 0);
	if (raw_sock == -1)
		err(-1, "FAIL: socket(PF_INET, SOCK_DGRAM)");

	test_ttl(raw_sock, tcp_sock, udp_sock);
	test_loop(raw_sock, tcp_sock, udp_sock);
	test_if(raw_sock, tcp_sock, udp_sock);
	test_addr(raw_sock, tcp_sock, udp_sock);

	close(udp_sock);
	close(tcp_sock);
	close(raw_sock);

	test_udp();

	return (0);
}
void CSocketControl::setSocket(char* inputString)
{
  if (inputString == 0) return;
  uint8_t len = strlen(inputString);
  if (len < 2 || len > 10) return;
  // interpret commands
  if (!strcmp(inputString, "alloff"))
    for (int i = 1; i <= 4; i++)
      setSocket(i, 1);
    else
      if (!strcmp(inputString, "allon"))
        for (int i = 1; i <= 4; i++)
          setSocket(i, 0);
      else
        if (!strcmp(inputString, "looptest"))
          test_loop();
        else
        {
          uint8_t socket = 9;
          uint8_t state = 0;
          
          socket = inputString[0] - 48;
          state = inputString[1] - 49;
        
          setSocket(socket, state);
        }
}
Beispiel #5
0
int main(void)
{
	bool ret = true;

	talloc_disable_null_tracking();
	talloc_enable_null_tracking();

	ret &= test_ref1();
	ret &= test_ref2();
	ret &= test_ref3();
	ret &= test_ref4();
	ret &= test_unlink1(); 
	ret &= test_misc();
	ret &= test_realloc();
	ret &= test_realloc_child(); 
	ret &= test_steal(); 
	ret &= test_move(); 
	ret &= test_unref_reparent();
	ret &= test_realloc_fn(); 
	ret &= test_type();
	ret &= test_lifeless(); 
	ret &= test_loop();
	ret &= test_free_parent_deny_child(); 
	ret &= test_talloc_ptrtype();

	if (ret) {
		ret &= test_speed();
	}
	ret &= test_autofree();

	if (!ret)
		return -1;
	return 0;
}
Beispiel #6
0
int main()
{
    std::vector<std::string> x;
    std::cout << "=== testing random-access iterators with <: ===\n";
    test_loop(x, no_compare(), 25);
    std::cout << "=== testing random-access iterators with compare: ===\n";
    test_loop(x, cmp(), 25);
    
    std::list<std::string> y;
    std::cout << "=== testing bidirectional iterators with <: ===\n";
    test_loop(y, no_compare(), 25);
    std::cout << "=== testing bidirectional iterators with compare: ===\n";
    test_loop(y, cmp(), 25);
    std::cerr << "******TEST PASSED******\n";
    return 0;
}
Beispiel #7
0
static void test_loop_win32(void)
{
	const struct pomp_loop_ops *loop_ops = NULL;
	loop_ops = pomp_loop_set_ops(&pomp_loop_win32_ops);
	test_loop();
	test_loop_wakeup();
	test_loop_idle();
	pomp_loop_set_ops(loop_ops);
}
int simpleTest( void )
{
	int x;
	// loop from {0.0} to {1.1000000} stepping by tv_sec by 1 and tv_usec by 100000
	x = test_loop( 0, 0,   1,  MICROSECONDS,   1,  MICROSECONDS / 10 );

	// x = test_loop( 0, 0,   5,  MICROSECONDS,   1,  MICROSECONDS / 1000 );
	// x = test_loop( 0, 0,  -5, -MICROSECONDS,  -1, -MICROSECONDS / 1000 );

	return x;
}
Beispiel #9
0
/*****************************************************************************
 * main()
 */
int main(int argc, char *argv[])
{
    pj_status_t status;

    if (init_options(argc, argv) != 0)
	return 1;


    /* Init */
    status = test_init();
    if (status != PJ_SUCCESS)
	return 1;

    /* Print parameters */
    PJ_LOG(3,(THIS_FILE, "Starting simulation. Parameters: "));
    PJ_LOG(3,(THIS_FILE, "  Codec=%.*s, tx_ptime=%d, rx_ptime=%d",
	      (int)g_app.cfg.codec.slen,
	      g_app.cfg.codec.ptr,
	      g_app.cfg.tx_ptime,
	      g_app.cfg.rx_ptime));
    PJ_LOG(3,(THIS_FILE, " Loss avg=%d%%, min_burst=%d, max_burst=%d",
	      g_app.cfg.tx_pct_avg_lost,
	      g_app.cfg.tx_min_lost_burst,
	      g_app.cfg.tx_max_lost_burst));
    PJ_LOG(3,(THIS_FILE, " TX jitter min=%dms, max=%dms",
	      g_app.cfg.tx_min_jitter, 
	      g_app.cfg.tx_max_jitter));
    PJ_LOG(3,(THIS_FILE, " RX jb init:%dms, min_pre=%dms, max_pre=%dms, max=%dms",
	      g_app.cfg.rx_jb_init,
	      g_app.cfg.rx_jb_min_pre,
	      g_app.cfg.rx_jb_max_pre,
	      g_app.cfg.rx_jb_max));
    PJ_LOG(3,(THIS_FILE, " RX sound burst:%d frames",
	      g_app.cfg.rx_snd_burst));
    PJ_LOG(3,(THIS_FILE, " DTX=%d, PLC=%d",
	      g_app.cfg.tx_dtx, g_app.cfg.rx_plc));

    /* Run test loop */
    test_loop(g_app.cfg.duration_msec);

    /* Print statistics */
    PJ_LOG(3,(THIS_FILE, "Simulation done"));
    PJ_LOG(3,(THIS_FILE, " TX packets=%u, dropped=%u/%5.1f%%",
	      g_app.tx->state.tx.total_tx,
	      g_app.tx->state.tx.total_lost,
	      (float)(g_app.tx->state.tx.total_lost * 100.0 / g_app.tx->state.tx.total_tx)));

    /* Done */
    test_destroy();

    return 0;
}
Beispiel #10
0
int main(){
  test_loop();
  test_task();
  test_reduction();
  test_gmove();
  test_bcast();
  test_reflect();
  test_barrier();
  
#pragma xmp task on t(1)
  printf("PASS\n");
 
 return 0;
}
Beispiel #11
0
END_TEST

START_TEST(test_group_case)
{
    struct tevent_req *req;

    test_ctx->ctx->allow_groups = discard_const(glist_1_case);
    test_ctx->ctx->deny_groups = NULL;

    req = simple_access_check_send(test_ctx, test_ctx->ev,
                                   test_ctx->ctx, "u1");
    fail_unless(test_ctx != NULL, "Cannot create request\n");
    tevent_req_set_callback(req, simple_access_check_done, test_ctx);

    test_loop(test_ctx);
    test_ctx->done = false;

    fail_unless(test_ctx->error == EOK, "access_simple_check failed.");
    fail_unless(test_ctx->access_granted == false,
                "Access granted for user with different case "
                "in case-sensitive domain");

    test_ctx->ctx->domain->case_sensitive = false;

    req = simple_access_check_send(test_ctx, test_ctx->ev,
                                   test_ctx->ctx, "u1");
    fail_unless(test_ctx != NULL, "Cannot create request\n");
    tevent_req_set_callback(req, simple_access_check_done, test_ctx);

    test_loop(test_ctx);
    test_ctx->done = false;

    fail_unless(test_ctx->error == EOK, "access_simple_check failed.");
    fail_unless(test_ctx->access_granted == true,
                "Access denied for user with different case "
                "in case-sensitive domain");
}
Beispiel #12
0
int main(void) {

    test_loop(NO_NEW_CTX, NO_CTX_DESTROY);
    test_loop(NEW_CTX, CTX_DESTROY);
    test_loop(NEW_CTX, NO_CTX_DESTROY);
    test_loop(NO_NEW_CTX, CTX_DESTROY);

    printf("\n[+] Total libfko function calls (before compounded tests): %d\n\n",
            spa_calls);

    printf("[+] Running compounded tests via: test_loop_compounded()...\n");
    test_loop_compounded();

    printf("\n[+] Total compounded function calls: %d\n", spa_compounded_calls);
    printf("[+] Total libfko function calls (after compounded tests): %d\n\n",
            spa_calls);

#if FUZZING_INTERFACES
    printf("[+] libfko fuzzing by setting SPA buffer manually...\n");
    spa_encoded_msg_fuzzing();
#endif

    return 0;
}
Beispiel #13
0
int
main(void)
{
    test_event_base_new_failure();
    test_evdns_base_new_failure();
    test_evsignal_failure();
    test_proper_destruction();
    test_event_add_failure();
    test_event_del_failure();
    test_multiple_break_loop_on_sigint_();
    test_loop();
    test_break_loop();
    test_sigint_correctly_handled();
    test_sigint_correctly_handled_once_removed();
}
Beispiel #14
0
void main()
{
 Super(0);
 rlvc_open_system();
 rlkb_open_keyboard();
/* rlkb_debug_on();        un-rem this for debuggers! */
 rlsc_open_video();
 rlsd_open_sound();
 rltrk_open_tracker();

 init_screen_space();
 load_all_files();
 test_loop();
 
 rltrk_close_tracker();
 rlsd_close_sound();
 rlsc_close_video();	
 rlkb_close_keyboard();
 rlvc_close_system();
}
Beispiel #15
0
END_TEST

START_TEST(test_unknown_user)
{
    struct tevent_req *req;

    test_ctx->ctx->allow_users = discard_const(ulist_1);
    test_ctx->ctx->deny_users = NULL;

    req = simple_access_check_send(test_ctx, test_ctx->ev,
                                   test_ctx->ctx, "foo");
    fail_unless(test_ctx != NULL, "Cannot create request\n");
    tevent_req_set_callback(req, simple_access_check_done, test_ctx);

    test_loop(test_ctx);
    test_ctx->done = false;

    fail_unless(test_ctx->error == EOK, "access_simple_check failed.");
    fail_unless(test_ctx->access_granted == false,
                "Access granted for user not present in domain");
}
Beispiel #16
0
bool torture_local_talloc(struct torture_context *tctx)
{
	bool ret = true;

	setlinebuf(stdout);

	talloc_disable_null_tracking();
	talloc_enable_null_tracking();

	ret &= test_ref1();
	ret &= test_ref2();
	ret &= test_ref3();
	ret &= test_ref4();
	ret &= test_unlink1(); 
	ret &= test_misc();
	ret &= test_realloc();
	ret &= test_realloc_child(); 
	ret &= test_steal(); 
	ret &= test_move(); 
	ret &= test_unref_reparent();
	ret &= test_realloc_fn(); 
	ret &= test_type();
	ret &= test_lifeless(); 
	ret &= test_loop();
	ret &= test_free_parent_deny_child(); 
	ret &= test_talloc_ptrtype();
	ret &= test_talloc_free_in_destructor();
	ret &= test_pool();

	if (ret) {
		ret &= test_speed();
	}
	ret &= test_autofree();

	return ret;
}
int main(int argc, char* argv[])
{
	int r = 0, semid;

	parse_args(argc, argv);

	if (argc - optind != 1) {
		print_usage();
		exit(EXIT_FAILURE);
	}

	if (use_id && create == 1) {
		fprintf(stderr, "** incompatible options used: -c and -i\n");
		exit(EXIT_FAILURE);
	}

	if (create == 1) {
		semid = create_sem(argv[optind], nbmembers);
		if (semid == -1)
			r = semid;
	} else {
		if (use_id) {
			semid = atoi(argv[optind]);
		} else {
			semid = get_sem(argv[optind]);
		}

		if (create == -1) { /* user wants to remove the SEM object */
			int r;
			r = delete_sem(semid);
			if (r)
				exit(EXIT_FAILURE);

			exit(EXIT_SUCCESS);
		}
	}

	if (semid == -1)
		exit(EXIT_FAILURE);

	switch (todo) {
	case ADD:
		r = add_to_member(semid, member, blocking, undo, delta);
		break;
	case SHOW:
		r = display_sem(semid);
		break;
	case TESTLOOP:
		r = test_loop(semid, undo);
		break;
	case NOTHING:
		if (create == 0) {
			print_usage();
			r = -1;
		}
		break;
	}

	if (r)
		exit(EXIT_FAILURE);

	exit(EXIT_SUCCESS);
}
Beispiel #18
0
int main(void)
{
    struct test_Parameters test_para;
    int i;
    int test_order_array_size = 0;
    formatting_card();

    if (init_res(&test_para) < 0)
	exit(0);

    if (init_result_flag(&test_para) < 0)
	exit(0);

    if (init_sdl(&test_para) < 0)
	exit(0);
#ifdef H350
    init_key_pad();
#endif
    test_para.test_offset = -1;
    test_para.select_mode = False;
    while(1)
    {
	result_show(&test_para);
	if( select_test_key_loop(&test_para) == False )
	    break;
    }

    test_order_array_size = sizeof(test_order_array) / sizeof(test_orders_);
    debug_print("test order array size is %d\n",test_order_array_size);
#ifdef H350
    /*flush_screen(1);*/
#endif
    if(test_para.total_num > 0 && test_para.total_num <= test_order_array_size)
    {
	if(test_para.select_mode == True)
	{
	    debug_print("test_offset is %d\n",test_para.test_offset);
	    test_loop(&test_para,test_para.test_offset,test_order_array_size);
	}
	else
	{
	    for(i = 0; i < test_para.total_num; i++)
		test_loop(&test_para,i,test_order_array_size);
	}
    }
    else
    {
	debug_print("Get test order num error!\n");
    }

    /*result_show(&test_para);*/
    /*press_A_go_on();*/
#ifdef H350
    /*flush_screen(0);*/
    deinit_key_pad();
#endif
    deinit_res(&test_para);
    deinit_result_conf();
    deinit_sdl();
    return 0;
}
Beispiel #19
0
void IridiumSBD::main_loop(int argc, char *argv[])
{
	CDev::init();

	pthread_mutex_init(&_tx_buf_mutex, NULL);
	pthread_mutex_init(&_rx_buf_mutex, NULL);

	int arg_i = 3;
	int arg_uart_name = 0;

	while (arg_i < argc) {
		if (!strcmp(argv[arg_i], "-d")) {
			arg_i++;
			arg_uart_name = arg_i;

		} else if (!strcmp(argv[arg_i], "-v")) {
			PX4_WARN("verbose mode ON");
			_verbose = true;
		}

		arg_i++;
	}

	if (arg_uart_name == 0) {
		PX4_WARN("no Iridium SBD modem UART port provided!");
		_task_should_exit = true;
		return;
	}

	if (open_uart(argv[arg_uart_name]) != SATCOM_UART_OK) {
		PX4_WARN("failed to open UART port!");
		_task_should_exit = true;
		return;
	}

	// disable flow control
	write_at("AT&K0");

	if (read_at_command() != SATCOM_RESULT_OK) {
		PX4_WARN("modem not responding");
		_task_should_exit = true;
		return;
	}

	// disable command echo
	write_at("ATE0");

	if (read_at_command() != SATCOM_RESULT_OK) {
		PX4_WARN("modem not responding");
		_task_should_exit = true;
		return;
	}

	param_t param_pointer;

	param_pointer = param_find("ISBD_READ_INT");
	param_get(param_pointer, &_param_read_interval_s);

	param_pointer = param_find("ISBD_SBD_TIMEOUT");
	param_get(param_pointer, &_param_session_timeout_s);

	if (_param_session_timeout_s < 0) {
		_param_session_timeout_s = 60;
	}

	param_pointer = param_find("ISBD_STACK_TIME");
	param_get(param_pointer, &_param_stacking_time_ms);

	if (_param_stacking_time_ms < 0) {
		_param_stacking_time_ms = 0;
	}

	VERBOSE_INFO("read interval: %d s", _param_read_interval_s);
	VERBOSE_INFO("SBD session timeout: %d s", _param_session_timeout_s);
	VERBOSE_INFO("SBD stack time: %d ms", _param_stacking_time_ms);

	while (!_task_should_exit) {
		switch (_state) {
		case SATCOM_STATE_STANDBY:
			standby_loop();
			break;

		case SATCOM_STATE_CSQ:
			csq_loop();
			break;

		case SATCOM_STATE_SBDSESSION:
			sbdsession_loop();
			break;

		case SATCOM_STATE_TEST:
			test_loop();
			break;
		}

		if (_new_state != _state) {
			VERBOSE_INFO("SWITCHING STATE FROM %s TO %s", satcom_state_string[_state], satcom_state_string[_new_state]);
			_state = _new_state;
			publish_iridium_status();

		} else {
			publish_iridium_status();
			usleep(100000);	// 100ms
		}
	}
}