コード例 #1
0
ファイル: testlibrbd.c プロジェクト: tcloud/ceph
int main(int argc, const char **argv) 
{
  rados_t cluster;
  rados_ioctx_t io_ctx;
  rbd_image_t image;

  srand(time(0));

  assert(rados_create(&cluster, NULL) == 0);
  assert(rados_conf_parse_argv(cluster, argc, argv) == 0);
  assert(rados_conf_read_file(cluster, NULL) == 0);
  assert(rados_connect(cluster) == 0);

  if (rados_pool_lookup(cluster, TEST_POOL) != -ENOENT) {
    int r = rados_pool_delete(cluster, TEST_POOL);
    printf("rados_pool_delete returned %d\n", r);
  }
  int r = rados_pool_create(cluster, TEST_POOL);
  printf("rados_pool_create returned %d\n", r);

  assert(rados_ioctx_create(cluster, TEST_POOL, &io_ctx) == 0);
  test_ls(io_ctx, 0);

  test_create_and_stat(io_ctx, TEST_IMAGE, MB_BYTES(1));
  assert(rbd_open(io_ctx, TEST_IMAGE, &image, NULL) == 0);

  test_ls(io_ctx, 1, TEST_IMAGE);
  test_ls_snaps(image, 0);

  test_create_snap(image, TEST_SNAP);
  test_ls_snaps(image, 1, TEST_SNAP, MB_BYTES(1));
  test_resize_and_stat(image, MB_BYTES(2));
  test_io(io_ctx, image);

  test_create_snap(image, TEST_SNAP "1");
  test_ls_snaps(image, 2, TEST_SNAP, MB_BYTES(1), TEST_SNAP "1", MB_BYTES(2));

  test_delete_snap(image, TEST_SNAP);
  test_ls_snaps(image, 1, TEST_SNAP "1", MB_BYTES(2));

  test_delete_snap(image, TEST_SNAP "1");
  test_ls_snaps(image, 0);

  test_io_to_snapshot(io_ctx, image, MB_BYTES(2));
  assert(rbd_close(image) == 0);

  test_create_and_stat(io_ctx, TEST_IMAGE "1", MB_BYTES(2));
  test_ls(io_ctx, 2, TEST_IMAGE, TEST_IMAGE "1");

  test_delete(io_ctx, TEST_IMAGE);
  test_ls(io_ctx, 1, TEST_IMAGE "1");

  test_delete(io_ctx, TEST_IMAGE "1");
  test_ls(io_ctx, 0);

  rados_ioctx_destroy(io_ctx);
  rados_shutdown(cluster);

  return 0;
}
コード例 #2
0
ファイル: shm_test.c プロジェクト: haveTryTwo/utils
int main(int argc, char* argv[])
{
    if (argc < 2)
    {
        goto help;
    }

    if (strcmp(argv[1], "create") == SHM_OK)
    {
        return test_creat();
    }
    else if (strcmp(argv[1], "write") == SHM_OK)
    {
        return test_write();
    }
    else if (strcmp(argv[1], "read") == SHM_OK)
    {
        return test_read();
    }
    else if (strcmp(argv[1], "delete") == SHM_OK)
    {
        return test_delete();
    }

help:
    printf("Usage: shm COMMAND\n\n"
           "The most used commands are:\n" 
           "create      Create a share memory\n"
           "write       Write something into the share memory\n"
           "read        Read something from the share memory\n"
           "delete      Delete the share memory\n"
            );

    return SHM_FAILED;
}
コード例 #3
0
ファイル: test.c プロジェクト: dpt/PrivateEye
int atom_test(void)
{
  error   err;
  atom_set_t *d;

  d = atom_create_tuned(1, 12);
  if (d == NULL)
    return 1;

  err = test_add(d);
  if (err)
    return 1;

  err = test_to_string(d);
  if (err)
    return 1;

  err = test_to_string_and_len(d);
  if (err)
    return 1;

  err = test_delete(d);
  if (err)
    return 1;

  err = test_to_string_and_len(d);
  if (err)
    return 1;

  err = test_add(d);
  if (err)
    return 1;

  err = test_to_string(d);
  if (err)
    return 1;

  err = test_rename(d);
  if (err)
    return 1;

  err = test_to_string(d);
  if (err)
    return 1;

  err = test_to_string_and_len(d);
  if (err)
    return 1;

  err = test_random(d);
  if (err)
    return 1;

  atom_destroy(d);

  return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: echoi/Coupling_SNAC_CHILD
int main() {
        CTest *t = NULL;

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

        return 0;
}
コード例 #5
0
int main()
{
      d_linked_list *list = build_list();
      
      print_list(list);
      test_delete(list, 1);
      test_delete(list, 2);
      test_delete(list, 7);
      test_delete(list, 3);
      test_delete(list, 4);
      test_delete(list, 5);
      test_add(list, 13);
      test_delete(list, 6);
      test_delete(list, 8);
      test_delete(list, 9);
      print_list(list);
      test_add(list, 1337);
      print_list(list);
      test_delete(list, 2);
      test_add(list, 98);
      print_list(list);
      
      return 0;
}
コード例 #6
0
int main(){

	ps = new PagingSystem(32, 1024, 4);

	test_dir();

	test_store();

	test_dir();

	test_delete();

	test_dir();
	
	test_read();
}
コード例 #7
0
int main() {
    try {
        //auto start = std::chrono::system_clock::now();
        test_get();
        test_post();
        test_put();
        test_delete();
        test_connectfail();
        //auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start);
        //std::cout << elapsed.count() << std::endl;
    } catch (const std::exception& e) {
        std::cout << e.what() << std::endl;
        return 1;
    }
    return 0;
}
コード例 #8
0
ファイル: client.c プロジェクト: hriships/DS_ALGO
int main(int args, char *arg[]) {

	list_t *list = NULL;
	list = test_create();
	test_insert(list);
	test_delete(list);
	test_examine(list);
	test_distroy(&list);
	list = test_create();	
	test_sorting(list);
	test_distroy(&list);
    test_concat_lists();
	test_merge_lists();
	test_reverse_lists();

	exit (EXIT_SUCCESS);
}
コード例 #9
0
ファイル: gridfs.c プロジェクト: cmjonze/rpm5_tarballs
int main(int argc, char *argv[])
{
    const char * test_server = (argc > 1 ? argv[1] : TEST_SERVER);
/* See https://jira.mongodb.org/browse/CDRIVER-126
 * on why we exclude this test from running on WIN32 */
 
    test_basic();
    test_delete();
    test_streaming();
    test_random_write();
    test_random_write2();
    
#if defined(RUN_TEST_LARGE)
    test_large();
#endif


    return 0;
}
コード例 #10
0
ファイル: test.c プロジェクト: sid0/critbit89
/* Program entry point */
int main(int argc, char **argv)
{
	cb_tree_t tree = cb_tree_make();

	printf("%d ", ++tnum); fflush(stdout);
	test_insert(&tree);

	printf("%d ", ++tnum); fflush(stdout);
	test_complete(&tree, sizeof(dict) / sizeof(const char *));

	printf("%d ", ++tnum); fflush(stdout);
	test_insert_dup(&tree);

	printf("%d ", ++tnum); fflush(stdout);
	test_contains(&tree);

	printf("%d ", ++tnum); fflush(stdout);
	test_delete(&tree);

	printf("%d ", ++tnum); fflush(stdout);
	cb_tree_clear(&tree);
	test_insert(&tree);
	test_complete(&tree, sizeof(dict) / sizeof(const char *));

	printf("%d ", ++tnum); fflush(stdout);
	test_delete_all(&tree);

	printf("%d ", ++tnum); fflush(stdout);
	test_complete(&tree, 0);

	printf("%d ", ++tnum); fflush(stdout);
	cb_tree_clear(&tree);
	test_empty(&tree);

	printf("%d ", ++tnum); fflush(stdout);
	test_insert(&tree);
	test_prefixes(&tree);

	cb_tree_clear(&tree);
	printf("ok\n");
	return 0;
}
コード例 #11
0
ファイル: main.c プロジェクト: ShabbyX/shDS
int main(int argc, char **argv)
{
	bool good = true;

	srand(time(NULL));
	if (argc < 2)
	{
		if (generate_data(RANDOM_SIZE))
			goto exit_no_mem;
	}
	else
	{
		if (read_data(argv[1]))
			goto exit_bad_input;
	}

	good = good && test_init() == 0;
	good = good && test_append() == 0;
	good = good && test_duplicate() == 0;
	good = good && test_links() == 0;
	good = good && test_prepend() == 0;
	good = good && test_links() == 0;
	good = good && test_concat() == 0;
	good = good && test_links() == 0;
	good = good && test_break() == 0;
	good = good && test_links() == 0;
	good = good && test_insert() == 0;
	good = good && test_links() == 0;
	good = good && test_compare() == 0;
	good = good && test_delete() == 0;
	good = good && test_links() == 0;
	good = good && test_clear() == 0;
	good = good && test_free() == 0;

	cleanup_data();

	return good?EXIT_SUCCESS:EXIT_FAILURE;
exit_bad_input:
exit_no_mem:
	cleanup_data();
	return EXIT_FAILURE;
}
コード例 #12
0
ファイル: test_list.c プロジェクト: Linhua-Sun/newick_utils
int main()
{
	int failures = 0;
	printf("Starting linked list test...\n");
	failures += test_create();
	failures += test_append_element();
	failures += test_prepend_element();
	failures += test_prepend_five();
	failures += test_append_five();
	failures += test_add_many();
	failures += test_add_struct();
	failures += test_append_list();
	failures += test_append_list_empty();
	failures += test_prepend_list();
	failures += test_prepend_list_empty();
	failures += test_reverse();
	failures += test_shallow_copy();
	failures += test_shift();
	failures += test_reduce();
	failures += test_insert();
	failures += test_insert_at_head();
	failures += test_insert_at_tail();
	failures += test_delete();
	failures += test_delete_at_head();
	failures += test_delete_at_tail();
	failures += test_index();
	failures += test_destroy();
	failures += test_clear();
	failures += test_llist_index_of_f();
	failures += test_to_array();
	failures += test_delete_last();
	failures += test_delete_last_few();
	if (0 == failures) {
		printf("All tests ok.\n");
	} else {
		printf("%d test(s) FAILED.\n", failures);
		return 1;
	}

	return 0;
}
コード例 #13
0
ファイル: llist_test.c プロジェクト: jkeary/linked_list_in_C
int main() 
{
  // Allocate memory for a new list
  llist *list = (llist *)malloc(sizeof(llist));
  if (list == NULL) {
    printf("Unable to allocate memory\n");
    exit(1);
  }
  init_list(list);

  int option = 0;
  bool quit = false;

  // Display menu and prompt user for action
  while (!quit) {
    option = prompt_user();
    switch (option) {
      case 1:
	printf("\n\tNumber of elements in list: %d\n", list->length);
	print(list);
	break;
      case 2: test_insert(list);
	break;
      case 3: test_delete(list);
	break;
      case 4: test_search(list);
	break;
      case 5: print_backwards(list);
	break;
      case 6: printf("Bye.\n");
	quit = true;
	break;
    }
  }
  // call function to free memory for entire list
  delete_list(list);

  return 0;
}
コード例 #14
0
main()
{
	char *repo_name = "pds_demo.dat";
	char *ndx_name = "pds_demo.ndx";
	int status;

	status = pds_open( repo_name, ndx_name );
	if( status != PDS_SUCCESS ){
		fprintf(stderr, "pds_open failed: %d\n", status);
		exit(1);
	}
	test_store();
	test_search();

	// Close and reopen to check if the index got saved properly
	pds_close();
	status = pds_open( repo_name, ndx_name );
	if( status != PDS_SUCCESS ){
		fprintf(stderr, "pds_open failed: %d\n", status);
		exit(1);
	}
	test_search();
	test_delete();
	pds_close();

	status = pds_open( repo_name, ndx_name );
	if( status != PDS_SUCCESS ){
		fprintf(stderr, "pds_open failed: %d\n", status);
		exit(1);
	}
	test_search();

	pds_close();

	printf("Program terminated successfully\n");
}
コード例 #15
0
ファイル: test2.c プロジェクト: vhbarros/aed1
int main () {
	test_create();
	test_insert();
	test_delete();
	test_diverse();
}
コード例 #16
0
int main(int argc, char *argv[])
{
    int i;
    int tmp;
    int index1;
    int index2;
    int result;


    log_init();

    if (argc > 1) {
        if (strcasecmp(argv[1], "multi") == 0 || strcmp(argv[1], "1") == 0) {
            skiplist_type = SKIPLIST_TYPE_MULTI;
        }
    }
    printf("skiplist type: %s\n",
            skiplist_type == SKIPLIST_TYPE_FLAT ? "flat" : "multi");

    numbers = (int *)malloc(sizeof(int) * COUNT);
    srand(time(NULL));
    for (i=0; i<COUNT; i++) {
        numbers[i] = i + 1;
    }

    for (i=0; i<COUNT; i++) {
        index1 = LAST_INDEX * (int64_t)rand() / (int64_t)RAND_MAX;
        index2 = LAST_INDEX * (int64_t)rand() / (int64_t)RAND_MAX;
        if (index1 == index2) {
            continue;
        }
        tmp = numbers[index1];
        numbers[index1] = numbers[index2];
        numbers[index2] = tmp;
    }

    fast_mblock_manager_init();
    result = skiplist_init_ex(&sl, LEVEL_COUNT, compare_func,
            free_test_func, MIN_ALLOC_ONCE, skiplist_type);
    if (result != 0) {
        return result;
    }

    test_insert();
    printf("\n");

    fast_mblock_manager_stat_print(false);

    test_delete();
    printf("\n");
    assert(instance_count == 0);

    test_insert();
    printf("\n");

    skiplist_destroy(&sl);
    assert(instance_count == 0);

    test_stable_sort();

    printf("pass OK\n");
    return 0;
}
コード例 #17
0
ファイル: example9.c プロジェクト: tejaspathak/librdf
static int test_hash_funtionality(librdf_world *world, librdf_hash *h) {
        librdf_hash *ch;
  const char *test_put_array[]={
      "colour","yellow",
      "age", "new",
      "size", "large",
      "colour", "green",
      "fruit", "banana",
      "colour", "yellow",
  };

  const char *test_delete_array[]={
      "invalidkey", "invalidvalue",
      "colour", "yellow",
      "colour", "aaaaaaaaaaaaainvalidvalue",
      "colour", "zzzzzzzzzzzzzinvalidvalue",
      "colour", NULL,
      "fruit", NULL,
      "size", "large",
      "age", "new",
  };

  const char *test_get_values_for_key="colour";
  int len, i;

  for (i=1; i<=STRESS_TEST_PUT_ITERATION; i++) {
    fprintf(stdout, "put iteration.. %d\n", i);

    /* Test put */
    len = sizeof(test_put_array)/sizeof(const char*);
    test_put(world, h, test_put_array, len);
  }

  fprintf(stdout, "total values: %d.", librdf_hash_values_count(h));

  /* Test get all keys only */
  fprintf(stdout, "all hash keys:");
  librdf_hash_print_keys(h, stdout);
  fputc('\n', stdout);

  /* Test get all values of given key */
  fprintf(stdout, "all values of key '%s'=", test_get_values_for_key);
  librdf_hash_print_values(h, test_get_values_for_key, stdout);
  fputc('\n', stdout);

  /* Test cloning hash */
  fprintf(stdout, "cloning hash\n");
  ch = librdf_new_hash_from_hash(h);
  if(ch) {
    fprintf(stdout, "clone success. values count %d\n", librdf_hash_values_count(ch));
    fprintf(stdout, "resulting: ");
    librdf_hash_print(ch, stdout);
    fputc('\n', stdout);

    librdf_hash_close(ch);
    librdf_free_hash(ch);
  } else {
    fprintf(stderr, "Failed to clone hash\n");
  }

  /* Test delete */
  len = sizeof(test_delete_array)/sizeof(const char*);
  test_delete(world, h, test_delete_array, len);

  /* Test string related features */
  test_string_manipulation(world, h);

  return 0;
}
コード例 #18
0
int main()
{
    INDEX *idx = NULL;
    //test case for idx_create
    /*
        printf ("test case for idx_create() ********************************\n");
        idx = idx_create("index_testfile", 2000);
        if (NULL == idx) {
            printf ("idx_fd is null.\n");
            return -1;
        }
        printf("is_change:%d\ncur_kv_count:%d\nhashhead_size:%llu\nnode_pool_size:%llu\n",
                idx->is_change, idx->cur_kv_count, idx->hashhead_size, idx->node_pool_size);
        printf("free_node_pool_size:%llu\nfree_node_count:%llu\ntimestamp:%llu\n",
                idx->free_node_pool_size, idx->free_node_count, idx->timestamp);
        if (NULL == idx->hash_head || NULL == idx->node_pool || NULL == idx->free_node_pool) {
            printf ("idx some struct is NULL.\n");
            return -1;
        }
        idx_exit(idx);
        idx = NULL;
    */
    printf ("***********************************************************\n\n\n");

    //test case for idx_load
    printf ("test case for idx_load() ********************************\n");
    idx = idx_load("index_testfile");
    if (NULL == idx) {
        printf ("idx_fd is null.\n");
        return -1;
    }
    printf("is_change:%d\ncur_kv_count:%d\nhashhead_size:%llu\nnode_pool_size:%llu\n",
           idx->is_change, idx->cur_kv_count, idx->hashhead_size, idx->node_pool_size);
    printf("free_node_pool_size:%llu\nfree_node_count:%llu\ntimestamp:%llu\n",
           idx->free_node_pool_size, idx->free_node_count, idx->timestamp);
    if (NULL == idx->hash_head || NULL == idx->node_pool || NULL == idx->free_node_pool) {
        printf ("idx some struct is NULL.\n");
        return -1;
    }
    printf ("***********************************************************\n\n\n");

    //test case for insert
    printf ("test case for insert ********************************\n");
    test_insert(idx, 1101, 1806);
    test_insert(idx, 1102, 1807);
    test_insert(idx, 1102, 1808);
    test_insert(idx, 1102, 1807);
    printf ("***********************************************************\n\n\n");

    //test case for select
    printf ("test case for select ********************************\n");
    test_select(idx, 1806);
    test_select(idx, 1807);
    test_select(idx, 1806);
    test_select(idx, 1806);
    test_select(idx, 1805);
    test_select(idx, 1808);
    printf ("***********************************************************\n\n\n");

    //test case for delete
    printf ("test case for delete ********************************\n");
    test_delete(idx, 1111, 1806);
    test_delete(idx, 1112, 1806);
    printf ("***********************************************************\n\n\n");


    idx_exit(idx);
    return 0;
}
コード例 #19
0
int main()
{
    MYSQL *conn;
    MYSQL_RES *res;
    MYSQL_ROW row;
    conn = mysql_init(NULL);
    if(!mysql_real_connect(conn, server,
                user, password, database, 0, NULL, 0))
    {
        printf("%s\n", mysql_error(conn));
        return 0;
    }
    printf("print the type of benchmark:\n");
    printf("1.insert\n2.delete\n3.update\n4.replace\n");
    int type;
    scanf("%d", &type);
    switch(type)
    {
        case 1:
            int insert_type, insert_time, insert_size;
            printf("1.simple insert\n2.concurrency insert\n");
            scanf("%d", &insert_type);
            printf("print the time you wanto insert:\n");
            scanf("%d", &insert_time);
            printf("print the size you wanto insert:\n1.1B\n2.1K\n3.1M\nOthers\n");
            scanf("%d", &insert_size);
            if(insert_size == 1)
                insert_size = SIZE_1B;
            else if(insert_size == 2)
                insert_size = SIZE_1K;
            else if(insert_size == 3)
                insert_size = SIZE_1M;
            if(insert_type == 1)
                test_insert(conn, insert_time, insert_size, 0);
            else
            {
                test_concurrency_insert(conn, insert_time, insert_size);
            }
            break;
        case 2:
            test_delete(conn);
            break;
        case 3:
            printf("print the update size\n1.1B\n2.1K\n3.1M\nOther\n");
            int update_size;
            scanf("%d", &update_size);
            if(update_size == 1)
                update_size = SIZE_1B;
            else if(update_size == 2)
                update_size = SIZE_1K;
            else if(update_size == 3)
                update_size = SIZE_1M;
            test_update(conn, update_size);
            break;
        case 4:
            int rep_insert_time, rep_insert_type, rep_insert_size;
            printf("print the time you wanto insert:\n");
            scanf("%d", &rep_insert_time);
            printf("print the size you wanto insert:\n1.1B\n2.1K\n3.1M\nOthers\n");
            scanf("%d", &rep_insert_size);
            if(rep_insert_size == 1)
                rep_insert_size = SIZE_1B;
            else if(rep_insert_size == 2)
                rep_insert_size = SIZE_1K;
            else if(rep_insert_size == 3)
                rep_insert_size = SIZE_1M;
            test_insert(conn, rep_insert_time, rep_insert_size, 1);
            break;
    }
    return 0;
}