Esempio n. 1
0
int main(int argc, char **argv)
{
    plan_tests(9 + 36 + 18);

    const GeoPoint a(Angle::degrees(fixed(7.7061111111111114)),
                     Angle::degrees(fixed(51.051944444444445)));
    const GeoPoint b(Angle::degrees(fixed(7.599444444444444)),
                     Angle::degrees(fixed(51.099444444444444)));
    const GeoPoint c(Angle::degrees(fixed(4.599444444444444)),
                     Angle::degrees(fixed(47.099444444444444)));

    fixed distance = Distance(a, b);
    ok1(distance > fixed(9130) && distance < fixed(9140));

    Angle bearing = Bearing(a, b);
    ok1(bearing.value_degrees() > fixed(304));
    ok1(bearing.value_degrees() < fixed(306));

    bearing = Bearing(b, a);
    ok1(bearing.value_degrees() > fixed(124));
    ok1(bearing.value_degrees() < fixed(126));

    distance = ProjectedDistance(a, b, a);
    ok1(is_zero(distance));
    distance = ProjectedDistance(a, b, b);
    ok1(distance > fixed(9120) && distance < fixed(9140));

    const GeoPoint middle(a.Longitude.Fraction(b.Longitude, fixed_half),
                          a.Latitude.Fraction(b.Latitude, fixed_half));
    distance = ProjectedDistance(a, b, middle);
    ok1(distance > fixed(9100/2) && distance < fixed(9140/2));

    fixed big_distance = Distance(a, c);
    ok1(big_distance > fixed(494000) && big_distance < fixed(495000));

    TestLinearDistance();

    return exit_status();
}
Esempio n. 2
0
int main(int argc, char **argv) {

	plan_tests(8);

	downtime_id = strtoul(svr_hostname, &end_ptr, 10);
	ok(downtime_id == 0, "hostname downtime_id is 0");
	ok(strlen(end_ptr) == 8, "hostname end_ptr is 8 chars");

	downtime_id = strtoul(svr_fqdn, &end_ptr, 10);
	ok(downtime_id == 0, "fqdn downtime_id is 0");
	ok(strlen(end_ptr) == 20, "fqdn end_ptr is 20 chars");

	downtime_id = strtoul(svr_ip, &end_ptr, 10);
	ok(downtime_id == 192, "ip downtime_id is 192");
	ok(strlen(end_ptr) == 8, "ip end_ptr is 8 chars");

	downtime_id = strtoul(svr_downtime_id, &end_ptr, 10);
	ok(downtime_id == 1234, "svr_downtime_id downtime_id is 1234");
	ok(strlen(end_ptr) == 0, "svr_downtime_id end_ptr is 0 chars");

	return exit_status();
}
Esempio n. 3
0
int main(void)
{
	int status;

	plan_tests(3);

	if (fork() == 0) {
		int fds[2];

		ok1(pipe(fds) == 0);
		io_new_conn(NULL, fds[0], setup_waiter, &status);
		io_loop(NULL, NULL);
		exit(1);
	}

	ok1(wait(&status) != -1);
	ok1(WIFSIGNALED(status));
	ok1(WTERMSIG(status) == SIGABRT);

	/* This exits depending on whether all tests passed */
	return exit_status();
}
Esempio n. 4
0
int main(void)
{
    plan_tests(9);

    MEMREF  act, x = strref("hello, world");
#   define S(s) ((s) ? (s) : "(null)")
#   define TRY(p, l, exp) \
        if (!ok(!refcmp(act = subref(x,p,l), strref(exp)), "(%d, %d): %s", p, l, S(exp))) \
            fprintf(stderr, "act[%"FSIZE"d]: %.*s\n", act.len, (int)act.len, S(act.ptr))

    TRY(  0,  5, "hello");
    TRY(  2,  3, "llo");
    TRY( -5,  2, "wo");
    TRY( -5, 99, "world");
    TRY(-12,  2, "he");
    TRY(  0, -1, x.ptr);    // (len) is unsigned, so (-1) is just a very big positive number.
    TRY(  0,  0, NULL);
    TRY(  1,  0, NULL);
    TRY(-13,  2, NULL);

    return exit_status();
}
Esempio n. 5
0
int main(int argc, char **argv)
{
  plan_tests(2095);

  glide_settings.SetDefaults();

  TestAll();

  glide_polar.SetMC(fixed(0.1));
  TestAll();

  glide_polar.SetMC(fixed(1));
  TestAll();

  glide_polar.SetMC(fixed(4));
  TestAll();

  glide_polar.SetMC(fixed(10));
  TestAll();

  return exit_status();
}
Esempio n. 6
0
int main(int argc, char **argv)
{
    if (argc < 3) {
        unsigned n = 100;
        if (argc > 1) {
            n = atoi(argv[1]);
        }
        TestTrace("test/data/09kc3ov3.igc", n);
    } else {
        assert(argc >= 3);
        unsigned n = atoi(argv[2]);
        plan_tests(n);

        for (unsigned i=2; i<2+n; i++) {
            unsigned nt = pow(2,i);
            char buf[100];
            sprintf(buf," trace size %d", nt);
            ok(TestTrace(argv[1], nt),buf, 0);
        }
    }
    return 0;
}
Esempio n. 7
0
int
main(int argc, char *argv[])
{
	unsigned int rc = 0;
	unsigned int side_effect = 0;

	rc = plan_tests(4);
	diag("Returned: %d", rc);

	rc = ok(1 == 1, "1 equals 1");	/* Should always work */
	diag("Returned: %d", rc);

	do {
		if(1) {
			rc = skip(1, "Testing skipping");
			continue;
		}
		
		side_effect++;

		ok(side_effect == 1, "side_effect checked out");

	} while(0);

	diag("Returned: %d", rc);

	skip_start(1 == 1, 1, "Testing skipping #2");

	side_effect++;
	rc = ok(side_effect == 1, "side_effect checked out");
	diag("Returned: %d", rc);

	skip_end;

	rc = ok(side_effect == 0, "side_effect is %d", side_effect);
	diag("Returned: %d", rc);

	return exit_status();
}
Esempio n. 8
0
int main(int argc, char *argv[])
{
	char **split, *str;
	void *ctx;

	plan_tests(16);
	split = strsplit(NULL, "hello  world", " ");
	ok1(talloc_array_length(split) == 4);
	ok1(!strcmp(split[0], "hello"));
	ok1(!strcmp(split[1], ""));
	ok1(!strcmp(split[2], "world"));
	ok1(split[3] == NULL);
	talloc_free(split);

	split = strsplit(NULL, "hello  world", "o ");
	ok1(talloc_array_length(split) == 6);
	ok1(!strcmp(split[0], "hell"));
	ok1(!strcmp(split[1], ""));
	ok1(!strcmp(split[2], ""));
	ok1(!strcmp(split[3], "w"));
	ok1(!strcmp(split[4], "rld"));
	ok1(split[5] == NULL);

	ctx = split;
	split = strsplit(ctx, "hello  world", "o ");
	ok1(talloc_parent(split) == ctx);
	talloc_free(ctx);

	str = strjoin(NULL, (char **)substrings, ", ");
	ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar, "));
	ctx = str;
	str = strjoin(ctx, (char **)substrings, "");
	ok1(!strcmp(str, "farbarbazbbazar"));
	ok1(talloc_parent(str) == ctx);
	talloc_free(ctx);

	return exit_status();
}				
Esempio n. 9
0
int main(void)
{
	char haystack1[] = "abcd\0efgh";
	char haystack2[] = "ab\0ab\0ab\0ab";
	char needle1[] = "ab";
	char needle2[] = "d\0e";

	/* This is how many tests you plan to run */
	plan_tests(19);

	ok1(memmem(haystack1, sizeof(haystack1), needle1, 2) == haystack1);
	ok1(memmem(haystack1, sizeof(haystack1), needle1, 3) == NULL);
	ok1(memmem(haystack1, sizeof(haystack1), needle2, 3) == (haystack1 + 3));

	ok1(memmem(haystack2, sizeof(haystack2), needle1, sizeof(needle1))
	    == haystack2);
	ok1(memmem(haystack2, sizeof(haystack2), needle2, 3) == NULL);

	ok1(memrchr(haystack1, 'a', sizeof(haystack1)) == haystack1);
	ok1(memrchr(haystack1, 'b', sizeof(haystack1)) == haystack1 + 1);
	ok1(memrchr(haystack1, 'c', sizeof(haystack1)) == haystack1 + 2);
	ok1(memrchr(haystack1, 'd', sizeof(haystack1)) == haystack1 + 3);
	ok1(memrchr(haystack1, 'e', sizeof(haystack1)) == haystack1 + 5);
	ok1(memrchr(haystack1, 'f', sizeof(haystack1)) == haystack1 + 6);
	ok1(memrchr(haystack1, 'g', sizeof(haystack1)) == haystack1 + 7);
	ok1(memrchr(haystack1, 'h', sizeof(haystack1)) == haystack1 + 8);
	ok1(memrchr(haystack1, '\0', sizeof(haystack1)) == haystack1 + 9);
	ok1(memrchr(haystack1, 'i', sizeof(haystack1)) == NULL);

	ok1(memrchr(haystack2, 'a', sizeof(haystack2)) == haystack2 + 9);
	ok1(memrchr(haystack2, 'b', sizeof(haystack2)) == haystack2 + 10);
	ok1(memrchr(haystack2, '\0', sizeof(haystack2)) == haystack2 + 11);

	ok1(memrchr(needle1, '\0', 2) == NULL);

	/* This exits depending on whether all tests passed */
	return exit_status();
}
Esempio n. 10
0
int main(int argc, char** argv)
{
  if (!parse_args(argc,argv)) {
    return 0;
  }

  plan_tests(16);

  Waypoints waypoints;

  ok(setup_waypoints(waypoints),"waypoint setup",0);

  unsigned size = waypoints.size();

  ok(test_lookup(waypoints,3),"waypoint lookup",0);
  ok(!test_lookup(waypoints,5000),"waypoint bad lookup",0);
  ok(test_nearest(waypoints),"waypoint nearest",0);
  ok(test_nearest_landable(waypoints),"waypoint nearest landable",0);
  ok(test_location(waypoints,true),"waypoint location good",0);
  ok(test_location(waypoints,false),"waypoint location bad",0);
  ok(test_range(waypoints,100)==1,"waypoint visit range 100m",0);
  ok(test_radius(waypoints,100)==1,"waypoint radius 100m",0);
  ok(test_range(waypoints,500000)== waypoints.size(),"waypoint range 500000m",0);
  ok(test_radius(waypoints,25000)<= test_range(waypoints,25000),"waypoint radius<range",0);

  // test clear
  waypoints.clear();
  ok(waypoints.size()==0,"waypoint clear",0);
  setup_waypoints(waypoints);
  ok(size == waypoints.size(),"waypoint setup after clear",0);

  ok(test_copy(waypoints),"waypoint copy",0);

  ok(test_erase(waypoints,3),"waypoint erase",0);
  ok(test_replace(waypoints,4),"waypoint replace",0);

  return exit_status();
}
Esempio n. 11
0
int main(int argc, char *argv[])
{
	unsigned int i;
	struct ntdb_context *ntdb;
	int flags[] = { NTDB_INTERNAL,
			NTDB_INTERNAL|NTDB_CONVERT,
			NTDB_CONVERT };
	NTDB_DATA key = ntdb_mkdata("key", 3);
	NTDB_DATA data = ntdb_mkdata("data", 4);

	failtest_init(argc, argv);
	failtest_hook = block_repeat_failures;
	failtest_exit_check = exit_check_log;

	failtest_suppress = true;
	plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1);
	for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
		ntdb = ntdb_open("run-12-check.ntdb", flags[i]|MAYBE_NOSYNC,
				 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
		ok1(ntdb);
		ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);

		/* This is what we really want to test: ntdb_check(). */
		failtest_suppress = false;
		if (!ok1(ntdb_check(ntdb, NULL, NULL) == 0))
			goto fail;
		failtest_suppress = true;

		ntdb_close(ntdb);
	}
	ok1(tap_log_messages == 0);
	failtest_exit(exit_status());

