SEXP dieharderCallback(SEXP callback_sexp, SEXP bits_sexp, SEXP testnum_sexp, SEXP seed_sexp, SEXP psamples_sexp, SEXP tsamples_sexp, SEXP ntuple_sexp, SEXP quiet_sexp, SEXP verbose_sexp) { initialize_globals(bits_sexp, seed_sexp, ntuple_sexp, quiet_sexp, verbose_sexp); Dtest *test_type = dh_test_types[INTEGER_VALUE(testnum_sexp)]; Test **test_results = create_test(test_type, INTEGER_VALUE(tsamples_sexp), INTEGER_VALUE(psamples_sexp)); global_parsed_callback = parse_and_test_callback(callback_sexp); if (global_parsed_callback) { PROTECT(global_parsed_callback); std_test(test_type, test_results); UNPROTECT(1); } else { result = NULL; } global_parsed_callback = NULL; output(test_type, test_results); save_values_for_R(test_type, test_results); destroy_test(test_type, test_results); gsl_rng_free(rng); rng = NULL; reset_bit_buffers(); return result; }
void run_user_template() { /* * Declare the results struct. */ Test **user_template_test; /* * First we create the test (to set some values displayed in test header * correctly). */ user_template_test = create_test(&user_template_dtest,tsamples,psamples,&user_template); /* * Set any GLOBAL data used by the test. This is very test specific -- most * library tests won't have any but a few do. The data will usually be input * via one of the special command line variables reserved for that purpose, * and only can work if the -a(ll) flag is not set -- otherwise test specific * defaults are used. */ user_template_lag = (int)x_user; /* * Show the standard test header for this test. */ show_test_header(&user_template_dtest,user_template_test); /* * This is where we can output any test-specific information (such as * the value of the lag). In dieharder, I tend to start each output * line with an # to make things all pretty. */ printf("# Lag used in %s test: %u\n",user_template_dtest.name,user_template_lag); /* * Set any GLOBAL data used by the test. Then call the test itself * This fills in the results in the Test struct. */ std_test(&user_template_dtest,user_template_test); /* * This almost certainly belongs in the show_test_results section, * possibly with additional conditionals rejecting test results involving * rewinds, period. */ if(strncmp("file_input",gsl_rng_name(rng),10) == 0){ printf("# %u rands were used in this test\n",file_input_get_rtot(rng)); printf("# The file %s was rewound %u times\n",gsl_rng_name(rng),file_input_get_rewind_cnt(rng)); } /* * Show standard test results, for all statistics generated by a single run. */ show_test_results(&user_template_dtest,user_template_test); }
void run_diehard_sums() { /* * Declare the results struct. */ Test **diehard_sums_test; /* * First we create the test (to set some values displayed in test header * correctly). */ diehard_sums_test = create_test(&diehard_sums_dtest,tsamples,psamples,&diehard_sums); /* * Set any GLOBAL data used by the test. */ diehard_sums_rand_dbl = (double *)malloc((size_t) diehard_sums_test[0]->tsamples*sizeof(double)); /* * Show the standard test header for this test. */ show_test_header(&diehard_sums_dtest,diehard_sums_test); /* * This is where we can output any test-specific information. */ /* * Set any GLOBAL data used by the test. Then call the test itself * This fills in the results in the Test struct. */ std_test(&diehard_sums_dtest,diehard_sums_test); /* * This almost certainly belongs in the show_test_results section, * possibly with additional conditionals rejecting test results involving * rewinds, period. */ if(strncmp("file_input",gsl_rng_name(rng),10) == 0){ printf("# %u rands were used in this test\n",file_input_get_rtot(rng)); printf("# The file %s was rewound %u times\n",gsl_rng_name(rng),file_input_get_rewind_cnt(rng)); } /* * Show standard test results, for all statistics generated by a single run. */ show_test_results(&diehard_sums_dtest,diehard_sums_test); /* * Free global memory */ free(diehard_sums_rand_dbl); }
void run_marsaglia_tsang_gcd() { /* * Declare the results struct. */ Test **marsaglia_tsang_gcd_test; /* * First we create the test (to set some values displayed in test header * correctly). */ marsaglia_tsang_gcd_test = create_test(&marsaglia_tsang_gcd_dtest,tsamples,psamples,&marsaglia_tsang_gcd); /* * Set any GLOBAL data used by the test. */ /* * Show the standard test header for this test. */ show_test_header(&marsaglia_tsang_gcd_dtest,marsaglia_tsang_gcd_test); /* * This is where we can output any test-specific information. */ /* * Set any GLOBAL data used by the test. Then call the test itself * This fills in the results in the Test struct. */ std_test(&marsaglia_tsang_gcd_dtest,marsaglia_tsang_gcd_test); /* * This almost certainly belongs in the show_test_results section, * possibly with additional conditionals rejecting test results involving * rewinds, period. */ if(strncmp("file_input",gsl_rng_name(rng),10) == 0){ printf("# %u rands were used in this test\n",file_input_get_rtot(rng)); printf("# The file %s was rewound %u times\n",gsl_rng_name(rng),file_input_get_rewind_cnt(rng)); } /* * Show standard test results, for all statistics generated by a single run. */ show_test_results(&marsaglia_tsang_gcd_dtest,marsaglia_tsang_gcd_test); }