コード例 #1
0
ファイル: main.c プロジェクト: noppelmax/passgen
int main(void) {
  const struct CMUnitTest tests_calcSHA[] = {
    cmocka_unit_test(test_calcSHA_general),
    cmocka_unit_test(test_calcSHA_is_deterministic),
    cmocka_unit_test(test_calcSHA_hardcheck),
    cmocka_unit_test(test_calcSHA_lengthcheck),
    cmocka_unit_test(test_calcSHA_errorhandling),
    cmocka_unit_test(test_calcSHA_is_repeatable),
  };

  return cmocka_run_group_tests(tests_calcSHA, NULL, NULL);
}
コード例 #2
0
ファイル: main.c プロジェクト: ifzz/libbitpack
int main(void)
{
	const struct CMUnitTest tests[] =
	{
		cmocka_unit_test( test_unpack_uint64_be_aligned ),
		cmocka_unit_test( test_unpack_uint64_le_aligned ),
		cmocka_unit_test( test_unpack_uint32_be_byaligned ),
		cmocka_unit_test( test_unpack_uint32_le_byaligned ),
		cmocka_unit_test( test_unpack_uint32_be_unaligned ),
		cmocka_unit_test( test_unpack_uint32_le_unaligned ),
	};
	return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #3
0
ファイル: main.c プロジェクト: pakhomova/repository
int main(void) {
   const struct CMUnitTest tests[] =
    {
        cmocka_unit_test (new_void_zeroCount),
        cmocka_unit_test (insert_oneSentence_countOnePlaceZeroFormatTwo),
        cmocka_unit_test (delete_hasOneInertedSentence_CountZero),
        cmocka_unit_test (writeFormat_insertOneSentenceWithThirdFormat_CountOnePlaceZeroFormatThird),
        cmocka_unit_test (writeFormat_insertOneSentenceWithFirstFormat_CountZero),
        cmocka_unit_test (writeFormat_insertTwoSentenceWithFirstAndSecondFormat_CountOnePlaceZeroFormatSecond)
    };
    return cmocka_run_group_tests(tests, NULL, NULL);
    return 0;
}
コード例 #4
0
int main(){
 const struct CMUnitTest tests[] =
    {
        cmocka_unit_test(new_oneValue_sizeOneValue),
        cmocka_unit_test(newRand_void_sizeInRangeZeroToTen),
        cmocka_unit_test(setSize_oneValue_sizeOneValue),
        cmocka_unit_test(addEl_oneValue_FirstDataOneValue),
        cmocka_unit_test(delEl_oneValue_FirstDataZero),
        cmocka_unit_test(merge_hasTwoPushedValue_returnsMergedValuesAndSizeOfTwo),
    };
    return cmocka_run_group_tests(tests, NULL, NULL);
return 0;
}
コード例 #5
0
ファイル: bad_inputs_test.c プロジェクト: cedric-d/libcbor
int main(void)
{
	const struct CMUnitTest tests[] = {
		cmocka_unit_test(test_1),
		cmocka_unit_test(test_2),
		cmocka_unit_test(test_3),
#ifdef SANE_MALLOC
		cmocka_unit_test(test_4),
		cmocka_unit_test(test_5),
#endif
		cmocka_unit_test(test_6),
#ifdef EIGHT_BYTE_SIZE_T
		cmocka_unit_test(test_7),
#endif
	};
	return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #6
0
ファイル: _string.c プロジェクト: JunhanPark/rtos
int main() {
	const struct CMUnitTest UnitTest[] = {
//		cmocka_unit_test(memset_func),
//		cmocka_unit_test(memset_sse_func),
//		cmocka_unit_test(memcpy_func),
//		cmocka_unit_test(memcpy_sse_func),
//		cmocka_unit_test(memcmp_func),
//		cmocka_unit_test(memcmp_sse_func),
//		cmocka_unit_test(memmove_func),
//		cmocka_unit_test(memmove_sse_func),
//		cmocka_unit_test(bzero_func),
		cmocka_unit_test(strlen_func),
		cmocka_unit_test(strstr_func),
		cmocka_unit_test(strchr_func),
		cmocka_unit_test(strrchr_func),
		cmocka_unit_test(strcmp_func),
		cmocka_unit_test(strncmp_func),
		cmocka_unit_test(strdup_func),
		cmocka_unit_test(strtol_func),
		cmocka_unit_test(strtoll_func)
	};

	return cmocka_run_group_tests(UnitTest, NULL, NULL);
}
コード例 #7
0
ファイル: trie_test.c プロジェクト: mlazowik/spellcheck
/**
  Główna funkcja uruchamiająca testy.
  */
int main(void)
{
    setlocale(LC_ALL, "pl_PL.UTF-8");

    const struct CMUnitTest tests[] =
    {
        cmocka_unit_test(trie_init_test),
        cmocka_unit_test(trie_insert_word_test),
        cmocka_unit_test(trie_has_word_test),
        cmocka_unit_test(trie_delete_word_test),
        cmocka_unit_test(trie_to_word_list_test),
        cmocka_unit_test(trie_save_test),
        cmocka_unit_test(trie_load_test),
    };

    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #8
0
ファイル: eval_req_tests.c プロジェクト: lslebodn/pam_hbac
int main(void)
{
    const struct CMUnitTest tests[] = {
        cmocka_unit_test(test_create_eval_req_invalid),
        cmocka_unit_test_setup_teardown(test_create_eval_req_nogroups,
                                        test_create_eval_req_nogroups_setup,
                                        test_create_eval_req_nogroups_teardown),
        cmocka_unit_test_setup_teardown(test_create_eval_req_valid_groups,
                                        test_create_eval_req_valid_groups_setup,
                                        test_create_eval_req_valid_groups_teardown),
        cmocka_unit_test_setup_teardown(test_create_eval_req_skip_invalid_groups,
                                        test_create_eval_req_invalid_groups_setup,
                                        test_create_eval_req_invalid_groups_teardown),
    };

    return cmocka_run_group_tests(tests,
                                  eval_req_test_setup,
                                  eval_req_test_teardown);
}
コード例 #9
0
int main(int argc, char* argv[]) 
{
  polymec_init(argc, argv);
  const struct CMUnitTest tests[] = 
  {
    cmocka_unit_test(test_partition_small_linear_cloud),
    cmocka_unit_test(test_partition_large_linear_cloud),
    cmocka_unit_test(test_partition_small_planar_cloud),
    cmocka_unit_test(test_partition_large_planar_cloud),
    cmocka_unit_test(test_partition_small_cubic_cloud),
    cmocka_unit_test(test_partition_large_cubic_cloud)
  };
  return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #10
0
ファイル: main.c プロジェクト: faithche/tasks
int main()
{
   const struct CMUnitTest tests[] =
    {
        cmocka_unit_test(func_test1),
        cmocka_unit_test(func_test2),
        cmocka_unit_test(func_test3),
        cmocka_unit_test(func_test4),
        cmocka_unit_test(func_test5),
        cmocka_unit_test(func_test6),

    };
    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #11
0
ファイル: list_item_prepend.c プロジェクト: tlauda/sof
int main(void)
{
	const struct CMUnitTest tests[] = {
		cmocka_unit_test(test_list_list_item_prepend_head_prev_is_tail),
		cmocka_unit_test(test_list_list_item_prepend_head_next_is_tail_minus_1),
		cmocka_unit_test(test_list_list_item_prepend_tail_minus_1_prev_is_head),
		cmocka_unit_test(test_list_list_item_prepend_tail_minus_1_next_is_tail),
		cmocka_unit_test(test_list_list_item_prepend_tail_prev_is_tail_minus_1),
		cmocka_unit_test(test_list_list_item_prepend_tail_next_is_head),
	};

	cmocka_set_message_output(CM_OUTPUT_TAP);

	return cmocka_run_group_tests(tests, setup, teardown);
}
コード例 #12
0
ファイル: Unit_test.c プロジェクト: antonmazun/gogog
int main(void){

 const struct CMUnitTest tests[] = {

 cmocka_unit_test(corpus_new__roomsAndSeats__self),
 cmocka_unit_test(room_busy__self__0OR1),
 cmocka_unit_test(corpus_Room_count__self__roomCount),
 cmocka_unit_test(room_empty_seats__self__emptySeats),
 cmocka_unit_test(room_empty_seats__self__NoemptySeats),
 cmocka_unit_test(room_new__seats__self),

 };

 return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #13
0
ファイル: dictionary_test.c プロジェクト: mlazowik/spellcheck
/**
  Główna funkcja uruchamiająca testy.
  */
int main(void)
{
    setlocale(LC_ALL, "pl_PL.UTF-8");

    const struct CMUnitTest tests[] =
    {
        cmocka_unit_test(dictionary_init_test),
        cmocka_unit_test(dictionary_insert_test),
        cmocka_unit_test(dictionary_find_test),
        cmocka_unit_test(dictionary_delete_test),
        cmocka_unit_test(dictionary_save_test),
        cmocka_unit_test(dictionary_load_test),
    };

    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #14
0
ファイル: rangeset_tests.c プロジェクト: akuzm/pg_pathman
/* Entrypoint */
int
main(void)
{
	/* Array of test functions */
	const struct CMUnitTest tests[] =
	{
		cmocka_unit_test(test_irange_basic),
		cmocka_unit_test(test_irange_list_union_merge),
		cmocka_unit_test(test_irange_list_union_lossy_cov),
		cmocka_unit_test(test_irange_list_union_complete_cov),
		cmocka_unit_test(test_irange_list_union_intersecting),
		cmocka_unit_test(test_irange_list_intersection),
	};

	/* Run series of tests */
	return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #15
0
ファイル: 0014-http-posts.c プロジェクト: redBorder/n2kafka
int main() {
  curl_global_init(CURL_GLOBAL_ALL);

  printf("Initializing n2kafka\n");
  pid_t pID = fork();

  if (pID == 0) {
    // Close stdin, stdout, stderr
    close(0);
    close(1);
    close(2);
    open("/dev/null", O_RDWR);
    (void)(dup(0) + 1);
    (void)(dup(0) + 1);

    execlp("./n2kafka", "n2kafka", "configs_example/n2kafka_config_rbhttp.json",
           (char *)0);
    printf("Error executing n2kafka\n");
    exit(1);

  } else if (pID < 0) {
    exit(1);
  }

  // Wait for n2kafka to initialize
  sleep(1);

  const struct CMUnitTest tests[] = {
      cmocka_unit_test(test_valid_POST),    cmocka_unit_test(test_invalid_UUID),
      cmocka_unit_test(test_invalid_topic), cmocka_unit_test(test_no_topic),
      cmocka_unit_test(test_invalid_URL),   cmocka_unit_test(test_deflate),
      cmocka_unit_test(test_empty_body)};
  const int res = cmocka_run_group_tests(tests, NULL, NULL);

  curl_global_cleanup();
  kill(pID, SIGINT);
  sleep(1);

  return res;
}
コード例 #16
0
int main(int argc, const char *argv[])
{
    const struct CMUnitTest tests[] = {
        cmocka_unit_test(test_getpwnam_r_wrapper),
        cmocka_unit_test(test_getpwuid_r_wrapper),
        cmocka_unit_test(test_getgrnam_r_wrapper),
        cmocka_unit_test(test_getgrgid_r_wrapper),
        cmocka_unit_test(test_get_user_grouplist),
        cmocka_unit_test_setup_teardown(test_set_err_msg,
                                        extdom_req_setup, extdom_req_teardown),
        cmocka_unit_test_setup_teardown(test_encode,
                                        extdom_req_setup, extdom_req_teardown),
        cmocka_unit_test(test_decode),
    };

    assert_non_null(original_fopen);
    return cmocka_run_group_tests(tests, extdom_req_setup, extdom_req_teardown);
}
コード例 #17
0
ファイル: test_List.c プロジェクト: Andreasdahlberg/sillycat
int main(int argc, char *argv[])
{
    const struct CMUnitTest tests[] =
    {
        cmocka_unit_test(test_List_New),
        cmocka_unit_test(test_List_Append_NULL),
        cmocka_unit_test(test_List_Append),
        cmocka_unit_test(test_List_Remove_NULL),
        cmocka_unit_test(test_List_Remove),
        cmocka_unit_test(test_List_GetLength)
    };

    if (argc >= 2)
    {
        cmocka_set_test_filter(argv[1]);
    }

    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #18
0
ファイル: test_sss_idmap.c プロジェクト: 3van/sssd
int main(int argc, const char *argv[])
{
    poptContext pc;
    int opt;
    struct poptOption long_options[] = {
        POPT_AUTOHELP
        SSSD_DEBUG_OPTS
        POPT_TABLEEND
    };

    const struct CMUnitTest tests[] = {
        cmocka_unit_test_setup_teardown(test_add_domain,
                                        test_sss_idmap_setup,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_map_id,
                                        test_sss_idmap_setup_with_domains,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_map_id_2922,
                                        test_sss_idmap_setup_with_domains_2922,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_map_id_sec_slices,
                                        test_sss_idmap_setup_with_domains_sec_slices,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_map_id_external,
                                        test_sss_idmap_setup_with_external_mappings,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_check_sid_id,
                                        test_sss_idmap_setup_with_domains,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_check_sid_id,
                                        test_sss_idmap_setup_with_external_mappings,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_has_algorithmic,
                                        test_sss_idmap_setup_with_both,
                                        test_sss_idmap_teardown),
        cmocka_unit_test_setup_teardown(test_has_algorithmic_by_name,
                                        test_sss_idmap_setup_with_both,
                                        test_sss_idmap_teardown),
        cmocka_unit_test(test_sss_idmap_check_collision_ex),
    };

    /* Set debug level to invalid value so we can deside if -d 0 was used. */
    debug_level = SSSDBG_INVALID;

    pc = poptGetContext(argv[0], argc, argv, long_options, 0);
    while((opt = poptGetNextOpt(pc)) != -1) {
        switch(opt) {
        default:
            fprintf(stderr, "\nInvalid option %s: %s\n\n",
                    poptBadOption(pc, 0), poptStrerror(opt));
            poptPrintUsage(pc, stderr, 0);
            return 1;
        }
    }
    poptFreeContext(pc);

    DEBUG_CLI_INIT(debug_level);

    tests_set_cwd();

    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #19
0
int main(void) {
	const struct CMUnitTest tests[] = {
		cmocka_unit_test(test_add),
		cmocka_unit_test(test_subtract),
		cmocka_unit_test(test_multiply),
		cmocka_unit_test(test_divide),
		cmocka_unit_test(test_divide_by_zero),
		cmocka_unit_test(test_find_operator_function_by_string_null_functions),
		cmocka_unit_test(test_find_operator_function_by_string_null_string),
		cmocka_unit_test(test_find_operator_function_by_string_valid_null_functions),
		cmocka_unit_test(test_find_operator_function_by_string_not_found),
		cmocka_unit_test(test_find_operator_function_by_string_found),
		cmocka_unit_test(test_perform_operation_null_args),
		cmocka_unit_test(test_perform_operation_null_operator_functions),
		cmocka_unit_test(test_perform_operation_null_number_of_intermediate_values),
		cmocka_unit_test(test_perform_operation_null_intermediate_values),
		cmocka_unit_test(test_perform_operation_no_arguments),
		cmocka_unit_test(test_perform_operation_first_arg_not_integer),
		cmocka_unit_test(test_perform_operation_unknown_operator),
		cmocka_unit_test(test_perform_operation_missing_argument),
		cmocka_unit_test(test_perform_operation_no_integer_after_operator),
		cmocka_unit_test(test_perform_operation),
		cmocka_unit_test(test_example_main_no_args),
		cmocka_unit_test(test_example_main),
	};
	return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #20
0
ファイル: test_debug.c プロジェクト: JustAnother1/pmc
int main(void)
{
    const struct CMUnitTest tests[] = {
            cmocka_unit_test(test_debug_init),
            cmocka_unit_test(test_getStartOffsetOfNextWord_command_and_leading_whitespace),
            cmocka_unit_test(test_getStartOffsetOfNextWord_command_and_one_leading_whitespace),
            cmocka_unit_test(test_getStartOffsetOfNextWord_command_and_no_whitespace),
            cmocka_unit_test(test_getStartOffsetOfNextWord_no_command),
            cmocka_unit_test(test_getStartOffsetOfNextWord_no_whitespace),
            cmocka_unit_test(test_getNumBytesNextWord_lengthZero),
            cmocka_unit_test(test_getNumBytesNextWord_noMoreChars),
            cmocka_unit_test(test_getNumBytesNextWord_only_whitespace),
            cmocka_unit_test(test_getNumBytesNextWord_command_and_leading_whitespace),
            cmocka_unit_test(test_getNumBytesNextWord_command_no_leading_whitespace),
            cmocka_unit_test(test_getHexNumber_lengthZero),
            cmocka_unit_test(test_getHexNumber_one_char),
            cmocka_unit_test(test_getHexNumber_chars_withOffset),
    };

    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #21
0
ファイル: ether.c プロジェクト: GNsunghokim/rtos
int main(void) {
	const struct CMUnitTest UnitTest[] = {
		cmocka_unit_test(read_u8_func),
		cmocka_unit_test(read_u16_func),
		cmocka_unit_test(read_u32_func),
		cmocka_unit_test(read_u48_func),
		cmocka_unit_test(read_u64_func),
		cmocka_unit_test(read_string_func),
		cmocka_unit_test(write_u8_func),
		cmocka_unit_test(write_u16_func),
		cmocka_unit_test(write_u32_func),
		cmocka_unit_test(write_u48_func),
		cmocka_unit_test(write_u64_func),
		cmocka_unit_test(write_string_func),
	};
	return cmocka_run_group_tests(UnitTest, NULL, NULL);
}
コード例 #22
0
ファイル: type_2_test.c プロジェクト: cedric-d/libcbor
int main(void)
{
	const struct CMUnitTest tests[] = {
		cmocka_unit_test(test_empty_bs),
		cmocka_unit_test(test_embedded_bs),
		cmocka_unit_test(test_notenough_data),
		cmocka_unit_test(test_short_bs1),
		cmocka_unit_test(test_short_bs2),
		cmocka_unit_test(test_half_bs),
		cmocka_unit_test(test_int_bs),
		cmocka_unit_test(test_long_bs),
		cmocka_unit_test(test_zero_indef),
		cmocka_unit_test(test_short_indef),
		cmocka_unit_test(test_two_indef),
		cmocka_unit_test(test_missing_indef),
		cmocka_unit_test(test_inline_creation)
	};
	return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #23
0
ファイル: main.c プロジェクト: vmware/lightwave
int main(VOID)
{
    int ret = 0;

    const struct CMUnitTest tests[] = {
        cmocka_unit_test(Test_LwCAInitCA_Valid),
        cmocka_unit_test(Test_LwCAInitCA_Invalid),
        cmocka_unit_test(Test_LwCACreateRootCA_Valid),
        cmocka_unit_test(Test_LwCACreateRootCA_Invalid),
        cmocka_unit_test(Test_LwCAGetCACertificates_Valid),
        cmocka_unit_test(Test_LwCAGetCACertificates_Invalid),
        cmocka_unit_test(Test_LwCAGetSignedCertificate_Valid),
        cmocka_unit_test(Test_LwCAGetSignedCertificate_Invalid),
        cmocka_unit_test(Test_LwCACreateIntermediateCA_Valid),
        cmocka_unit_test(Test_LwCACreateIntermediateCA_Invalid),
        cmocka_unit_test(Test_LwCARevokeCertificate_Valid),
        cmocka_unit_test(Test_LwCARevokeCertificate_Invalid),
        cmocka_unit_test(Test_LwCARevokeIntermediateCA_Valid),
        cmocka_unit_test(Test_LwCARevokeIntermediateCA_Invalid),
        cmocka_unit_test(Test_LwCAGetCACrl_Valid),
        cmocka_unit_test(Test_LwCAGetCACrl_Invalid),
    };

    ret = cmocka_run_group_tests(tests, Test_LwCAAPITests_Setup, Test_LwCAAPI_Teardown);

    if (ret)
    {
        fail_msg("%s", "MutentCA API tests failed");
    }

    return ret;
}
コード例 #24
0
int main(void) {
    char* timeout_env = getenv(timeout_env_name);
    timeout = timeout_env ? atoi(timeout_env) : default_timeout;

    const struct CMUnitTest tests[] = {
        cmocka_unit_test(vr_sync_sub_and_fetch_16u_basic),
        cmocka_unit_test(vr_sync_sub_and_fetch_16u_high),
        cmocka_unit_test(vr_sync_sub_and_fetch_16u_max),
        cmocka_unit_test(vr_sync_sub_and_fetch_16u_negative),
        cmocka_unit_test(vr_sync_sub_and_fetch_16u_underflow),
        cmocka_unit_test(vr_sync_sub_and_fetch_32u_basic),
        cmocka_unit_test(vr_sync_sub_and_fetch_32u_high),
        cmocka_unit_test(vr_sync_sub_and_fetch_32u_max),
        cmocka_unit_test(vr_sync_sub_and_fetch_32u_negative),
        cmocka_unit_test(vr_sync_sub_and_fetch_32u_underflow),
        cmocka_unit_test(vr_sync_sub_and_fetch_32s_basic),
        cmocka_unit_test(vr_sync_sub_and_fetch_32s_min),
        cmocka_unit_test(vr_sync_sub_and_fetch_32s_max),
        cmocka_unit_test(vr_sync_sub_and_fetch_32s_negateflow),
        cmocka_unit_test(vr_sync_sub_and_fetch_64u_basic),
        cmocka_unit_test(vr_sync_sub_and_fetch_64u_high),
        cmocka_unit_test(vr_sync_sub_and_fetch_64u_max),
        cmocka_unit_test(vr_sync_sub_and_fetch_64u_negative),
        cmocka_unit_test(vr_sync_sub_and_fetch_64u_underflow),
        cmocka_unit_test(vr_sync_sub_and_fetch_64s_basic),
        cmocka_unit_test(vr_sync_sub_and_fetch_64s_min),
        cmocka_unit_test(vr_sync_sub_and_fetch_64s_max),
        cmocka_unit_test(vr_sync_sub_and_fetch_64s_negateflow),
        cmocka_unit_test(vr_sync_add_and_fetch_32u_basic),
        cmocka_unit_test(vr_sync_add_and_fetch_32u_max),
        cmocka_unit_test(vr_sync_add_and_fetch_32u_negative),
        cmocka_unit_test(vr_sync_add_and_fetch_32u_overflow),
        cmocka_unit_test(vr_sync_add_and_fetch_16u_basic),
        cmocka_unit_test(vr_sync_add_and_fetch_16u_max),
        cmocka_unit_test(vr_sync_add_and_fetch_16u_negative),
        cmocka_unit_test(vr_sync_add_and_fetch_16u_overflow),
        cmocka_unit_test(vr_sync_fetch_and_add_32u_basic),
        cmocka_unit_test(vr_sync_fetch_and_add_32u_max),
        cmocka_unit_test(vr_sync_fetch_and_add_32u_negative),
        cmocka_unit_test(vr_sync_fetch_and_add_32u_overflow),
        cmocka_unit_test(vr_sync_fetch_and_add_64u_basic),
        cmocka_unit_test(vr_sync_fetch_and_add_64u_max),
        cmocka_unit_test(vr_sync_fetch_and_add_64u_negative),
        cmocka_unit_test(vr_sync_fetch_and_add_64u_overflow),
        cmocka_unit_test(vr_sync_fetch_and_or_16u_basic),
        cmocka_unit_test(vr_sync_fetch_and_or_16u_max),
        cmocka_unit_test(vr_sync_and_and_fetch_16u_basic),
        cmocka_unit_test(vr_sync_and_and_fetch_16u_max_input),
        cmocka_unit_test(vr_sync_and_and_fetch_16u_max_output),
        cmocka_unit_test(vr_sync_and_and_fetch_32u_basic),
        cmocka_unit_test(vr_sync_and_and_fetch_32u_max_input),
        cmocka_unit_test(vr_sync_and_and_fetch_32u_max_output),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_8u_swap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_8u_noswap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_8u_comp_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_8u_assign_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_16u_swap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_16u_noswap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_16u_comp_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_16u_assign_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_32u_swap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_32u_noswap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_32u_comp_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_32u_assign_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_p_swap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_p_noswap),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_p_comp_max),
        cmocka_unit_test(vr_sync_bool_compare_and_swap_p_assign_max),
        cmocka_unit_test(vr_sync_fetch_and_add_32u_races),
        cmocka_unit_test(vr_sync_fetch_and_add_64u_races),
        cmocka_unit_test(vr_sync_add_and_fetch_32u_races),
        cmocka_unit_test(vr_sync_sub_and_fetch_32u_races),
        cmocka_unit_test(vr_sync_sub_and_fetch_32s_races),
        cmocka_unit_test(vr_sync_sub_and_fetch_64u_races),
        cmocka_unit_test(vr_sync_sub_and_fetch_64s_races),
    };

    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #25
0
int main(void)
{
    int rc;

    const struct CMUnitTest fake_tests[] = {
        cmocka_unit_test(test_res_fake_a_query),
        cmocka_unit_test(test_res_fake_a_query_case_insensitive),
        cmocka_unit_test(test_res_fake_a_query_trailing_dot),
        cmocka_unit_test(test_res_fake_a_query_notfound),
        cmocka_unit_test(test_res_fake_aaaa_query),
        cmocka_unit_test(test_res_fake_aaaa_query_notfound),
        cmocka_unit_test(test_res_fake_srv_query),
        cmocka_unit_test(test_res_fake_srv_query_minimal),
        cmocka_unit_test(test_res_fake_soa_query),
        cmocka_unit_test(test_res_fake_cname_query),
        cmocka_unit_test(test_res_fake_a_via_cname),
    };

    rc = cmocka_run_group_tests(fake_tests, NULL, NULL);

    return rc;
}
コード例 #26
0
void test_partition_linear_mesh(void** state)
{
  // Create a 100x1x1 uniform mesh.
  int nx = 100, ny = 1, nz = 1;
  real_t dx = 1.0/nx;
  bbox_t bbox = {.x1 = 0.0, .x2 = 1.0, .y1 = 0.0, .y2 = dx, .z1 = 0.0, .z2 = dx};
  mesh_t* mesh = create_uniform_mesh(MPI_COMM_SELF, nx, ny, nz, &bbox);

  // Partition it.
  exchanger_t* distributor = partition_mesh(&mesh, MPI_COMM_WORLD, NULL, 0.05);
  exchanger_verify(distributor, polymec_error);
  exchanger_free(distributor);

  // Check the ghost cells.
  int rank, nprocs;
  MPI_Comm_rank(mesh->comm, &rank);
  MPI_Comm_size(mesh->comm, &nprocs);
  if (nprocs > 1)
  {
    exchanger_t* ex = mesh_exchanger(mesh);
    int pos = 0, proc, *indices, num_indices;
    int num_sends = 0, num_receives = 0;
    while (exchanger_next_send(ex, &pos, &proc, &indices, &num_indices))
      num_sends += num_indices;
    pos = 0;
    while (exchanger_next_receive(ex, &pos, &proc, &indices, &num_indices))
      num_receives += num_indices;
    assert_true((mesh->num_ghost_cells == 1) || (mesh->num_ghost_cells == 2));
    assert_true(num_sends == mesh->num_ghost_cells);
    assert_true(num_receives == mesh->num_ghost_cells);
  }
  else
    assert_int_equal(0, mesh->num_ghost_cells);

  // Check the geometry of the mesh.
  int cell_volumes_are_ok = 1;
  for (int c = 0; c < mesh->num_cells; ++c)
  {
    if (fabs(mesh->cell_volumes[c] - dx*dx*dx) > 1e-12)
    {
      cell_volumes_are_ok = 0;
      break; 
    }
  }
  int face_areas_are_ok = 1;
  for (int f = 0; f < mesh->num_faces; ++f)
  {
    if (fabs(mesh->face_areas[f] - dx*dx) > 1e-12)
    {
      face_areas_are_ok = 0;
      break; 
    }
  }
  MPI_Allreduce(&cell_volumes_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  MPI_Allreduce(&face_areas_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  assert_true(cell_volumes_are_ok);
  assert_true(face_areas_are_ok);

  // Check the resulting exchanger.
  exchanger_verify(mesh_exchanger(mesh), polymec_error);

  // Plot it.
  real_t p[mesh->num_cells];
  for (int c = 0; c < mesh->num_cells; ++c)
    p[c] = 1.0*rank;
  silo_file_t* silo = silo_file_new(mesh->comm, "linear_mesh_partition", "linear_mesh_partition", 1, 0, 0, 0.0);
  silo_file_write_mesh(silo, "mesh", mesh);
  silo_field_metadata_t* p_metadata = silo_field_metadata_new();
  silo_field_metadata_set_label(p_metadata, "P");
  silo_field_metadata_set_conserved(p_metadata, false);
  silo_file_write_scalar_cell_field(silo, "rank", "mesh", p, p_metadata);
  silo_file_close(silo);

  // Clean up.
  mesh_free(mesh);

  // Superficially check that the file is okay.
  int num_files, num_procs;
  assert_true(silo_file_query("linear_mesh_partition", "linear_mesh_partition",
                              &num_files, &num_procs, NULL));
  assert_int_equal(1, num_files);
  assert_int_equal(nprocs, num_procs);
}

void test_partition_slab_mesh(void** state)
{
  // Create a 50x50x1 uniform mesh.
  int nx = 50, ny = 50, nz = 1;
  real_t dx = 1.0/nx;
  bbox_t bbox = {.x1 = 0.0, .x2 = 1.0, .y1 = 0.0, .y2 = 1.0, .z1 = 0.0, .z2 = dx};
  mesh_t* mesh = create_uniform_mesh(MPI_COMM_SELF, nx, ny, nz, &bbox);

  // Partition it.
  exchanger_t* distributor = partition_mesh(&mesh, MPI_COMM_WORLD, NULL, 0.05);
  exchanger_free(distributor);

  // Check the geometry of the mesh.
  int cell_volumes_are_ok = 1;
  for (int c = 0; c < mesh->num_cells; ++c)
  {
    if (fabs(mesh->cell_volumes[c] - dx*dx*dx) > 1e-12)
    {
      cell_volumes_are_ok = 0;
      break; 
    }
  }
  int face_areas_are_ok = 1;
  for (int f = 0; f < mesh->num_faces; ++f)
  {
    if (fabs(mesh->face_areas[f] - dx*dx) > 1e-12)
    {
      face_areas_are_ok = 0;
      break; 
    }
  }
  MPI_Allreduce(&cell_volumes_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  MPI_Allreduce(&face_areas_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  assert_true(cell_volumes_are_ok);
  assert_true(face_areas_are_ok);

  // Plot it.
  int nprocs, rank;
  MPI_Comm_size(mesh->comm, &nprocs);
  MPI_Comm_rank(mesh->comm, &rank);
  real_t p[mesh->num_cells];
  for (int c = 0; c < mesh->num_cells; ++c)
    p[c] = 1.0*rank;
  silo_file_t* silo = silo_file_new(mesh->comm, "slab_mesh_partition", "slab_mesh_partition", 1, 0, 0, 0.0);
  silo_file_write_mesh(silo, "mesh", mesh);
  silo_file_write_scalar_cell_field(silo, "rank", "mesh", p, NULL);
  silo_file_close(silo);

  // Clean up.
  mesh_free(mesh);

  // Superficially check that the file is okay.
  int num_files, num_procs;
  assert_true(silo_file_query("slab_mesh_partition", "slab_mesh_partition",
                              &num_files, &num_procs, NULL));
  assert_int_equal(1, num_files);
  assert_int_equal(nprocs, num_procs);
}

void test_partition_box_mesh(void** state)
{
  // Create a 20x20x20 uniform mesh.
  int nx = 20, ny = 20, nz = 20;
  bbox_t bbox = {.x1 = 0.0, .x2 = 1.0, .y1 = 0.0, .y2 = 1.0, .z1 = 0.0, .z2 = 1.0};
  mesh_t* mesh = create_uniform_mesh(MPI_COMM_SELF, nx, ny, nz, &bbox);

  // Partition it.
  exchanger_t* distributor = partition_mesh(&mesh, MPI_COMM_WORLD, NULL, 0.05);
  exchanger_free(distributor);

  // Check the geometry of the mesh.
  real_t dx = 1.0/nx;
  int cell_volumes_are_ok = 1;
  for (int c = 0; c < mesh->num_cells; ++c)
  {
    if (fabs(mesh->cell_volumes[c] - dx*dx*dx) > 1e-12)
    {
      cell_volumes_are_ok = 0;
      break; 
    }
  }
  int face_areas_are_ok = 1;
  for (int f = 0; f < mesh->num_faces; ++f)
  {
    if (fabs(mesh->face_areas[f] - dx*dx) > 1e-12)
    {
      face_areas_are_ok = 0;
      break; 
    }
  }
  MPI_Allreduce(&cell_volumes_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  MPI_Allreduce(&face_areas_are_ok, &cell_volumes_are_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  assert_true(cell_volumes_are_ok);
  assert_true(face_areas_are_ok);

  // Plot it.
  int nprocs, rank;
  MPI_Comm_size(mesh->comm, &nprocs);
  MPI_Comm_rank(mesh->comm, &rank);
  double p[mesh->num_cells];
  for (int c = 0; c < mesh->num_cells; ++c)
    p[c] = 1.0*rank;
  silo_file_t* silo = silo_file_new(mesh->comm, "box_mesh_partition", "box_mesh_partition", 1, 0, 0, 0.0);
  silo_file_write_mesh(silo, "mesh", mesh);
  silo_file_write_scalar_cell_field(silo, "rank", "mesh", p, NULL);
  silo_file_close(silo);

  // Clean up.
  mesh_free(mesh);

  // Superficially check that the file is okay.
  int num_files, num_procs;
  assert_true(silo_file_query("box_mesh_partition", "box_mesh_partition",
                              &num_files, &num_procs, NULL));
  assert_int_equal(1, num_files);
  assert_int_equal(nprocs, num_procs);
}

int main(int argc, char* argv[]) 
{
  polymec_init(argc, argv);
  const struct CMUnitTest tests[] = 
  {
    cmocka_unit_test(test_partition_linear_mesh),
    cmocka_unit_test(test_partition_slab_mesh),
    cmocka_unit_test(test_partition_box_mesh)
  };
  return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #27
0
ファイル: test_dp_opts.c プロジェクト: 3van/sssd
int main(int argc, const char *argv[])
{
    int no_cleanup = 0;
    poptContext pc;
    int opt;
    int ret;
    struct poptOption long_options[] = {
        POPT_AUTOHELP
        SSSD_DEBUG_OPTS
        {"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
         _("Do not delete the test database after a test run"), NULL },
        POPT_TABLEEND
    };
    const struct CMUnitTest tests[] = {
        cmocka_unit_test_setup_teardown(opt_test_getset_string,
                                        opt_test_getset_setup,
                                        opt_test_getset_teardown),
        cmocka_unit_test_setup_teardown(opt_test_getset_int,
                                        opt_test_getset_setup,
                                        opt_test_getset_teardown),
        cmocka_unit_test_setup_teardown(opt_test_getset_bool,
                                        opt_test_getset_setup,
                                        opt_test_getset_teardown),
        cmocka_unit_test_setup_teardown(opt_test_getset_blob,
                                        opt_test_getset_setup,
                                        opt_test_getset_teardown),
        cmocka_unit_test_setup_teardown(opt_test_inherit,
                                        opt_test_getset_setup,
                                        opt_test_getset_teardown),
        cmocka_unit_test(opt_test_copy_default),
        cmocka_unit_test(opt_test_copy_options),
        cmocka_unit_test(opt_test_get)
    };

    /* Set debug level to invalid value so we can deside if -d 0 was used. */
    debug_level = SSSDBG_INVALID;

    pc = poptGetContext(argv[0], argc, argv, long_options, 0);
    while((opt = poptGetNextOpt(pc)) != -1) {
        switch(opt) {
        default:
            fprintf(stderr, "\nInvalid option %s: %s\n\n",
                    poptBadOption(pc, 0), poptStrerror(opt));
            poptPrintUsage(pc, stderr, 0);
            return 1;
        }
    }
    poptFreeContext(pc);

    DEBUG_CLI_INIT(debug_level);

    /* Even though normally the tests should clean up after themselves
     * they might not after a failed run. Remove the old db to be sure */
    tests_set_cwd();
    test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
    test_dom_suite_setup(TESTS_PATH);

    ret = cmocka_run_group_tests(tests, NULL, NULL);
    if (ret == 0 && !no_cleanup) {
        test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
    }
    return ret;
}
コード例 #28
0
ファイル: utest_error.c プロジェクト: assaabloy-ppi/binson-c
int utest_run_tests(void) {
  const struct CMUnitTest tests[] = {
	      cmocka_unit_test(utest_binson_error),
	      };
  return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #29
0
ファイル: happy_number.c プロジェクト: kasenoshi/c-playground
int main(void) {
    const struct CMUnitTest tests[] = {
        cmocka_unit_test(empty),
    };
    return cmocka_run_group_tests(tests, NULL, NULL);
}
コード例 #30
0
  int result = ovh_regex_match(regex, "This should match... hello");
  assert_int_equal(1, result);
  result = ovh_regex_match(regex, "This should not match...");
  assert_int_equal(0, result);
  ovh_regex_free(regex);

  regex = ovh_regex_new("/phish/(.*)make_7\\.html");
  result = ovh_regex_match(regex, "/phish/dfdfdfdfdfmake_7.html");
  assert_int_equal(1, result);
  result = ovh_regex_match(regex, "/phish/dfdfdfdfdfmake_7.html?more=yes");
  assert_int_equal(1, result);

  ovh_regex_free(regex);
  ovh_regex_free(orig);

  CHECK_ZERO_MEMORY_ALLOCATED;
}


static const struct CMUnitTest tests[] = {
  cmocka_unit_test(ovh_regex_simple_test),
  cmocka_unit_test(ovh_regex_clone_test),
};

SUPPRESS_UNUSED_WARN(ovh_regex_simple_test);
SUPPRESS_UNUSED_WARN(ovh_regex_clone_test);

test_helper_group(tests, suite_setup, suite_teardown);

#endif