int main() { //[circular_buffer_bound_example_3] //`Construct a bounded_buffer to hold the chosen type, here int. bounded_buffer<int> bb_int(queue_size); std::cout << "Testing bounded_buffer<int> "; //`Start the fifo test. fifo_test(&bb_int); //` destructor of boost::timer::auto_cpu_timer will output the time to std::cout //] [/circular_buffer_bound_example_3] return 0; } // int main()
/** * * @brief Perform all selected benchmarks * * @return N/A */ void main(void) { int continuously = 0; int test_result; init_output(&continuously); bench_test_init(); do { fprintf(output_file, sz_module_title_fmt, "Nanokernel API test"); fprintf(output_file, sz_kernel_ver_fmt, sys_kernel_version_get()); fprintf(output_file, "\n\nEach test below is repeated %d times;\n" "average time for one iteration is displayed.", NUMBER_OF_LOOPS); test_result = 0; test_result += sema_test(); test_result += lifo_test(); test_result += fifo_test(); test_result += stack_test(); if (test_result) { /* sema/lifo/fifo/stack account for 12 tests in total */ if (test_result == 12) { fprintf(output_file, sz_module_result_fmt, sz_success); } else { fprintf(output_file, sz_module_result_fmt, sz_partial); } } else { fprintf(output_file, sz_module_result_fmt, sz_fail); } TC_PRINT_RUNID; } while (continuously && !kbhit()); output_close(); }
int main(int /*argc*/, char* /*argv*/[]) { bounded_buffer<int> bb_int(QUEUE_SIZE); std::cout << "bounded_buffer<int> "; fifo_test(&bb_int); bounded_buffer_space_optimized<int> bb_space_optimized_int(QUEUE_SIZE); std::cout << "bounded_buffer_space_optimized<int> "; fifo_test(&bb_space_optimized_int); bounded_buffer_deque_based<int> bb_deque_based_int(QUEUE_SIZE); std::cout << "bounded_buffer_deque_based<int> "; fifo_test(&bb_deque_based_int); bounded_buffer_list_based<int> bb_list_based_int(QUEUE_SIZE); std::cout << "bounded_buffer_list_based<int> "; fifo_test(&bb_list_based_int); bounded_buffer<std::string> bb_string(QUEUE_SIZE); std::cout << "bounded_buffer<std::string> "; fifo_test(&bb_string); bounded_buffer_space_optimized<std::string> bb_space_optimized_string(QUEUE_SIZE); std::cout << "bounded_buffer_space_optimized<std::string> "; fifo_test(&bb_space_optimized_string); bounded_buffer_deque_based<std::string> bb_deque_based_string(QUEUE_SIZE); std::cout << "bounded_buffer_deque_based<std::string> "; fifo_test(&bb_deque_based_string); bounded_buffer_list_based<std::string> bb_list_based_string(QUEUE_SIZE); std::cout << "bounded_buffer_list_based<std::string> "; fifo_test(&bb_list_based_string); return 0; }
void *pt_final_test(void *args) { final_test_t arg = *(final_test_t *) args; free(args); int i; int result; // once this is set we can no longer send other commands running_final_test = 1; // now we can unlock our things, since nothing else should use them sbc_lock = 0; xl3_lock[arg.crate_num] = 0; fd_set thread_fdset; FD_ZERO(&thread_fdset); FD_SET(rw_xl3_fd[arg.crate_num],&thread_fdset); char ft_ids[16][250]; char id_string[16*250]; JsonNode *ft_docs[16]; char comments[1000]; memset(comments,'\0',1000); char command_buffer[100]; system("clear"); pt_printsend("------------------------------------------\n"); pt_printsend("Welcome to final test!\nHit enter to start\n"); read_from_tut(comments); pt_printsend("------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -x -v",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("------------------------------------------\n"); while (rw_sbc_fd <= 0){ pt_printsend("Attempting to connecting to sbc\n"); do { sprintf(command_buffer,"sbc_control"); } while (sbc_control(command_buffer) != 0); while (sbc_lock != 0){} } pt_printsend("------------------------------------------\n"); do { sprintf(command_buffer,"mtc_init -x"); result = mtc_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (sbc_lock != 0 || xl3_lock[arg.crate_num] != 0){} pt_printsend("------------------------------------------\n"); pt_printsend("If any boards could not initialize properly, type \"quit\" now " "to exit the test.\n Otherwise hit enter to continue.\n"); read_from_tut(comments); if (strncmp("quit",comments,4) == 0){ pt_printsend("Exiting final test\n"); running_final_test = 0; unthread_and_unlock(1,(0x1<<arg.crate_num),arg.thread_num); return; } // set up the final test documents for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ get_new_id(ft_ids[i]); ft_docs[i] = json_mkobject(); sprintf(id_string+strlen(id_string),"%s ",ft_ids[i]); pt_printsend(".%s.\n",id_string); } } pt_printsend("Now starting board_id\n"); do { sprintf(command_buffer,"board_id -c %d -s %04x",arg.crate_num,arg.slot_mask); result = board_id(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); if (arg.skip == 0){ for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ pt_printsend("Please enter any comments for slot %i motherboard now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"fec_comments",json_mkstring(comments)); pt_printsend("Has this slot been refurbished? (y/n)\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"refurbished",json_mkbool(comments[0] == 'y')); pt_printsend("Has this slot been cleaned? (y/n)\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"cleaned",json_mkbool(comments[0] == 'y')); pt_printsend("Time to measure resistance across analog outs and cmos address lines. For the cmos address lines" "it's easier if you do it during the fifo mod\n"); read_from_tut(comments); json_append_member(ft_docs[i],"analog_out_res",json_mkstring(comments)); pt_printsend("Please enter any comments for slot %i db 0 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db0_comments",json_mkstring(comments)); pt_printsend("Please enter any comments for slot %i db 1 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db1_comments",json_mkstring(comments)); pt_printsend("Please enter any comments for slot %i db 2 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db2_comments",json_mkstring(comments)); pt_printsend("Please enter any comments for slot %i db 3 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db3_comments",json_mkstring(comments)); pt_printsend("Please enter dark matter measurements for slot %i db 0 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db0_dark_matter",json_mkstring(comments)); pt_printsend("Please enter dark matter measurements for slot %i db 1 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db1_dark_matter",json_mkstring(comments)); pt_printsend("Please enter dark matter measurements for slot %i db 2 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db2_dark_matter",json_mkstring(comments)); pt_printsend("Please enter dark matter measurements for slot %i db 3 now.\n",i); read_from_tut(comments); json_append_member(ft_docs[i],"db3_dark_matter",json_mkstring(comments)); } } pt_printsend("Enter N100 DC offset\n"); read_from_tut(comments); for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ json_append_member(ft_docs[i],"dc_offset_n100",json_mkstring(comments)); } } pt_printsend("Enter N20 DC offset\n"); read_from_tut(comments); for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ json_append_member(ft_docs[i],"dc_offset_n20",json_mkstring(comments)); } } pt_printsend("Enter esum hi DC offset\n"); read_from_tut(comments); for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ json_append_member(ft_docs[i],"dc_offset_esumhi",json_mkstring(comments)); } } pt_printsend("Enter esum lo DC offset\n"); read_from_tut(comments); for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ json_append_member(ft_docs[i],"dc_offset_esumlo",json_mkstring(comments)); } } pt_printsend("Thank you. Please hit enter to continue with the rest of final test. This may take a while.\n"); read_from_tut(comments); } // starting the tests pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"fec_test -c %d -s %04x -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = fec_test(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"vmon -c %d -s %04x -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = vmon(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"cgt_test_1 -c %d -s %04x -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = cgt_test(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} ////////////////////////////////////////////////////////////// // now gotta turn pulser on and off to get rid of garbage //sprintf(command_buffer,"readout_add_mtc -c %d -f 0",arg.crate_num); //readout_add_mtc(command_buffer); //sprintf(command_buffer,"stop_pulser"); //stop_pulser(command_buffer); ////////////////////////////////////////////////////////////// pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"ped_run -c %d -s %04x -l 300 -u 1000 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = ped_run(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_cbal -c %d -s %04x -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = crate_cbal(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} ////////////////////////////////////////////////////////////// // now gotta turn pulser on and off to get rid of garbage //sprintf(command_buffer,"readout_add_mtc -c %d -f 0",arg.crate_num); //readout_add_mtc(command_buffer); //sprintf(command_buffer,"stop_pulser"); //stop_pulser(command_buffer); ////////////////////////////////////////////////////////////// pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -B",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"ped_run -c %d -s %04x -b -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = ped_run(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"chinj_scan -c %d -s %04x -l 400 -u 5000 -w 100 -n 10 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = chinj_scan(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); if (arg.tub_tests == 1){ pt_printsend("You should now connect the cable to ext_ped for ttot tests\nHit enter when ready\n"); read_from_tut(comments); do { sprintf(command_buffer,"set_ttot -c %d -s %04x -t 400 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = set_ttot(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} } pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -B -D",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); if (arg.tub_tests == 1){ do { sprintf(command_buffer,"get_ttot -c %d -s %04x -t 390 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = get_ttot(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} } pt_printsend("-------------------------------------------\n"); pt_printsend("You should now disconnect the cable to ext_ped\nHit enter when ready\n"); read_from_tut(comments); do { sprintf(command_buffer,"disc_check -c %d -s %04x -n 500000 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = disc_check(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"cmos_m_gtvalid -c %d -s %04x -g 400 -n -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = cmos_m_gtvalid(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} // would put see_reflections here pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"zdisc -c %d -s %04x -o 0 -r 100 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = zdisc(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"mtc_init"); result = mtc_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (sbc_lock != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -x",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do{ sprintf(command_buffer,"mb_stability_test -c %d -s %04x -n 50 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = mb_stability_test(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"fifo_test -c %d -s %04x -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = fifo_test(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -X",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"cald_test -c %d -s %04x -l 750 -u 3500 -n 200 -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = cald_test(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ do { pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -x",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); sprintf(command_buffer,"mem_test -c %d -s %d -d -# %s",arg.crate_num,i,ft_ids[i]); result = mem_test(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} } } pt_printsend("-------------------------------------------\n"); do { sprintf(command_buffer,"crate_init -c %d -s %04x -x",arg.crate_num,arg.slot_mask); result = crate_init(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} pt_printsend("-------------------------------------------\n"); pt_printsend("Ready for see_refl test. Hit enter to begin or type \"skip\" to end the final test.\n"); read_from_tut(comments); if (strncmp("skip",comments,4) != 0){ do { sprintf(command_buffer,"see_refl -c %d -s %04x -d -# %s",arg.crate_num,arg.slot_mask,id_string); result = see_refl(command_buffer); if (result == -2 || result == -3){ return; } } while (result != 0); while (xl3_lock[arg.crate_num] != 0){} } pt_printsend("-------------------------------------------\n"); pt_printsend("Final test finished. Now updating the database.\n"); // update the database for (i=0;i<16;i++){ if ((0x1<<i) & arg.slot_mask){ json_append_member(ft_docs[i],"type",json_mkstring("final_test")); pthread_mutex_lock(&socket_lock); xl3_lock[arg.crate_num] = 1; // we gotta lock this shit down before we call post_doc pthread_mutex_unlock(&socket_lock); post_debug_doc_with_id(arg.crate_num, i, ft_ids[i], ft_docs[i],&thread_fdset); json_delete(ft_docs[i]); } } pt_printsend("-------------------------------------------\n"); running_final_test = 0; unthread_and_unlock(1,(0x1<<arg.crate_num),arg.thread_num); }