int test_image_png_to_bmp() { char *buffer = TEST_SOURCE_PATH; char src_png[PATH_MAX]; char src_bmp[PATH_MAX]; char dst_png[PATH_MAX]; char dst_bmp[PATH_MAX]; char dst_png2[PATH_MAX]; char dst_bmp2[PATH_MAX]; char *tmp = GetKnownPath(KNOWN_PATH_TEMP); if (!tmp) return -1; if (!buffer) return -1; sprintf_s(src_png, sizeof(src_png), "%s/lodepng_32bit.png", buffer); sprintf_s(src_bmp, sizeof(src_bmp), "%s/lodepng_32bit.bmp", buffer); sprintf_s(dst_png, sizeof(dst_png), "%s/lodepng_32bit.png", tmp); sprintf_s(dst_bmp, sizeof(dst_bmp), "%s/lodepng_32bit.bmp", tmp); sprintf_s(dst_png2, sizeof(dst_png2), "%s/lodepng_32bit-2.png", tmp); sprintf_s(dst_bmp2, sizeof(dst_bmp2), "%s/lodepng_32bit-2.bmp", tmp); if (create_test(src_png, dst_png, dst_bmp)) return -1; if (create_test(src_bmp, dst_png2, dst_bmp2)) return -1; return 0; }
static void argparse_parse(char *cmdline) { char* token = os_strtok(cmdline, " "); while (token != NULL) { os_printf("token: %s\n", token); if (os_strcmp("-load", token) == 0) { char* name = os_strtok(NULL, " "); process_execute(name); } else if (os_strcmp("-test", token) == 0) { os_printf("RUNNING TESTS\n"); os_printf("Running tests...\n"); Test *tests[2]; tests[0] = create_test("This passes", &test1); tests[1] = create_test("This fails", &test2); run_tests(tests, 2); } token = os_strtok(NULL, " "); } }
//function running tests void run_hmap_tests() { Test *tests[NUM_TESTS]; tests[0] = create_test("test_hmap_1", &test_hmap_1); tests[1] = create_test("test_hmap_2", &test_hmap_2); tests[2] = create_test("test_hmap_3", &test_hmap_3); tests[3] = create_test("test_hmap_4", &test_hmap_4); run_tests(tests, NUM_TESTS); }
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 piglit_init(int argc, char **argv) { GLint max_samples; if (argc < 2) print_usage_and_exit(argv[0]); { char *endptr = NULL; num_samples = strtol(argv[1], &endptr, 0); if (endptr != argv[1] + strlen(argv[1])) print_usage_and_exit(argv[0]); } piglit_require_gl_version(21); piglit_require_extension("GL_ARB_framebuffer_object"); piglit_require_extension("GL_ARB_vertex_array_object"); /* Skip the test if num_samples > GL_MAX_SAMPLES */ glGetIntegerv(GL_MAX_SAMPLES, &max_samples); if (num_samples > max_samples) { printf("Sample count not supported : %d\n", num_samples); piglit_report_result(PIGLIT_SKIP); } test = create_test(TEST_TYPE_COLOR, num_samples, false /*small*/, true /* combine_depth_stencil */, pattern_width, pattern_height, 16 /* supersample_factor */); }
int main(int argc, char *argv[]) { HTEST *hTest = NULL; OMX_STRING component = NULL; OMX_STRING dump_file = NULL; if(argc < 2) { printf("Usage: ./bin <dump_file>\n"); return 0; } OMX_Init(); component = "OMX.Freescale.std.video_source.v4l.sw-based"; dump_file = argv[1]; hTest = create_test(component, dump_file); hTest->media_name = argv[1]; if(hTest == NULL) { printf("Create test failed.\n"); return 0; } load_component(hTest); StateTrans(hTest, (OMX_STATETYPE)2); StateTrans(hTest, (OMX_STATETYPE)3); cmd_process(hTest); delete_test(hTest); OMX_Deinit(); return 1; }
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 piglit_init(int argc, char **argv) { GLint max_samples; int i, num_samples; bool small = false; bool combine_depth_stencil = false; if (argc < 3) print_usage_and_exit(argv[0]); { char *endptr = NULL; num_samples = strtol(argv[1], &endptr, 0); if (endptr != argv[1] + strlen(argv[1])) print_usage_and_exit(argv[0]); } for (i = 3; i < argc; ++i) { if (strcmp(argv[i], "small") == 0) { small = true; } else if (strcmp(argv[i], "depthstencil") == 0) { combine_depth_stencil = true; } else { print_usage_and_exit(argv[0]); } } piglit_require_gl_version(21); piglit_require_extension("GL_ARB_framebuffer_object"); piglit_require_extension("GL_ARB_vertex_array_object"); /* Skip the test if num_samples > GL_MAX_SAMPLES */ glGetIntegerv(GL_MAX_SAMPLES, &max_samples); if (num_samples > max_samples) piglit_report_result(PIGLIT_SKIP); test_type_enum test_type; if (strcmp(argv[2], "color") == 0) { test_type = TEST_TYPE_COLOR; } else if (strcmp(argv[2], "srgb") == 0) { test_type = TEST_TYPE_SRGB; } else if (strcmp(argv[2], "stencil_draw") == 0) { test_type = TEST_TYPE_STENCIL_DRAW; } else if (strcmp(argv[2], "stencil_resolve") == 0) { test_type = TEST_TYPE_STENCIL_RESOLVE; } else if (strcmp(argv[2], "depth_draw") == 0) { test_type = TEST_TYPE_DEPTH_DRAW; } else if (strcmp(argv[2], "depth_resolve") == 0) { test_type = TEST_TYPE_DEPTH_RESOLVE; } else { print_usage_and_exit(argv[0]); } test = create_test(test_type, num_samples, small, combine_depth_stencil, pattern_width, pattern_height, supersample_factor); }
int main () { printf("STARTING\n"); TEST test_memcmp_1 = create_test("test_os_memcmp_1", &test_os_memcmp_1); TEST test_memcmp_2 = create_test("test_os_memcmp_2", &test_os_memcmp_2); TEST test_memcmp_3 = create_test("test_os_memcmp_3", &test_os_memcmp_3); printf("CREATED TESTS\n"); TEST_SUITE tests = create_test_suite(); printf("CREATED SUITE\n"); add_test(test_memcmp_1, &tests); add_test(test_memcmp_2, &tests); add_test(test_memcmp_3, &tests); printf("ADDED TESTS\n"); run_tests(tests); printf("DONE\n"); return 0; }
int settings_test(void){ if( create_test() < 0 ){ return -1; } if( update_test() < 0 ){ return -1; } return 0; }
int file_test(void){ if( create_test() < 0 ){ return -1; } if( open_test() < 0 ){ return -1; } return 0; }
int main(int argc , char ** argv) { create_test(); get_test(); set_test(); load_empty_test(); test_equal(); test_copy(); test_io(); test_update_undefined( ); test_select_matching(); test_count_matching(); exit(0); }
int main(int argc, char *argv[]) { HTEST *hTest = NULL; OMX_STRING component = NULL; OMX_STRING in_file = NULL, out_file = NULL; OMX_S32 width, height, bitrate; FORMAT fmt; if(argc < 6) { printf("Unit test of vpu encoder component.\n"); printf("This test read data from in_file then store the encoded data to out_file.\n"); printf("Usage: ./bin <in_file> <width> <height> <out_file> <bitrate>\n"); return 0; } OMX_Init(); in_file = argv[1]; width = atoi(argv[2]); height = atoi(argv[3]); out_file = argv[4]; bitrate = atoi(argv[5]); fmt = H264; if (fmt == H264) { component = "OMX.Freescale.std.video_encoder.avc.hw-based"; } else if (fmt == H263) { component = "OMX.Freescale.std.video_encoder.h263.hw-based"; } else { printf("wrong format.\n"); return 0; } hTest = create_test(component, in_file, width, height, out_file, fmt, bitrate); if(hTest == NULL) { printf("Create test failed.\n"); return 0; } load_component(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateExecuting); wait_eos(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateLoaded); unload_component(hTest); delete_test(hTest); OMX_Deinit(); printf("Vpu component test is done.\n"); return 1; }
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); }
int main(int argc, char *argv[]) { HTEST *hTest = NULL; OMX_STRING component = NULL; OMX_STRING in_file = NULL, out_file = NULL; FORMAT fmt; if(argc < 4) { printf("Unit test of vpu component.\n"); printf("This test read data from in_file then store the decoded data to out_file.\n"); printf("Usage: ./bin <in_file> <out_file> <format>\n"); printf("format: 0 -- mpeg4\n"); printf(" 1 -- h264\n"); return 0; } OMX_Init(); component = "OMX.Freescale.std.video_decoder.avc.v3.hw-based"; in_file = argv[1]; out_file = argv[2]; fmt = (FORMAT) atoi(argv[3]); hTest = create_test(component, in_file, out_file, fmt); if(hTest == NULL) { printf("Create test failed.\n"); return 0; } #if 1 load_component(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateExecuting); wait_eos(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateLoaded); unload_component(hTest); #else cmd_process(hTest); #endif delete_test(hTest); OMX_Deinit(); printf("Vpu component test is done.\n"); return 1; }
void run_rgb_timing() { /* * Declare the results struct. */ Rgb_Timing timing; Test **rgb_timing_test; /* * First we create the test (to set some values displayed in test header * correctly). */ rgb_timing_test = create_test(&rgb_timing_dtest,tsamples,psamples,&rgb_timing); /* * Set any GLOBAL data used by the test. */ /* * Show the standard test header for this test. */ show_test_header(&rgb_timing_dtest,rgb_timing_test); /* * Call the actual test that fills in the results struct. */ rgb_timing(rgb_timing_test,&timing); /* * Display the results. */ printf("#========================================================================\n"); printf("# rgb_timing() test using the %s generator \n",gsl_rng_name(rng)); printf("# Average time per rand = %e nsec.\n",timing.avg_time_nsec); printf("# Rands per second = %e.\n",timing.rands_per_sec); }
int main(int argc , char** argv) { if(argc!=2) { cout << argv[0] << " so" << endl; return 1; } void* test_index = dlopen(argv[1], RTLD_NOW); if (!test_index) { cerr << "Cannot load library: " << dlerror() << '\n'; return 1; } dlerror(); create_t* create_test = (create_t*) dlsym(test_index, "create"); const char* dlsym_error = dlerror(); if (dlsym_error) { cerr << "Cannot load symbol create: " << dlsym_error << '\n'; return 1; } destroy_t* destroy_test = (destroy_t*) dlsym(test_index, "destroy"); dlsym_error = dlerror(); if (dlsym_error) { cerr << "Cannot load symbol destroy: " << dlsym_error << '\n'; return 1; } test_base* c_test = create_test(); c_test->display(); destroy_test(c_test); dlclose(test_index); }
static void run_tests (GtkContainer *parent, gboolean wait_for_realize, gboolean fake_remote) { GtkWidget *vbox; DestroyType t; Test *tests[DESTROY_TYPE_LAST]; vbox = gtk_vbox_new (TRUE, 2); gtk_widget_show (vbox); gtk_container_add (parent, vbox); #if 0 { /* Test raw plug / socket */ GtkWidget *socket; g_warning ("Foo Bar. !!!"); socket = gtk_socket_new (); g_signal_connect (G_OBJECT (socket), "realize", G_CALLBACK (realize_cb), NULL); gtk_widget_show (GTK_WIDGET (socket)); gtk_box_pack_start (GTK_BOX (vbox), socket, TRUE, TRUE, 2); } #endif printf ("create\n"); for (t = 0; t < DESTROY_TYPE_LAST; t++) { tests [t] = create_test (fake_remote); gtk_box_pack_start ( GTK_BOX (vbox), GTK_WIDGET (tests [t]->matecomponent_widget), TRUE, TRUE, 2); } if (wait_for_realize) mainloop_for (100); printf ("show / hide\n"); gtk_widget_hide (GTK_WIDGET (parent)); if (wait_for_realize) mainloop_for (100); gtk_widget_show (GTK_WIDGET (parent)); if (wait_for_realize) mainloop_for (100); printf ("re-add\n"); g_object_ref (G_OBJECT (vbox)); gtk_container_remove (parent, vbox); gtk_container_add (parent, vbox); if (wait_for_realize) mainloop_for (100); printf ("re-parent\n"); for (t = 0; t < DESTROY_TYPE_LAST; t++) { g_object_ref (tests [t]->matecomponent_widget); gtk_container_remove (GTK_CONTAINER (GTK_BOX (vbox)), tests [t]->matecomponent_widget); gtk_box_pack_start ( GTK_BOX (vbox), GTK_WIDGET (tests [t]->matecomponent_widget), TRUE, TRUE, 2); g_object_unref (tests [t]->matecomponent_widget); } if (wait_for_realize) mainloop_for (100); printf ("destroy\n"); for (t = 0; t < DESTROY_TYPE_LAST; t++) { destroy_test (tests [t], t); mainloop_for (0); } gtk_widget_destroy (GTK_WIDGET (vbox)); }
void run_rgb_persist() { /* * Declare the results struct. */ Rgb_Persist persist; Test **rgb_persist_test; /* * First we create the test (to set some values displayed in test header * correctly). */ rgb_persist_test = create_test(&rgb_persist_dtest,tsamples,psamples,&rgb_persist); /* * Set any GLOBAL data used by the test. * * We arbitrarily choose 256 successive random numbers as enough. * This should be plenty -- the probability of any bit slot not * changing by CHANCE in 256 tries is 2^-256 or almost 10^-26, * so even with 32 bit slots, repeatedly, we aren't horribly likely * to see it in our lifetime unless we run this test continuously for * months at a time (yes, a dumb idea). */ rgb_persist_rand_uint = (unsigned int*)malloc(256 * sizeof(unsigned int)); /* * Show the standard test header for this test. */ show_test_header(&rgb_persist_dtest,rgb_persist_test); /* * Call the actual test that fills in the results struct. */ rgb_persist(rgb_persist_test,&persist); 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)); } printf("#==================================================================\n"); printf("# Results\n"); printf("# Results for %s rng, using its %d valid bits:\n",gsl_rng_name(rng),rmax_bits); printf("# (Cumulated mask of zero is good.)\n"); printf("# cumulated_mask = %10u = ",persist.cumulative_mask); dumpbits(&persist.cumulative_mask,persist.nbits); printf("\n# randm_mask = %10u = ",rmax_mask); dumpbits(&rmax_mask,persist.nbits); printf("\n# random_max = %10u = ",random_max); dumpbits(&random_max,persist.nbits); if(persist.cumulative_mask){ printf("\n# rgb_persist test FAILED (bits repeat)\n"); } else { printf("\n# rgb_persist test PASSED (no bits repeat)\n"); } printf("#==================================================================\n"); free(rgb_persist_rand_uint); }