Exemplo n.º 1
0
int main(int argc, char** argv) {

    CClass *t1 = NULL;
    CClass *t2 = NULL;
    t1 = test_new(5);
    test_testfunc(t1);
    
    t2 = test_new(8);
    test_testfunc(t2);
    
    test_testfunc(t1);
    
    func();
    return (EXIT_SUCCESS);
}
Exemplo n.º 2
0
/* Test several threads running (*body)(struct test *m) for increasing settings
   of m->iterations, until about timeout_s to 2*timeout_s seconds have elapsed.
   If extra!=NULL, run (*extra)(m) in an additional thread.  */
static void test(const char *name, void (*body)(void *m),
                 void (*extra)(void *m), int timeout_s) {
  gpr_int64 iterations = 1024;
  struct test *m;
  gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
  gpr_timespec time_taken;
  gpr_timespec deadline = gpr_time_add(
      start, gpr_time_from_micros(timeout_s * 1000000, GPR_TIMESPAN));
  fprintf(stderr, "%s:", name);
  while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
    iterations <<= 1;
    fprintf(stderr, " %ld", (long)iterations);
    m = test_new(10, iterations);
    if (extra != NULL) {
      gpr_thd_id id;
      GPR_ASSERT(gpr_thd_new(&id, extra, m, NULL));
      m->done++; /* one more thread to wait for */
    }
    test_create_threads(m, body);
    test_wait(m);
    if (m->counter != m->threads * m->iterations) {
      fprintf(stderr, "counter %ld  threads %d  iterations %ld\n",
              (long)m->counter, m->threads, (long)m->iterations);
      GPR_ASSERT(0);
    }
    test_destroy(m);
  }
  time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
  fprintf(stderr, " done %ld.%09d s\n", (long)time_taken.tv_sec,
          (int)time_taken.tv_nsec);
}
Exemplo n.º 3
0
int main(int argc, char** argv)
{
	printf("KEY META     TESTS\n");
	printf("==================\n\n");

	init (argc, argv);
	test_basic();
	test_iterate();
	test_size();
	test_uid();
	test_dup();
	test_comment();
	test_owner();
	test_mode();
	test_type();
	test_examples();
	test_copy();
	test_ro();
	test_new();
	test_copyall();


	printf("\ntest_ks RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

	return nbError;
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
    SpiceCoreInterface *core;
    Command *commands;
    int num_commands;
    int i;
    Test *test;

    spice_test_config_parse_args(argc, argv);
    sized = 0;
    for (i = 1 ; i < argc; ++i) {
        if (strcmp(argv[i], "sized") == 0) {
            sized = 1;
        }
        /* render last frame */
        if (strcmp(argv[i], "render") == 0) {
            render_last_frame = 1;
        }
    }
    srand(time(NULL));
    // todo: add args list of test numbers with explenations
    core = basic_event_loop_init();
    test = test_new(core);
    spice_server_set_streaming_video(test->server, SPICE_STREAM_VIDEO_ALL);
    test_add_display_interface(test);
    get_commands(&commands, &num_commands);
    test_set_command_list(test, commands, num_commands);
    basic_event_loop_mainloop();
    free(commands);
    return 0;
}
Exemplo n.º 5
0
int main(int argc, char *argv[]) {
    PQueue *q = NULL;
    Test *t = NULL;
    int i;

    srand(time(NULL));

    /* A priority Queue containing a maximum of 10 elements */
    q = pqueue_new(test_compare, 10);

    for(i = 0; i < 10; ++i) {
        /* Adding elements to priority Queue */
        t = test_new(rand());
        pqueue_minenqueue(q, t);
    }

    for(i = 0; i < 10; ++i) {
    	Test * buffer = (Test*)pqueue_mindequeue(q);          
        printf("%d - %s\n", buffer->priority, buffer->log);
        /* Free memory - me lazy */
    }

    /* Free memory - me lazy */

    return (0);
}
Exemplo n.º 6
0
int main(void)
{
    Test *t1;
    Test *t2;

    core = basic_event_loop_init();
    t1 = test_new(core);
    t2 = test_new(core);
    //spice_server_set_image_compression(server, SPICE_IMAGE_COMPRESSION_OFF);
    test_add_display_interface(t1);
    test_add_display_interface(t2);
    test_set_simple_command_list(t1, simple_commands, COUNT(simple_commands));
    test_set_simple_command_list(t2, simple_commands, COUNT(simple_commands));

    basic_event_loop_mainloop();
    return 0;
}
Exemplo n.º 7
0
void test_all()
{
	test_new();
	test_del();
	test_push();
	test_pop();
	test_peek();
}
Exemplo n.º 8
0
END_TEST

int main()
{
	SRunner *sr;
	Suite *s;
	TCase *tcase;
	test_new("protocol_http", &sr, &s);

	tcase = tcase_create("Sane");
	suite_add_tcase(s, tcase);
	tcase_add_checked_fixture(tcase, test_setup, test_teardown);
	tcase_add_test(tcase, test_http_sane);
	tcase_add_test(tcase, test_http_replace_poller);
	tcase_add_test(tcase, test_http_heartbeat);
	tcase_add_test(tcase, test_http_surrogate);
	tcase_add_test(tcase, test_http_iframe);
	tcase_add_test(tcase, test_http_long_uuid);

	tcase = tcase_create("Disabled");
	suite_add_tcase(s, tcase);
	tcase_add_checked_fixture(tcase, NULL, test_teardown);
	tcase_add_test(tcase, test_http_disabled);

	tcase = tcase_create("Edges");
	suite_add_tcase(s, tcase);
	tcase_add_checked_fixture(tcase, test_setup, test_teardown);
	tcase_add_test(tcase, test_http_edge_invalid_header_newlines);
	tcase_add_test(tcase, test_http_edge_partial_headers_0);
	tcase_add_test(tcase, test_http_edge_partial_headers_1);
	tcase_add_test(tcase, test_http_10);
	tcase_add_test(tcase, test_http_10_keepalive);
	tcase_add_test(tcase, test_http_11_connection_close);
	tcase_add_test(tcase, test_http_partial_body);
	tcase_add_test(tcase, test_http_tons_of_newlines);
	tcase_add_test(tcase, test_http_oversized_request);
	tcase_add_test(tcase, test_http_close_with_surrogate);
	tcase_add_test(tcase, test_http_close_on_replace);
	tcase_add_test(tcase, test_http_incoming_wait);
	tcase_add_test(tcase, test_http_incoming_no_wait);
	tcase_add_test(tcase, test_http_requests_on_same_socket);

	tcase = tcase_create("Errors");
	suite_add_tcase(s, tcase);
	tcase_add_checked_fixture(tcase, test_setup, test_teardown);
	tcase_add_test(tcase, test_http_error_uuid);
	tcase_add_test(tcase, test_http_error_not_post);
	tcase_add_test(tcase, test_http_error_not_http);
	tcase_add_test(tcase, test_http_error_invalid_content_length);
	tcase_add_test(tcase, test_http_error_content_length_too_big);
	tcase_add_test(tcase, test_http_error_no_content_length);
	tcase_add_test(tcase, test_http_error_invalid_upgrade);
	tcase_add_test(tcase, test_http_error_invalid_events);
	tcase_add_test(tcase, test_http_error_invalid_uuid);
	tcase_add_test(tcase, test_http_error_invalid_uuid_format);

	return test_do(sr);
}
Exemplo n.º 9
0
int main(void) {
    test_new();
    test_enqueue();
    test_dequeue();
    test_free();
    test_length();

    printf("All Tests Pass!!!\n");
    return 0;
}
Exemplo n.º 10
0
int main() {
        CTest *t = NULL;

        t = test_new(5);
        test_testfunc(t);
        test_delete(t);
        t = NULL;

        return 0;
}
Exemplo n.º 11
0
static gpointer
test_dup(gconstpointer data)
{
	const test_t *org = (const test_t *)data;
	test_t		 *test;

	test = (test_t *)test_new(NULL);
	test->op   = org->op;
	test->val1 = stnode_dup(org->val1);
	test->val2 = stnode_dup(org->val1);

	return (gpointer) test;
}
Exemplo n.º 12
0
int
main (void) {

	test_new ();
	test_import ();
	test_split ();
	test_replace ();
	test_copy ();
	test_cut ();
	test_search ();
	test_tail_head ();
	return 0;
}
Exemplo n.º 13
0
int
main (int   argc,
      char *argv[])
{
	/* run tests in legacy (pre-session support) mode */
	setenv ("UPSTART_NO_SESSIONS", "1", 1);

	test_new ();

	test_name ();
	test_from_name ();

	return 0;
}
Exemplo n.º 14
0
END_TEST

int main()
{
	SRunner *sr;
	Suite *s;
	TCase *tcase;
	test_new("coverage", &sr, &s);

	tcase = tcase_create("Coverage");
	suite_add_tcase(s, tcase);
	tcase_add_test(tcase, test_coverage_udp);

	return test_do(sr);
}
Exemplo n.º 15
0
int
main (int   argc,
      char *argv[])
{
	test_new ();
	test_alloc ();
	test_realloc ();
	test_free ();
	test_discard ();
	test_ref ();
	test_unref ();
	test_parent ();
	test_local ();

	return 0;
}
Exemplo n.º 16
0
void test_slist(struct cag_test_series *tests)
{
	test_it(tests);
	test_new(tests);
	test_prepend(tests);
	test_insert(tests);
	test_insertp(tests);
	test_distance(tests);
	test_front(tests);
	test_erase(tests);
	test_copy(tests);
	test_reverse(tests);
	test_copy_over(tests);
	test_sort(tests);
	test_find(tests);
}
Exemplo n.º 17
0
int main(void)
{
    Test *test;

    core = basic_event_loop_init();
    test = test_new(core);

    vmc_instance.base.sif = &base;
    spice_server_add_interface(test->server, &vmc_instance.base);

    ping_timer = core->timer_add(pinger, NULL);
    core->timer_start(ping_timer, ping_ms);

    basic_event_loop_mainloop();

    return 0;
}
Exemplo n.º 18
0
int main(void)
{
    Test *test;

    core = basic_event_loop_init();
    test = test_new(core);
    //spice_server_set_image_compression(server, SPICE_IMAGE_COMPRESSION_OFF);
    test_add_display_interface(test);
    test_add_agent_interface(test->server);
    test_set_simple_command_list(test, simple_commands, COUNT(simple_commands));

    ping_timer = core->timer_add(pinger, NULL);
    core->timer_start(ping_timer, ping_ms);

    basic_event_loop_mainloop();

    return 0;
}
Exemplo n.º 19
0
END_TEST

int main()
{
	SRunner *sr;
	Suite *s;
	TCase *tcase;
	test_new("protocol_config", &sr, &s);

	tcase = tcase_create("Options");
	suite_add_tcase(s, tcase);
	tcase_add_checked_fixture(tcase, NULL, test_teardown);
	tcase_add_test(tcase, test_config_invalid_sub_min_size_0);
	tcase_add_test(tcase, test_config_invalid_sub_min_size_1);
	tcase_add_test(tcase, test_config_invalid_cbs_max_age);
	tcase_add_test(tcase, test_config_invalid_public_address);

	return test_do(sr);
}
Exemplo n.º 20
0
void
TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
    TestBatchRunner_Plan(runner, (TestBatch*)self, 139);
    test_new(runner);
    test_Cat(runner);
    test_Clone(runner);
    test_Code_Point_At_and_From(runner);
    test_Contains_and_Find(runner);
    test_SubString(runner);
    test_Trim(runner);
    test_To_F64(runner);
    test_To_I64(runner);
    test_To_String(runner);
    test_To_Utf8(runner);
    test_To_ByteBuf(runner);
    test_Length(runner);
    test_Compare_To(runner);
    test_Starts_Ends_With(runner);
    test_Get_Ptr8(runner);
    test_iterator(runner);
    test_iterator_whitespace(runner);
    test_iterator_substring(runner);
}
Exemplo n.º 21
0
int main(int argc, char *argv[])
{
    FILE *f = fopen(TMP_FILE, "w");

    test_h t = test_new();

    test_put_f1(t, 4);

    assert(4 == test_get_f1(t));

    free(t);


  /*
  test t;
  t.f1 = 34;
  t.f6 = 48;
  t.f4 = -9834;
  test_write(&t, f);
 
  fclose(f);
  FILE *in = fopen(TMP_FILE, "r");

  test t2;
  test_read_new(&t2, in);

  assert(t2.f1 == 34);
  assert(t2.f6 == 48);
  assert(t2.f4 == -9834);

  fclose(in);

  execl("rm", "-f", TMP_FILE, NULL);
  */

    return 0;
}
Exemplo n.º 22
0
};

