void test_5(void){ char str[128] = "abcde"; struct yaml_string * ys = create_yaml(); print_test_info(ys, "test_5", "e abcde", "abcd", "20"); remove_char('e', str); str[sizeof(str) - 1] = '\0'; print_test_output(ys, str); }
int main(int argc, char *argv[]) { info = (struct test_info *)malloc(sizeof(struct test_info)); test_info_init(info); info->test_type = 0; info->msg_count=50; struct plat_opts_config_mpilogme config; SDF_boolean_t success = SDF_TRUE; uint32_t numprocs; int tmp, namelen, mpiv = 0, mpisubv = 0, i; char processor_name[MPI_MAX_PROCESSOR_NAME]; int msg_init_flags = SDF_MSG_MPI_INIT; config.inputarg = 0; config.msgtstnum = 500; /* We may not need to gather anything from here but what the heck */ loadProperties("/opt/schooner/config/schooner-med.properties"); // TODO get filename from command line /* make sure this is first in order to get the the mpi init args */ success = plat_opts_parse_mpilogme(&config, argc, argv) ? SDF_FALSE : SDF_TRUE; printf("input arg %d msgnum %d success %d\n", config.inputarg, config.msgtstnum, success); fflush(stdout); myid = sdf_msg_init_mpi(argc, argv, &numprocs, &success, msg_init_flags); info->myid = myid; if ((!success) || (myid < 0)) { printf("Node %d: MPI Init failure... exiting - errornum %d\n", myid, success); fflush(stdout); MPI_Finalize(); return (EXIT_FAILURE); } int debug = 0; while(debug); tmp = init_msgtest_sm((uint32_t)myid); /* Enable this process to run threads across 2 cpus, MPI will default to running all threads * on only one core which is not what we really want as it forces the msg thread to time slice * with the fth threads that send and receive messsages * first arg is the number of the processor you want to start off on and arg #2 is the sequential * number of processors from there */ //lock_processor(0, 7); lock_processor(myid * 4, 4); info->lock_cpu = 4; sleep(1); msg_init_flags = msg_init_flags | SDF_MSG_RTF_DISABLE_MNGMT; /* Startup SDF Messaging Engine FIXME - dual node mode still - pnodeid is passed and determined * from the number of processes mpirun sees. */ sdf_msg_init(myid, &pnodeid, msg_init_flags); MPI_Get_version(&mpiv, &mpisubv); MPI_Get_processor_name(processor_name, &namelen); printf("Node %d: MPI Version: %d.%d Name %s \n", myid, mpiv, mpisubv, processor_name); fflush(stdout); plat_log_msg( PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: Completed Msg Init.. numprocs %d pnodeid %d Starting Test\n", myid, numprocs, pnodeid); info->pnodeid = pnodeid; for (i = 0; i < 2; i++) { sleep(2); plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: Number of sleeps %d\n", myid, i); } fthInit(); /* SAVE THIS may need to play with the priority later */ #if 0 struct sched_param param; int newprio = 60; pthread_attr_t hi_prior_attr; pthread_attr_init(&hi_prior_attr); pthread_attr_setschedpolicy(&hi_prior_attr, SCHED_FIFO); pthread_attr_getschedparam(&hi_prior_attr, ¶m); param.sched_priority = newprio; pthread_attr_setschedparam(&hi_prior_attr, ¶m); pthread_create(&fthPthread, &hi_prior_attr, &fthPthreadRoutine, NULL); #endif pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&fthPthread, &attr, &SinglePtlSequentialPressPthreadRoutine, NULL); plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: Created pthread for FTH %d\n", myid, i); info->pthread_info = 1; info->fth_info = 2; pthread_join(fthPthread, NULL); plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: SDF Messaging Test Complete - i %d\n", myid, i); /* Lets stop the messaging engine this will block until they complete */ /* FIXME arg is the threadlvl */ sdf_msg_stopmsg(myid, SYS_SHUTDOWN_SELF); if (numprocs > 1) { sdf_msg_nsync(myid, (myid == 0 ? 1 : 0)); } plat_shmem_detach(); info->success++; if (myid == 0) { sched_yield(); printf("Node %d: Exiting message test after yielding... Calling MPI_Finalize\n", myid); fflush(stdout); sched_yield(); MPI_Finalize(); print_test_info(info); test_info_final(info); } else { printf("Node %d: Exiting message test... Calling MPI_Finalize\n", myid); fflush(stdout); sched_yield(); MPI_Finalize(); } printf("Successfully ends\n"); return (EXIT_SUCCESS); }
int main(int argc, char *argv[]) { info = (struct test_info *)malloc(sizeof(struct test_info)); test_info_init(info); info->test_type = 0; msgCount = 50; info->msg_count=msgCount; struct plat_opts_config_mpilogme config; SDF_boolean_t success = SDF_TRUE; uint32_t numprocs; int tmp, namelen, mpiv = 0, mpisubv = 0; char processor_name[MPI_MAX_PROCESSOR_NAME]; int msg_init_flags = SDF_MSG_MPI_INIT; config.inputarg = 0; config.msgtstnum = 50; /* We may not need to gather anything from here but what the heck */ loadProperties("/opt/schooner/config/schooner-med.properties"); // TODO get filename from command line /* make sure this is first in order to get the the mpi init args */ success = plat_opts_parse_mpilogme(&config, argc, argv) ? SDF_FALSE : SDF_TRUE; printf("input arg %d msgnum %d success %d\n", config.inputarg, config.msgtstnum, success); fflush(stdout); myid = sdf_msg_init_mpi(argc, argv, &numprocs, &success, msg_init_flags); info->myid = myid; if ((!success) || (myid < 0)) { printf("Node %d: MPI Init failure... exiting - errornum %d\n", myid, success); fflush(stdout); MPI_Finalize(); return (EXIT_FAILURE); } tmp = init_msgtest_sm((uint32_t)myid); /* Enable this process to run threads across 2 cpus, MPI will default to running all threads * on only one core which is not what we really want as it forces the msg thread to time slice * with the fth threads that send and receive messsages * first arg is the number of the processor you want to start off on and arg #2 is the sequential * number of processors from there */ lock_processor(0, 2); info->lock_cpu = 2; /* Startup SDF Messaging Engine FIXME - dual node mode still - pnodeid is passed and determined * from the number of processes mpirun sees. */ sleep(1); msg_init_flags = msg_init_flags | SDF_MSG_RTF_DISABLE_MNGMT; sdf_msg_init(myid, &pnodeid, msg_init_flags); MPI_Get_version(&mpiv, &mpisubv); MPI_Get_processor_name(processor_name, &namelen); printf("Node %d: MPI Version: %d.%d Name %s \n", myid, mpiv, mpisubv, processor_name); fflush(stdout); plat_log_msg( PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: Completed Msg Init.. numprocs %d pnodeid %d Starting Test\n", myid, numprocs, pnodeid); info->pnodeid = pnodeid; for (msgCount = 0; msgCount < 2; msgCount++) { sleep(2); plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: Number of sleeps %d\n", myid, msgCount); } /* create the fth test threads */ fthInit(); // Init // start the message engine sdf_msg_startmsg(myid, 0, NULL); pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&fthPthread[0], &attr, &MixedthreadTestfthUniptlRoutine, &myid); pthread_create(&fthPthread[1], &attr, &MixedthreadTestpthreadUniptlRoutine, &myid); plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: Created pthread for mixed thread test2\n", myid); info->pthread_info = 2; info->fth_info = 6; pthread_join(fthPthread[0], NULL); pthread_join(fthPthread[1], NULL); plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE, "\nNode %d: SDF Messaging Test Complete\n", myid); sdf_msg_stopmsg(myid, SYS_SHUTDOWN_SELF); plat_shmem_detach(); info->success++; if (myid == 0) { sched_yield(); printf("Node %d: Exiting message test after yielding... Calling MPI_Finalize\n", myid); fflush(stdout); sched_yield(); MPI_Finalize(); print_test_info(info); test_info_final(info); } else { printf("Node %d: Exiting message test... Calling MPI_Finalize\n", myid); fflush(stdout); sched_yield(); MPI_Finalize(); } printf("Successfully ends\n"); return (EXIT_SUCCESS); }
int run_test(int argc, char **argv, unsigned int test_num, Test *test, char **fifos) { char *in_file = NULL; int in_fd = -1; char **out_files = NULL; int *out_fds = NULL; int fifo_fds[MAX_READERS]; pid_t child = 0; int i, res = 0, wres; /* Write some information about the test to the log */ print_test_info(test_num, test); assert(test->npipes <= MAX_READERS); for (i = 0; i < MAX_READERS; i++) fifo_fds[i] = -1; /* Open any output files needed */ if (test->nfiles > 0) { if (0 != get_output_files(test, &out_files, &out_fds)) goto BAIL; } /* Create an input file if the test needs one */ if (test->in_type == IN_FILE) { if (NULL == (in_file = get_input_file(test))) goto BAIL; } /* Start the program under test */ child = start_prog(argc, argv, test, &in_fd, in_file, fifos, out_files); if (child < 0) goto BAIL; /* Open any named pipes required */ if (test->npipes > 0) { if (0 != open_fifos(test->npipes, fifos, fifo_fds)) goto BAIL; } if (test->npipes) { /* reading from pipes, run the full poll loop */ res = run_poll_loop(test, in_fd, fifo_fds, fifos); /* Close any pipes that are still open */ if (0 != close_fifos(test->npipes, fifos, fifo_fds)) { res = -1; } } else if (test->in_type == IN_PIPE || test->in_type == IN_SLOW_PIPE) { /* only sending to a pipe, so just shove the data down it */ size_t offset = 0; if (gen_data("pipe", in_fd, test->in_len, &offset, 0, 0) != test->in_len) { res = -1; } if (0 != close(in_fd)) { perror("Closing pipe"); res = -1; } } /* Wait for the program to finish and check the exit status */ wres = wait_child(child); if (-99 == wres) goto BAIL; if (wres < 0) res = -1; /* Check the contents of any regular files that were created */ if (test->nfiles > 0) { if (0 != check_output_files(test, out_fds, out_files)) res = -1; } /* Clean up */ if (NULL != in_file) remove_files(&in_file, 1); if (test->nfiles > 0) { remove_files(out_files, test->nfiles); } return res; BAIL: /* Something went wrong, clean up and return 99 */ if (NULL != in_file) remove_files(&in_file, 1); if (test->nfiles > 0 && NULL != out_files) { remove_files(out_files, test->nfiles); } if (test->npipes > 0) { close_fifos(test->npipes, fifos, fifo_fds); } return 99; }
/* Run the test(s) */ int piglit_cl_framework_run(int argc, char** argv) { enum piglit_result result = PIGLIT_SKIP; int version = 0; cl_platform_id platform_id = NULL; cl_device_id device_id = NULL; /* Get test configuration */ struct piglit_cl_test_config_header *config = piglit_cl_get_test_config(argc, (const char**)argv, &PIGLIT_CL_DEFAULT_TEST_CONFIG_HEADER); /* Check that config is valid */ // run_per_platform, run_per_device if(config->run_per_platform && config->run_per_device) { fprintf(stderr, "Invalid configuration, only one of run_per_platform and run_per_device can be true.\n"); piglit_report_result(PIGLIT_WARN); } /* Init */ if(config->init_func != NULL) { config->init_func(argc, (const char**)argv, config); } /* Print test name and file */ printf("## Test: %s (%s) ##\n\n", config->name != NULL ? config->name : "", config->_filename); /* Get version to test against */ version = piglit_cl_get_version_arg(argc, (const char **)argv); if(version > 0) { if(version > PIGLIT_CL_VERSION) { printf("Piglit was compiled with lower OpenCL version (%d.%d) than version argument: %d.%d.\n", PIGLIT_CL_VERSION/10, PIGLIT_CL_VERSION%10, version/10, version%10); piglit_report_result(PIGLIT_SKIP); } } else { /* * If version was not provided on the command line, set it to * the version against which Piglit was compiled (PIGLIT_CL_VERSION) */ version = PIGLIT_CL_VERSION; } /* Run the actual test */ if(!(config->run_per_platform || config->run_per_device)) { print_test_info(config, version, NULL, NULL); result = config->_test_run(argc, (const char**)argv, (void*)config, version, NULL, NULL); } else { /* Run tests per platform or device */ int i; regex_t platform_regex; regex_t device_regex; bool platform_defined; unsigned int num_platforms; cl_platform_id* platform_ids; /* Create regexes */ if( config->platform_regex != NULL && regcomp(&platform_regex, config->platform_regex, REG_EXTENDED | REG_NEWLINE)) { fprintf(stderr, "Regex to filter platforms is invalid, ignoring it.\n"); regcomp(&platform_regex, "", REG_EXTENDED | REG_NEWLINE); piglit_merge_result(&result, PIGLIT_WARN); } if( config->device_regex != NULL && regcomp(&device_regex, config->device_regex, REG_EXTENDED | REG_NEWLINE)) { fprintf(stderr, "Regex to filter devices is invalid, ignoring it.\n"); regcomp(&device_regex, "", REG_EXTENDED | REG_NEWLINE); piglit_merge_result(&result, PIGLIT_WARN); } /* check for command-line/environment platform */ platform_defined = piglit_cl_get_platform_arg(argc, (const char**)argv, &platform_id); /* generate platforms list */ if(platform_defined) { /* use platform defined by command-line/environment */ num_platforms = 1; platform_ids = malloc(sizeof(cl_platform_id)); platform_ids[0] = platform_id; } else { /* use all available platforms */ num_platforms = piglit_cl_get_platform_ids(&platform_ids); } /* execute test for each platform in platforms list */ for(i = 0; i < num_platforms; i++) { int final_version = version; int platform_version; platform_id = platform_ids[i]; /* Filter platform */ if(config->platform_regex != NULL) { char* platform_name; platform_name = piglit_cl_get_platform_info(platform_id, CL_PLATFORM_NAME); if(regexec(&platform_regex, platform_name, 0, NULL, 0)) { printf("\n# Skipping platform %s because it does not match platform_regex.\n\n", platform_name); free(platform_name); continue; } free(platform_name); } /* Check platform extensions */ if(!check_platform_extensions(platform_id, config->require_platform_extensions)) { continue; } /* Get platform version */ platform_version = piglit_cl_get_platform_version(platform_id); if(config->run_per_platform) { /* Check platform version */ if(platform_version < final_version) { printf("# Platform supporting only version %d.%d. Running test on that version.\n", platform_version/10, platform_version%10); final_version = platform_version; } /* run test on platform */ print_test_info(config, final_version, platform_id, NULL); piglit_merge_result(&result, config->_test_run(argc, (const char**)argv, (void*)config, final_version, platform_id, NULL)); } else { //config->run_per_device int j; bool device_defined; unsigned int num_devices; cl_device_id* device_ids; /* check for command-line/environment device */ device_defined = piglit_cl_get_device_arg(argc, (const char**)argv, platform_id, &device_id); /* generate devices list */ if(device_defined) { /* use device defined by command-line/environment */ num_devices = 1; device_ids = malloc(sizeof(cl_device_id)); device_ids[0] = device_id; } else { /* use all available devices */ num_devices = piglit_cl_get_device_ids(platform_id, CL_DEVICE_TYPE_ALL, &device_ids); } /* run tests per each device */ for(j = 0; j < num_devices; j++) { int device_version; device_id = device_ids[j]; /* Filter device */ if(config->device_regex != NULL) { char* device_name; device_name = piglit_cl_get_device_info(device_id, CL_DEVICE_NAME); if(regexec(&device_regex, device_name, 0, NULL, 0)) { printf("\n# Skipping device %s because it does not match device_regex.\n\n", device_name); free(device_name); continue; } free(device_name); } /* Check device extensions */ if(!check_device_extensions(device_id, config->require_device_extensions)) { continue; } /* Check platform version */ if(platform_version < final_version) { printf("# Platform supporting only version %d.%d. Running test on that version.\n", platform_version/10, platform_version%10); final_version = platform_version; } /* Check device version */ device_version = piglit_cl_get_device_version(device_id); if(device_version < final_version) { printf("# Device supporting only version %d.%d. Running test on that version.\n", device_version/10, device_version%10); final_version = device_version; } print_test_info(config, version, platform_id, device_id); piglit_merge_result(&result, config->_test_run(argc, (const char**)argv, (void*)config, final_version, platform_id, device_id)); } free(device_ids); } } if(config->platform_regex != NULL) { regfree(&platform_regex); } if(config->device_regex != NULL) { regfree(&device_regex); } free(platform_ids); } /* Clean */ if(config->clean_func != NULL) { config->clean_func(argc, (const char**)argv, config); } /* Report merged result */ printf("# Result:\n"); piglit_report_result(result); /* UNREACHED */ return 1; }