void shutdown(void) { SGE_ASSERT(details::g_window != NULL); SGE_ASSERT(details::g_gl_context != NULL); SGE_ASSERT(s_imgui_context != NULL); shutdown_test(); s_program.Destroy(); ImGui::SetCurrentContext(s_imgui_context); ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplSDL2_Shutdown(); ImGui::SetCurrentContext(NULL); ImGui::DestroyContext(s_imgui_context); s_imgui_context = NULL; if (details::g_gl_context == SDL_GL_GetCurrentContext()) SDL_GL_MakeCurrent(details::g_window, NULL); SDL_GL_DeleteContext(details::g_gl_context); details::g_gl_context = NULL; SDL_DestroyWindow(details::g_window); details::g_window = NULL; details::g_window_id = 0; }
int main(int argc, char *argv[]) { init_test(); shutdown_test(); return 0; }
int Reader(int idx, int count) { Mai_t in_mad; int i,rc; int nHandles=0; IBhandle_t hdl[MAX_FD]; printf("\nINFO: Reader thread starting idx %d\n",idx); for(i=idx;i<(idx+count);i++) { hdl[nHandles++] = fd[i]; } for(i=0;i<loop;i++) { int first=-1; memset(&in_mad,0,sizeof(Mai_t)); if(nHandles==1) { //Now that we have sent the Mad we should receive it on the handle rc = mai_recv(hdl[0],&in_mad,timeout); if(rc == VSTATUS_TIMEOUT) continue; if(rc != VSTATUS_MAI_INTERNAL && rc != VSTATUS_OK) { printf("ERROR: - Unable to recv INTERNAL mad as expected %d\n",first); printf("ERROR: - mai_recv return status %s\n",cs_convert_status(rc)); exit(-1); } else { //we got a mad .. print the loop count printf("-count -> %u\n", *(uint32_t*)in_mad.data); mads++; if(*(uint32_t*)in_mad.data == loop) { printf("Final Mad received\n"); shutdown_test(mads-*(uint32_t*)in_mad.data); } } } else { rc = mai_wait_handle(hdl,nHandles,timeout,&first,&in_mad); if(rc == VSTATUS_OK) { //Now that we have sent the Mad we should receive it on the handle //rc = mai_recv(fd[first],&in_mad,0); if(rc != VSTATUS_MAI_INTERNAL && rc != VSTATUS_OK) { printf("ERROR: - Unable to recv INTERNAL mad as expected %d\n",first); printf("ERROR: - mai_recv return status %s\n",cs_convert_status(rc)); exit(-1); } //we got a mad .. print the loop count printf("+count -> %u\n", *(uint32_t*)in_mad.data); mads++; if(*(uint32_t*)in_mad.data == loop) { printf("Final Mad received\n"); shutdown_test(mads-*(uint32_t*)in_mad.data); } } else { if(rc == VSTATUS_TIMEOUT) { printf("\nINFO: wait returned %d\n",rc); } else { printf("ERROR: %s - mai_wait_handle return status\n",cs_convert_status(rc)); exit(-1); } } } } rc = (mads - *(uint32_t*)in_mad.data); printf("\nINFO: Reader done .. returning %d\n",rc); return rc; }
int main(int argc, char *argv[]) { int i,rc; Filter_t *fh; int max; if(argc > 1) parse_cmd_line(argc,argv); srand(getpid()); mai_init(); rc=ib_init_devport(&ib_dev, &ib_port, NULL); if (rc) { printf("ERROR: ib_init_devport failed, %s\n",cs_convert_status(rc)); exit(1); } for(i=0;i<fdcount;i++) { if ((rc = mai_open(0, ib_dev, ib_port, &fd[i])) != VSTATUS_OK) { printf("ERROR: can't open mai %s\n", cs_convert_status(rc)); exit(1); } } printf("\nINFO: PRE-TEST layers charecteristics %d\n",0); mode = fmode; switch(mode) { case FILTER_EXPOSED: printf("********** EXPOSED FILTER MODE *************\n"); break; case FILTER_METHOD: printf("********** METHOD MODE *********************\n"); break; case FILTER_AID: printf("********** AID MODE ************************\n"); break; case FILTER_AMOD: printf("********** AMOD MODE ************************\n"); break; case FILTER_ONCE: printf("********** ONCE MODE not supported *************************\n"); exit(-1); break; default: printf("********** UNKOWN MODE ***********************\n"); exit(-1); break; } memset(&all_filter,0,sizeof(all_filter)); max = fdcount; fh = &all_filter[0]; //First we linearly create the filters and delete them in the order //they were created. if(readers) { for(i=0;i<max;i++) { char name[32]; switch(mode) { case FILTER_EXPOSED: { IBhandle_t hd; fh->dev = ib_dev; fh->qp = MAI_FILTER_ANY; fh->port= ib_port; fh->type = MAI_TYPE_ANY; fh->value.bversion = i%2; fh->value.mclass = i%256; fh->value.cversion = i%256; fh->value.method = i%256; fh->value.status = i%(1<<16); fh->value.hopPointer = i%64; fh->value.hopCount = i%64; fh->value.tid = i; fh->value.aid = i%(1<<16); fh->value.amod = i; fh->mask.bversion = MAI_FMASK_ALL; fh->mask.mclass = MAI_FMASK_ALL; fh->mask.cversion = MAI_FMASK_ALL; fh->mask.method = MAI_FMASK_ALL; fh->mask.status = MAI_FMASK_ALL; fh->mask.hopPointer = MAI_FMASK_ALL; fh->mask.hopCount = MAI_FMASK_ALL; fh->mask.tid = MAI_FMASK_ALL; fh->mask.aid = MAI_FMASK_ALL; fh->mask.amod = MAI_FMASK_ALL; fh->active = (MAI_ACT_QP | MAI_ACT_DEV | MAI_ACT_TYPE | MAI_ACT_PORT | MAI_ACT_FMASK); sprintf(name,"Fil %d",i); MAI_SET_FILTER_NAME(fh,name); //now create the filter rc = mai_filter_hcreate(fd[i%fdcount],fh,flags,&all_handles[i]); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_create return status\n",cs_convert_status(rc)); exit(-1); } //now get the handle and compare .. make sure they //point to the same thing. rc = mai_filter_handle(fd[i%fdcount],fh,flags,&hd); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to get filter handle\n",i); printf("ERROR: %s - mai_filter_handle return status\n",cs_convert_status(rc)); exit(-1); } if(hd != all_handles[i]) { printf("ERROR: %d - Filter handles do not agree\n",i); exit(-1); } fh++; } break; case FILTER_METHOD: { rc = mai_filter_method(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i%256); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_method return status\n",cs_convert_status(rc)); exit(-1); } } break; case FILTER_AID: { rc = mai_filter_aid(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i%256,i); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_aid return status\n",cs_convert_status(rc)); exit(-1); } } break; case FILTER_AMOD: { rc = mai_filter_amod(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i%256,i,i); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_amod return status\n",cs_convert_status(rc)); exit(-1); } } break; case FILTER_ONCE: { rc = mai_filter_once(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_method return status\n",cs_convert_status(rc)); exit(-1); } } break; default: { printf("ERROR: %d - Unknown filter test mode\n",mode); exit(-1); } } } } if(writer) { //start the writer thread if(readers==0) { i=Writer(); shutdown_test(i); } else { //start the workert thread rc = vs_thread_create(&thandle[thread_cnt], (unsigned char*)"Writer",//name (void (*) (uint32_t,uint8_t**)) Writer, //func 0, //argc NULL, //argptr STACK_SIZE //stacksize ); if(rc) { printf("ERROR (%s): creating Writer thread\n", cs_convert_status(rc)); exit(-1); } printf("\nINFO: Writer thread created %s\n",cs_convert_status(rc)); thread_cnt++; } } if(readers) { int threads=0; int idx; if(fdcount > 2) { int threads; //start 2 normal readers and then //a wait_handle reader if(fdcount == 3) { threads = 1; idx = 2; } else { threads = 2; idx = fdcount - 2; } //now start single handle readers for(i=0;i<threads;i++) { thread_argv[thread_cnt][0] = (uint8_t*)(unsigned long)idx++; thread_argv[thread_cnt][1] = (uint8_t*)(unsigned long)1; rc = vs_thread_create(&thandle[thread_cnt], (unsigned char*)"Reader",//name (void (*) (uint32_t,uint8_t**))ThreadStart, //func 2, //argc (uint8_t **)&thread_argv[thread_cnt], //argptr STACK_SIZE //stacksize ); if(rc) { printf("ERROR (%s): creating reader thread\n", cs_convert_status(rc)); return -1; } thread_cnt++; } } //now do multi handle recv Reader(0,fdcount-threads); while(threads); } shutdown_test(mads-loop); return 0; }
int main(int argc, char **argv) { int rc = 0; int nr_round; if (argc < 3) { usage(); goto out; } if (strcmp(argv[1], "-n") != 0) { usage(); goto out; } nr_round = atoi(argv[2]); if (nr_round == 0) { usage(); goto out; } do { rc = unit_test(nr_round); if (rc != 0) { printf("unit_test failed.\n"); } else { printf("unit_test finished with round %d.\n", nr_round); } } while (FALSE); echo_test(); mkdir_test(); ls_test(); cd_test(); cat_test(); date_test(); lsmod_test(); null_dev_test(); multi_processes_test(); clear_test(); shutdown_test(); while (TRUE) { ; } out: return rc; }