fail:
	failtest_suppress = true;
	ntdb_close(ntdb);
	failtest_exit(exit_status());
}
Esempio n. 12
0
int main(void)
{
    struct cdump_definitions *defs;
    const struct cdump_type *t, *t2;
    char *ctx = tal(NULL, char), *problems;

    /* This is how many tests you plan to run */
    plan_tests(16);

    defs = cdump_extract(ctx, "struct foo { struct bar *bar; };\n"
                         "struct bar { int x; };", &problems);
    ok1(defs);
    ok1(tal_parent(defs) == ctx);
    ok1(!problems);

    t = strmap_get(&defs->structs, "foo");
    ok1(t);
    t2 = strmap_get(&defs->structs, "bar");
    ok1(t2);

    ok1(t2->kind == CDUMP_STRUCT);
    ok1(streq(t2->name, "bar"));
    ok1(tal_count(t2->u.members) == 1);
    ok1(t2->u.members[0].type->kind == CDUMP_UNKNOWN);
    ok1(streq(t2->u.members[0].type->name, "int"));

    ok1(t->kind == CDUMP_STRUCT);
    ok1(streq(t->name, "foo"));
    ok1(tal_count(t->u.members) == 1);
    ok1(streq(t->u.members[0].name, "bar"));
    ok1(t->u.members[0].type->kind == CDUMP_POINTER);
    ok1(t->u.members[0].type->u.ptr == t2);

    tal_free(ctx);

    /* This exits depending on whether all tests passed */
    return exit_status();
}
Esempio n. 13
0
int main(int argc, char** argv) {
  // default arguments
  verbose=1;  
  
  if (!parse_args(argc,argv)) {
    return 0;
  }

  TaskBehaviour task_behaviour;
  TaskEventsPrint default_events(verbose);
  GlidePolar glide_polar(fixed_two);

  Waypoints waypoints;
  setup_waypoints(waypoints);

  TaskManager task_manager(default_events,
                           task_behaviour,
                           waypoints);
  task_manager.set_glide_polar(glide_polar);
  test_task(task_manager, waypoints, 0);

  plan_tests(1);

  ok(test_edit(task_manager, task_behaviour),
     "edit task", 0);

/*
  plan_tests(task_manager.task_size());

  // here goes, example, edit all task points
  SafeTaskEdit ste(task_manager, waypoints);
  for (unsigned i=0; i<task_manager.task_size(); i++) {
    ok(ste.edit(i),"edit tp",0);
    task_report(task_manager, "edit tp\n");
  }
*/
  return exit_status();
}
Esempio n. 14
0
int main(void)
{
	struct io_listener *l;
	int fd;
	struct timers timers;
	struct timer timer, *expired;
	struct addrinfo *addrinfo;

	/* This is how many tests you plan to run */
	plan_tests(7);

	fake_time = time_now();

	timers_init(&timers, fake_time);
	timer_init(&timer);
	timer_add(&timers, &timer,
		  timeabs_add(fake_time, time_from_sec(1000)));

	fd = make_listen_fd(PORT, &addrinfo);
	freeaddrinfo(addrinfo);
	ok1(fd >= 0);
	l = io_new_listener(NULL, fd, init_conn, NULL);
	ok1(l);

	fake_time.ts.tv_sec += 1000;
	ok1(io_time_override(get_fake_time) == time_now);
	ok1(io_loop(&timers, &expired) == NULL);

	ok1(expired == &timer);
	ok1(!timers_expire(&timers, fake_time));
	ok1(io_time_override(time_now) == get_fake_time);
	io_close_listener(l);

	timers_cleanup(&timers);

	/* This exits depending on whether all tests passed */
	return exit_status();
}
Esempio n. 15
0
int
main (int argc, char **argv)
{
	time_t rotation_time;
	struct stat stat_info, stat_new;

	plan_tests(14);

	rotation_time = (time_t)1242949698;

	log_rotation_method=5;
	ok(rotate_log_file(rotation_time) == ERROR, "Got error for a bad log_rotation_method");

	log_file="renamefailure";
	log_rotation_method=LOG_ROTATION_HOURLY;
	ok(rotate_log_file(rotation_time) == ERROR, "Got an error with rename");
	ok( strcmp(saved_dest, "var/nagios-05-22-2009-00.log")==0, "Got an hourly rotation" );

	log_file="var/nagios.log";
	log_rotation_method=LOG_ROTATION_HOURLY;
	ok(system("cp var/nagios.log.dummy var/nagios.log")==0, "Copied in dummy nagios.log for archiving");
	ok(rotate_log_file(rotation_time) == OK, "Log rotation should work happily");

	ok( system("diff var/nagios.log var/nagios.log.expected > /dev/null")==0, "Got correct contents of nagios.log");
	ok( system("diff var/nagios.log.dummy var/nagios-05-22-2009-00.log")==0, "nagios log archived correctly" );

	unlink("var/nagios-05-22-2009-00.log");
	ok( system("chmod 777 var/nagios.log")==0, "Changed mode of nagios.log" );
	ok( stat("var/nagios.log", &stat_info) == 0, "Got stat info for log file" );
	ok( rotate_log_file(rotation_time) == OK, "Log rotate to check if mode is retained" );
	ok( stat("var/nagios-05-22-2009-00.log", &stat_new) == 0, "Got new stat info for archived log file" );
	ok( stat_info.st_mode == stat_new.st_mode, "Mode for archived file same as original log file" );

	ok( stat("var/nagios.log", &stat_new) == 0, "Got new stat info for new log file" );
	ok( stat_info.st_mode == stat_new.st_mode, "Mode for new log file kept same as original log file" );

	return exit_status ();
}
int main(int argc, char *argv[])
{
	const int flags[] = { NTDB_DEFAULT, NTDB_NOMMAP,
			NTDB_CONVERT, NTDB_NOMMAP|NTDB_CONVERT };
	int i;
	struct ntdb_context *ntdb;
	NTDB_DATA key, data;

	plan_tests(sizeof(flags)/sizeof(flags[0]) * 5);
	agent = prepare_external_agent();
	if (!agent)
		err(1, "preparing agent");

	unlock_callback = after_unlock;
	for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
		diag("Test with %s and %s\n",
		     (flags[i] & NTDB_CONVERT) ? "CONVERT" : "DEFAULT",
		     (flags[i] & NTDB_NOMMAP) ? "no mmap" : "mmap");
		unlink(TEST_DBNAME);
		ntdb = ntdb_open(TEST_DBNAME, flags[i]|MAYBE_NOSYNC,
				 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
		ok1(ntdb);

		opened = true;
		ok1(ntdb_transaction_start(ntdb) == 0);
		key = ntdb_mkdata("hi", strlen("hi"));
		data = ntdb_mkdata("world", strlen("world"));

		ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);
		ok1(ntdb_transaction_commit(ntdb) == 0);
		ok(!errors, "We had %u open errors", errors);

		opened = false;
		ntdb_close(ntdb);
	}

	return exit_status();
}
Esempio n. 17
0
int main(int argc, char *argv[])
{
    plan_tests(12);

    /* --aaa without args. */
    opt_register_arg("-a|--aaa", test_arg, NULL, "aaa", "");
    ok1(!parse_args(&argc, &argv, "--aaa", NULL));
    ok1(strstr(err_output, ": --aaa: requires an argument"));
    free(err_output);
    err_output = NULL;
    ok1(!parse_args(&argc, &argv, "-a", NULL));
    ok1(strstr(err_output, ": -a: requires an argument"));
    free(err_output);
    err_output = NULL;

    /* Multiple */
    opt_register_arg("--bbb|-b|-c|--ccc", test_arg, NULL, "aaa", "");
    ok1(!parse_args(&argc, &argv, "--bbb", NULL));
    ok1(strstr(err_output, ": --bbb: requires an argument"));
    free(err_output);
    err_output = NULL;
    ok1(!parse_args(&argc, &argv, "-b", NULL));
    ok1(strstr(err_output, ": -b: requires an argument"));
    free(err_output);
    err_output = NULL;
    ok1(!parse_args(&argc, &argv, "-c", NULL));
    ok1(strstr(err_output, ": -c: requires an argument"));
    free(err_output);
    err_output = NULL;
    ok1(!parse_args(&argc, &argv, "--ccc", NULL));
    ok1(strstr(err_output, ": --ccc: requires an argument"));
    free(err_output);
    err_output = NULL;

    /* parse_args allocates argv */
    free(argv);
    return exit_status();
}
Esempio n. 18
0
int main(int argc, char *argv[])
{
	const char *myname = argv[0];

	plan_tests(7);

	/* Simple short arg.*/
	ok1(!parse_args(&argc, &argv, "-a", NULL));
	/* Simple long arg.*/
	ok1(!parse_args(&argc, &argv, "--aaa", NULL));

	/* Extra arguments preserved. */
	ok1(parse_args(&argc, &argv, "extra", "args", NULL));
	ok1(argc == 3);
	ok1(argv[0] == myname);
	ok1(strcmp(argv[1], "extra") == 0);
	ok1(strcmp(argv[2], "args") == 0);

	/* parse_args allocates argv */
	free(argv);

	return exit_status();
}
Esempio n. 19
0
int main(int _argc,const char *_argv[]){
  isaac64_ctx isaac64;
  int         i;
  int         j;

  /*This is how many tests you plan to run.*/
  plan_tests(2);
  isaac64_init(&isaac64,NULL,0);
  for(j=0;j<ISAAC64_SZ;j++)isaac64_next_uint64(&isaac64);
  for(i=0;i<2;i++){
    int nmatches;
    nmatches=0;
    for(j=0;j<ISAAC64_SZ;j++){
      nmatches+=isaac64_next_uint64(&isaac64)==STATEVEC64[(i+1)*ISAAC64_SZ-j-1];
    }
    ok1(nmatches==ISAAC64_SZ);
  }
  /*TODO: We should test the random float/double routines, but they are not
     guaranteed to return the same values on all platforms, because the number
     of bits in the mantissa may be different.
    Perhaps some simple statistical tests would suffice.*/
  return exit_status();
}
Esempio n. 20
0
int main(void)
{
	char *parent, *c;
	int i;

	plan_tests(1 + 3 * 100 + 98);

	parent = tal(NULL, char);
	ok1(parent);

	for (i = 0; i < 100; i++) {
		c = tal_arr(parent, char, 1);
		ok1(tal_resizez(&c, i));
		ok1(tal_count(c) == i);
		ok1(tal_parent(c) == parent);
		if (i > 1)
			ok1(c[i-1] == '\0');
	}
	tal_free(parent);

	tal_cleanup();
	return exit_status();
}
Esempio n. 21
0
int
main(int argc, char** argv)
{
  const char hc_path[] = "tmp/terrain";

  TCHAR jp2_path[4096];
  _tcscpy(jp2_path, PathName(hc_path));
  _tcscat(jp2_path, _T(DIR_SEPARATOR_S) _T("terrain.jp2"));

  TCHAR j2w_path[4096];
  _tcscpy(j2w_path, PathName(hc_path));
  _tcscat(j2w_path, _T(DIR_SEPARATOR_S) _T("terrain.j2w"));

  NullOperationEnvironment operation;
  RasterMap map(jp2_path, j2w_path, NULL, operation);
  do {
    map.SetViewCenter(map.GetMapCenter(), fixed(100000));
  } while (map.IsDirty());

  plan_tests(4 + NUM_SOL);
  ok(test_route(28, map), "route 28", 0);
  return exit_status();
}
Esempio n. 22
0
int main(void)
{
	int status;

	plan_tests(3);
	failtest_init(0, NULL);

	status = setjmp(exited);
	if (status == 0) {
		char *p = failtest_malloc(1, "run-malloc.c", 1);
		/* If we just segv, valgrind counts that as a failure.
		 * So kill ourselves creatively. */
		if (!p)
			kill(getpid(), SIGSEGV);
		fail("Expected child to crash!");
	} else {
		ok1(status == 2);
		ok1(strstr(output, "Killed by signal"));
		ok1(strstr(output, "--failpath=M\n"));
	}
	free(buffer);
	return exit_status();
}
Esempio n. 23
0
int main(int argc, char** argv) 
{
  // default arguments
  autopilot_parms.SetIdeal();

  if (!ParseArgs(argc,argv)) {
    return 0;
  }

#define NUM_FLIGHT 2

  plan_tests(NUM_FLIGHT*2);

  for (int i=0; i<NUM_FLIGHT; i++) {
    unsigned k = rand()%NUM_WIND;
    ok (test_aat(2,k), GetTestName("target ",2,k),0);
  }
  for (int i=0; i<NUM_FLIGHT; i++) {
    unsigned k = rand()%NUM_WIND;
    ok (test_aat(0,k), GetTestName("target ",0,k),0);
  }
  return exit_status();
}
Esempio n. 24
0
int main(int argc, char** argv) 
{
  // default arguments
  autopilot_parms.SetIdeal();

  if (!ParseArgs(argc,argv)) {
    return 0;
  }

#define NUM_TESTS 2

  plan_tests(NUM_TESTS);

  for (int j=0; j<NUM_TESTS; j++) {
    unsigned i = rand()%NUM_WIND;

    if (j+1==NUM_TESTS) {
      verbose=1;
    }
    ok (test_flight_times(7,i), GetTestName("flight times",7,i),0);
  }
  return exit_status();
}
Esempio n. 25
0
/* The code should barf on TDBs created with rwlocks. */
int main(int argc, char *argv[])
{
	struct tdb_context *tdb;
	unsigned int log_count;
	struct tdb_logging_context log_ctx = { log_fn, &log_count };

	plan_tests(4);

	/* We should fail to open rwlock-using tdbs of either endian. */
	log_count = 0;
	tdb = tdb_open_ex("test/rwlock-le.tdb", 0, 0, O_RDWR, 0,
			  &log_ctx, NULL);
	ok1(!tdb);
	ok1(log_count == 1);

	log_count = 0;
	tdb = tdb_open_ex("test/rwlock-be.tdb", 0, 0, O_RDWR, 0,
			  &log_ctx, NULL);
	ok1(!tdb);
	ok1(log_count == 1);

	return exit_status();
}
Esempio n. 26
0
int
main(int argc, char * const *argv)
{
    int guid_alt = argc > 1 && !strcmp(argv[1], "-g");
    /* {2cb56191-ee6f-432d-a377-853d3c6b949e} */
    CSSM_GUID s3dl_guid =
    {
        0x2cb56191, 0xee6f, 0x432d,
        { 0xa3, 0x77, 0x85, 0x3d, 0x3c, 0x6b, 0x94, 0x9e }
    };
    const CSSM_GUID *guid = guid_alt ? & s3dl_guid : &gGuidAppleFileDL;
    CSSM_DL_HANDLE dl;

    /* Total number of test cases in this file. */
    plan_tests(45);

    ok(cssm_attach(guid, &dl), "cssm_attach");
    ok(tests_begin(argc, argv), "setup");

    /* Run tests. */
    ok(test1(dl), "create close delete");
    ok(test2(dl), "create delete close");
    ok(test3(dl), "autocommit off create close delete");
    ok(test4(dl), "autocommit off create delete close");
    ok(test5(dl), "autocommit off create rollback close delete");
    ok(test6(dl), "autocommit off create rollback delete close");
    ok(test7(dl), "autocommit off create delete rollback close");
    ok(test8(dl), "delete non existant db");

    ok(cssm_detach(guid, dl), "cssm_detach");
    ok(tests_end(1), "cleanup");
TODO: {
        ok_leaks("leaks");
    }

    return 0;
}
Esempio n. 27
0
int main ( void ) {
	plan_tests(7);
	
	hx_nodemap* map	= hx_new_nodemap();
	ok1( map != NULL );
	
	hx_node* v1	= hx_new_node_variable( -1 );
	hx_node* v2	= hx_new_node_variable( -2 );
	hx_node* l1	= hx_new_node_literal("foo");
	hx_node* l2	= (hx_node*) hx_new_node_lang_literal("bar", "en-us");
	hx_node* l3	= (hx_node*) hx_new_node_dt_literal("7", "http://www.w3.org/2001/XMLSchema#integer");
	hx_node* r1	= (hx_node*) hx_new_node_resource("http://www.w3.org/2001/XMLSchema#integer");
	hx_node* b1	= (hx_node*) hx_new_node_blank("r1");
	
	hx_node_id id;
	
	{
		ok1( hx_nodemap_get_node_id( map, l1 ) == 0 );
		id	= hx_nodemap_add_node( map, l1 );
		ok1( id != 0 );
		ok1( hx_nodemap_get_node_id( map, l1 ) == id );
		
		ok1( hx_nodemap_remove_node( map, l1 ) == 0 );
		ok1( hx_nodemap_get_node_id( map, l1 ) == 0 );
	}
	
	{
		hx_node_id rid, bid;
		rid	= hx_nodemap_add_node( map, r1 );
		bid	= hx_nodemap_add_node( map, b1 );
		ok1( rid != bid );
	}
	
	
	hx_free_nodemap( map );
	return exit_status();
}
Esempio n. 28
0
int main(int argc, char **argv)
{
	int ret;
	int session_id;

	plan_tests(NUM_TESTS);

	diag("Live unit tests");

	ret = connect_viewer("localhost");
	ok(ret == 0, "Connect viewer to relayd");

	ret = establish_connection();
	ok(ret == 0, "Established connection and version check with %d.%d",
			VERSION_MAJOR, VERSION_MINOR);

	ret = list_sessions(&session_id);
	ok(ret > 0, "List sessions : %d session(s)", ret);

	ret = attach_session(session_id);
	ok(ret > 0, "Attach to session, %d streams received", ret);

	ret = get_metadata();
	ok(ret > 0, "Get metadata, received %d bytes", ret);

	ret = get_next_index();
	ok(ret == 0, "Get one index per stream");

	ret = get_data_packet(first_packet_stream_id, first_packet_offset,
			first_packet_len);
	ok(ret == first_packet_len,
			"Get one data packet for stream %d, offset %d, len %d",
			first_packet_stream_id, first_packet_offset,
			first_packet_len);

	return exit_status();
}
Esempio n. 29
0
int main(int argc, char *argv[])
{
	unsigned int i, j;
	struct tdb_context *tdb;
	int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
			TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
			TDB_NOMMAP|TDB_CONVERT,
			TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
			TDB_NOMMAP|TDB_VERSION1,
			TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
			TDB_CONVERT|TDB_VERSION1,
			TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };

	plan_tests(sizeof(flags) / sizeof(flags[0]) * 4 + 1);
	for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
		bool array[NUM_RECORDS];

		tdb = tdb_open("run-check-callback.tdb", flags[i],
			       O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
		ok1(tdb);
		if (!tdb)
			continue;

		ok1(store_records(tdb));
		for (j = 0; j < NUM_RECORDS; j++)
			array[j] = false;
		ok1(tdb_check(tdb, check, array) == TDB_SUCCESS);
		for (j = 0; j < NUM_RECORDS; j++)
			if (!array[j])
				break;
		ok1(j == NUM_RECORDS);
		tdb_close(tdb);
	}

	ok1(tap_log_messages == 0);
	return exit_status();
}
Esempio n. 30
0
int main(void)
{
	int state = 0;
	struct addrinfo *addrinfo;
	struct io_listener *l;
	int fd;

	/* This is how many tests you plan to run */
	plan_tests(10);
	fd = make_listen_fd(PORT, &addrinfo);
	ok1(fd >= 0);
	l = io_new_listener(NULL, fd, init_conn, &state);
	ok1(l);
	fflush(stdout);
	if (!fork()) {
		io_close_listener(l);
		fd = socket(addrinfo->ai_family, addrinfo->ai_socktype,
			    addrinfo->ai_protocol);
		if (fd < 0)
			exit(1);
		if (connect(fd, addrinfo->ai_addr, addrinfo->ai_addrlen) != 0)
			exit(2);
		close(fd);
		freeaddrinfo(addrinfo);
		exit(0);
	}
	freeaddrinfo(addrinfo);
	ok1(io_loop(NULL, NULL) == &state + 1);
	ok1(state == 2);
	io_close_listener(l);
	ok1(wait(&state));
	ok1(WIFEXITED(state));
	ok1(WEXITSTATUS(state) == 0);

	/* This exits depending on whether all tests passed */
	return exit_status();
}