static SpiceCharDeviceInstance vmc_instance = {
    .subtype = "vdagent",
};

static void test_multiple_vmc_devices(void)
{
    SpiceCharDeviceInstance vmc_instances[2] = {
        { .subtype = "vdagent", },
        { .subtype = "vdagent", }
    };
    int status;

    SpiceCoreInterface *core = basic_event_loop_init();
    Test *test = test_new(core);

    g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*spice_server_char_device_add_interface: vdagent already attached");
    g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                          "*spice_server_remove_interface: assertion ?char_device->st != NULL'*");
    vmc_instances[0].base.sif = &vmc_interface.base;
    spice_server_add_interface(test->server, &vmc_instances[0].base);
    vmc_instances[1].base.sif = &vmc_interface.base;
    spice_server_add_interface(test->server, &vmc_instances[1].base);
    status = spice_server_remove_interface(&vmc_instances[1].base);
    g_assert_cmpint(status, ==, -1);
    status = spice_server_remove_interface(&vmc_instances[0].base);
    g_assert_cmpint(status, ==, 0);
    g_test_assert_expected_messages();
    test_destroy(test);
Exemplo n.º 23
0
int main(int argc, char **argv)
{
  for (size_t i = 0; i < 128; i++) {
    test_class(PN_OBJECT, i);
    test_class(PN_VOID, i);
    test_class(&noop_class, i);
  }

  for (size_t i = 0; i < 128; i++) {
    test_new(i, PN_OBJECT);
    test_new(i, &noop_class);
  }

  test_finalize();
  test_free();
  test_hashcode();
  test_compare();

  for (int i = 0; i < 1024; i++) {
    test_refcounting(i);
  }

  for (size_t i = 0; i < 4; i++) {
    test_list(i);
  }

  for (size_t i = 0; i < 4; i++) {
    test_list_refcount(i);
  }

  test_list_index();

  test_map();
  test_map_links();

  test_hash();

  test_string(NULL);
  test_string("");
  test_string("this is a test");
  test_string("012345678910111213151617181920212223242526272829303132333435363"
              "738394041424344454647484950515253545556575859606162636465666768");
  test_string("this has an embedded \000 in it");
  test_stringn("this has an embedded \000 in it", 28);

  test_string_format();
  test_string_addf();

  test_build_list();
  test_build_map();
  test_build_map_odd();

  for (int i = 0; i < 64; i++)
  {
    test_map_iteration(i);
  }

  test_list_inspect();
  test_map_inspect();
  test_list_compare();
  test_iterator();
  for (int seed = 0; seed < 64; seed++) {
    for (int size = 1; size <= 64; size++) {
      test_heap(seed, size);
    }
  }

  return 0;
}