void tests (void) { unsigned int res; unsigned char n; clrscr(); revers(1); //0123456789012345678901234567890123456789 cprintf("testing... press any key to abort. "); revers(0); n = 0; while (testinfo[n].generator) { testinfo[n].result = 0; if (((cpu_type == testinfo[n].cpu_type) || (testinfo[n].cpu_type == CPU_6502)) && (ram_banks >= testinfo[n].ram_banks)) { printinfo(n, 0); } ++n; } while(1) { n = 0; while (testinfo[n].generator) { if (((cpu_type == testinfo[n].cpu_type) || (testinfo[n].cpu_type == CPU_6502)) && (ram_banks >= testinfo[n].ram_banks)) { gotoxy(39,n + 1); cputc('*'); teststart(); testinfo[n].generator(); testend(); res = (0xffff - 29) - dotest(); testinfo[n].result = res; printrating(); printinfo(n, res); } ++n; if (kbhit()) { break; } } delay_200ms(); if (kbhit()) { break; } } while (kbhit()) { cgetc(); } }
/**************************************************************************** * * Subroutine main * *****************************************************************************/ int main(int argc, char *argv[]) { int tlkilled,tlpid, rc,status; /*tlpid=trace logger pid */ struct traceparser_state * tp_state; char message[200]; pthread_t cur_thread; /* * Start the tests. */ teststart(argv[0]); /* Get rid of tracelogger if it is running */ tlkilled=kill_tl(); /* Setup a channel for the MsgSend Events */ chid=ChannelCreate(0); assert(chid!=-1); /* Setup the barrier used to syncronize */ rc=pthread_barrier_init(&global_barrier, NULL, 2); assert(rc==EOK); /* Setup the mutex for the mutex/condvar state test */ rc=pthread_mutex_init(&mymutex,NULL); assert(rc==EOK); /* Setup the condvar for the condvar state test */ rc=pthread_cond_init(&mycondvar,NULL); assert(rc==EOK); /* setup the sem tfor the sem state test */ rc=sem_init(&mysem, 0,0); assert(rc==0); /* Setup the needed child */ child_pid=fork(); assert(child_pid!=-1); if (child_pid==0) { /* This child is used only in the stopped state test. * it will just sit and loop */ while (1) { delay(10); } exit(0); } /* and create a thread to go into various states */ rc=pthread_create(&cur_thread, NULL, state_thread, NULL); assert(rc==EOK); for (cur_state=STATE_DEAD;cur_state<=STATE_SEM;cur_state++) { /* these states can not be reliably and or safely triggered. */ if ((cur_state==STATE_STACK) || (cur_state==STATE_WAITPAGE) || cur_state==STATE_INTR) continue; /***********************************************************************/ /***********************************************************************/ /* * Make sure that if we trigger a thread state, that it gets logged * properly (all the information in the tracelogger is correct) * This tests the information provided in wide mode. */ snprintf(message, sizeof(message),"%s in wide mode", state_str[cur_state]); testpntbegin(message); exp_thread=cur_thread; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then thread states, then * start logging. * We then will trigger a thread state change, and flush the trace buffer. * This should create a VERY minimal trace buffer that will be easily parsed */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); fast_mode=WIDE; /* Add the given thread event in the thread class back in */ rc=TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD,(1<<cur_state)); assert(rc!=-1); /* Filter out all tids other then the state_thread */ if (cur_state==STATE_STOPPED) { rc=TraceEvent(_NTO_TRACE_SETCLASSTID, _NTO_TRACE_THREAD, child_pid, 1); } else { rc=TraceEvent(_NTO_TRACE_SETCLASSTID, _NTO_TRACE_THREAD, getpid(),cur_thread); } assert(rc!=-1); /* then trigger an event. Logging is started inside the state thread * right before it tries to trigger the given state. * the two barrier waits are to * 1) Tell the state thread that everything is setup so it should trigger the event * 2) Wait for the state thread to tell us it has finished. */ pthread_barrier_wait(&global_barrier); if ((cur_state==STATE_SEND)|| (cur_state==STATE_REPLY)) { /* If the thread is going into the send state, we should receive and reply */ sleep(1); status=MsgReceive(chid, message, sizeof(message), NULL); MsgReply(status, EOK, "ok", 3); } else if (cur_state==STATE_RECEIVE) { /* If the thread is going to call reveive, we should send it a message */ sleep(1); status=ConnectAttach(0, getpid(), chid, _NTO_SIDE_CHANNEL, 0); MsgSend(status, message, 10, message,10); } else if (cur_state==STATE_MUTEX) { pthread_mutex_lock(&mymutex); sleep(2); pthread_mutex_unlock(&mymutex); } else if (cur_state==STATE_CONDVAR) { sleep(2); pthread_cond_signal(&mycondvar); } else if (cur_state==STATE_SEM) { sleep(2); sem_post(&mysem); } /* If the state thread is going to try to trigger the dead state, it will have to * exit, so we can not expect it to call barrier_wait to tell us it's done. */ if ((1<<cur_state)!=_NTO_TRACE_THDEAD) { pthread_barrier_wait(&global_barrier); } else { /* If the state thread is going to exit, then we should just * give it time to exit, then restart it. */ sleep(2); rc=pthread_join(cur_thread, (void **)&status); assert(rc==EOK); rc=pthread_create(&cur_thread, NULL, state_thread, NULL); } delay(100); /* flush the trace buffer and wait for the tracelogger to exit*/ rc=TraceEvent(_NTO_TRACE_FLUSHBUFFER); assert(rc!=-1); rc=waitpid(tlpid, &status, 0); assert(tlpid==rc); /* Now, setup the traceparser lib to pull out the thread state events, * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs(tp_state, NULL, parse_cb, _NTO_TRACE_THREAD, (1<<cur_state)); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (correct_values==0) testpntfail("Our callback never got called, no events?"); else if (correct_values==-1) testpntfail("Got the wrong thread state"); else if (correct_values==-2) testpntfail("Got the wrong pid"); else if (correct_values==-3) testpntfail("Got the wrong tid"); else if (correct_values==1) testpntpass("Got the correct values"); else testpntfail("This should not happen"); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if we trigger a thread state, that it gets logged * properly (all the information in the tracelogger is correct) * This tests the information provided in fast mode. */ snprintf(message, sizeof(message),"%s in fast mode", state_str[cur_state]); testpntbegin(message); exp_thread=cur_thread; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then thread states, then * start logging. * We then will trigger a thread state change, and flush the trace buffer. * This should create a VERY minimal trace buffer that will be easily parsed */ tlpid=start_logger(); sleep(1); /* Set the logger to fast emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESFAST); assert(rc!=-1); fast_mode=FAST; /* Add the given thread event in the thread class back in */ rc=TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD,(1<<cur_state)); assert(rc!=-1); /* Filter out all tids other then the state_thread */ if (cur_state==STATE_STOPPED) { rc=TraceEvent(_NTO_TRACE_SETCLASSTID, _NTO_TRACE_THREAD, child_pid, 1); } else { rc=TraceEvent(_NTO_TRACE_SETCLASSTID, _NTO_TRACE_THREAD, getpid(),cur_thread); } assert(rc!=-1); /* then trigger an event. Logging is started inside the state thread * right before it tries to trigger the given state. * the two barrier waits are to * 1) Tell the state thread that everything is setup so it should trigger the event * 2) Wait for the state thread to tell us it has finished. */ pthread_barrier_wait(&global_barrier); if ((cur_state==STATE_SEND)|| (cur_state==STATE_REPLY)) { /* If the thread is going into the send state, we should receive and reply */ sleep(1); status=MsgReceive(chid, message, sizeof(message), NULL); MsgReply(status, EOK, "ok", 3); } else if (cur_state==STATE_RECEIVE) { /* If the thread is going to call reveive, we should send it a message */ sleep(1); status=ConnectAttach(0, getpid(), chid, _NTO_SIDE_CHANNEL, 0); MsgSend(status, message, 10, message,10); } else if (cur_state==STATE_MUTEX) { pthread_mutex_lock(&mymutex); sleep(2); pthread_mutex_unlock(&mymutex); } else if (cur_state==STATE_CONDVAR) { sleep(2); pthread_cond_signal(&mycondvar); } else if (cur_state==STATE_SEM) { sleep(2); sem_post(&mysem); } /* If the state thread is going to try to trigger the dead state, it will have to * exit, so we can not expect it to call barrier_wait to tell us it's done. */ if ((1<<cur_state)!=_NTO_TRACE_THDEAD) { pthread_barrier_wait(&global_barrier); } else { /* If the state thread is going to exit, then we should just * give it time to exit, then restart it. */ sleep(2); rc=pthread_join(cur_thread, (void **)&status); assert(rc==EOK); rc=pthread_create(&cur_thread, NULL, state_thread, NULL); } delay(100); /* flush the trace buffer and wait for the tracelogger to exit*/ rc=TraceEvent(_NTO_TRACE_FLUSHBUFFER); assert(rc!=-1); rc=waitpid(tlpid, &status, 0); assert(tlpid==rc); /* Now, setup the traceparser lib to pull out the thread state events, * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs(tp_state, NULL, parse_cb, _NTO_TRACE_THREAD, (1<<cur_state)); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (correct_values==0) testpntfail("Our callback never got called, no events?"); else if (correct_values==-1) testpntfail("Got the wrong thread state"); else if (correct_values==-2) testpntfail("Got the wrong pid"); else if (correct_values==-3) testpntfail("Got the wrong tid"); else if (correct_values==1) testpntpass("Got the correct values"); else testpntfail("This should not happen"); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ } /* If the tracelogger was running when we started, we should restart it again */ if (tlkilled==1) system("reopen /dev/null ; tracelogger -n 0 -f /dev/null &"); /* Kill off the child we had forked earler */ kill (child_pid, SIGKILL); teststop(argv[0]); return 0; }
int mainprog(void) { int16_t frame,t; struct monster_obj *nobbin, *hobbin; struct digger_obj odigger; struct obj_position newpos; loadscores(); escape=false; nobbin = NULL; hobbin = NULL; do { soundstop(); creatembspr(); detectjoy(); ddap->gclear(); ddap->gtitle(); outtext(ddap, "D I G G E R",100,0,3); shownplayers(); showtable(ddap); started=false; frame=0; newframe(); teststart(); while (!started) { started=teststart(); if ((akeypressed==27 || akeypressed=='n' || akeypressed=='N') && !gauntlet && diggers==1) { switchnplayers(); shownplayers(); akeypressed=0; } if (frame==0) for (t=54;t<174;t+=12) outtext(ddap, " ",164,t,0); if (frame==50) { if (nobbin != NULL) { CALL_METHOD(nobbin, dtor); } nobbin = monster_obj_ctor(0, MON_NOBBIN, DIR_LEFT, 292, 63); CALL_METHOD(nobbin, put); } if (frame>50 && frame<=77) { CALL_METHOD(nobbin, getpos, &newpos); newpos.x -= 4; if (frame == 77) { newpos.dir = DIR_RIGHT; } CALL_METHOD(nobbin, setpos, &newpos); } if (frame > 50) { CALL_METHOD(nobbin, animate); } if (frame==83) outtext(ddap, "NOBBIN",216,64,2); if (frame==90) { if (hobbin != NULL) { CALL_METHOD(hobbin, dtor); } hobbin = monster_obj_ctor(1, MON_NOBBIN, DIR_LEFT, 292, 82); CALL_METHOD(hobbin, put); } if (frame>90 && frame<=117) { CALL_METHOD(hobbin, getpos, &newpos); newpos.x -= 4; if (frame == 117) { newpos.dir = DIR_RIGHT; } CALL_METHOD(hobbin, setpos, &newpos); } if (frame == 100) { CALL_METHOD(hobbin, mutate); } if (frame > 90) { CALL_METHOD(hobbin, animate); } if (frame==123) outtext(ddap, "HOBBIN",216,83,2); if (frame==130) { digger_obj_init(&odigger, 0, DIR_LEFT, 292, 101); CALL_METHOD(&odigger, put); } if (frame>130 && frame<=157) { odigger.x -= 4; } if (frame>157) { odigger.dir = DIR_RIGHT; } if (frame >= 130) { CALL_METHOD(&odigger, animate); } if (frame==163) outtext(ddap, "DIGGER",216,102,2); if (frame==178) { movedrawspr(FIRSTBAG,184,120); drawgold(0,0,184,120); } if (frame==183) outtext(ddap, "GOLD",216,121,2); if (frame==198) drawemerald(184,141); if (frame==203) outtext(ddap, "EMERALD",216,140,2); if (frame==218) drawbonus(184,158); if (frame==223) outtext(ddap, "BONUS",216,159,2); if (frame == 235) { CALL_METHOD(nobbin, damage); } if (frame == 239) { CALL_METHOD(nobbin, kill); } if (frame == 242) { CALL_METHOD(hobbin, damage); } if (frame == 246) { CALL_METHOD(hobbin, kill); } newframe(); frame++; if (frame>250) frame=0; } if (savedrf) { if (gotgame) { recsavedrf(); gotgame=false; } savedrf=false; continue; } if (escape) break; recinit(); game(); gotgame=true; if (gotname) { recsavedrf(); gotgame=false; } savedrf=false; escape=false; } while (!escape); finish(); return 0; }
/**************************************************************************** * * Subroutine main * *****************************************************************************/ int main(int argc, char *argv[]) { int tlkilled,tlpid, rc,status; //tlpid=trace logger pid struct traceparser_state * tp_state; /* * Start the tests. */ teststart(argv[0]); /* Get rid of tracelogger if it is running */ tlkilled=kill_tl(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that interrupt events get logged * This tests the information provided in wide mode. */ testpntbegin("Get interrupt entry in wide mode"); /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then interrupt events, and * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add interrupt entry's */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_INTENTER); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* Wait a bit, so some timer interrupts should fire */ delay(100); /* flush the trace buffer */ rc=TraceEvent(_NTO_TRACE_FLUSHBUFFER); assert(rc!=-1); rc=waitpid(tlpid, &status, 0); assert(tlpid==rc); /* Now, setup the traceparser lib to pull out the interrupt events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb, _NTO_TRACE_INTENTER, _NTO_TRACE_INTFIRST, _NTO_TRACE_INTLAST); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (correct_values==0) testpntfail("Our callback never got called, no events?"); else if (correct_values==-1) testpntfail("Wrong parameters in the event"); else if (correct_values==1) testpntpass("Got the correct values"); else testpntfail("This should not happen"); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if we trigger a event, that it gets logged properly * (all the information in the tracelogger is correct) * This tests the information provided in fast mode. */ testpntbegin("Get interrupt entry in fast mode"); /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then interrupts, then start * logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESFAST); assert(rc!=-1); /* Add interrupt entry's */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_INTENTER); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* Wait a bit, so some timer interrupts should fire */ delay(1000); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* flush the trace buffer */ rc=TraceEvent(_NTO_TRACE_FLUSHBUFFER); assert(rc!=-1); rc=waitpid(tlpid, &status, 0); assert(tlpid==rc); /* Now, setup the traceparser lib to pull out the interrupt events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb, _NTO_TRACE_INTENTER, _NTO_TRACE_INTFIRST, _NTO_TRACE_INTLAST); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (correct_values==0) testpntfail("Our callback never got called, no events?"); else if (correct_values==-1) testpntfail("Wrong parameters in the event"); else if (correct_values==1) testpntpass("Got the correct values"); else testpntfail("This should not happen"); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if we trigger a event, that it gets logged properly * (all the information in the tracelogger is correct) * This tests the information provided in wide mode. */ testpntbegin("Get interrupt exit in wide mode"); /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then interrupts, then start * logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add interrupt entry's */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_INTEXIT); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* Wait a bit, so some timer interrupts should fire */ delay(1000); /* flush the trace buffer */ rc=TraceEvent(_NTO_TRACE_FLUSHBUFFER); assert(rc!=-1); rc=waitpid(tlpid, &status, 0); assert(tlpid==rc); /* Now, setup the traceparser lib to pull out the interrupt events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb, _NTO_TRACE_INTEXIT, _NTO_TRACE_INTFIRST, _NTO_TRACE_INTLAST); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (correct_values==0) testpntfail("Our callback never got called, no events?"); else if (correct_values==-1) testpntfail("Wrong parameters in the event"); else if (correct_values==1) testpntpass("Got the correct values"); else testpntfail("This should not happen"); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if we trigger a event, that it gets logged properly * (all the information in the tracelogger is correct) * This tests the information provided in fast mode. */ testpntbegin("Get interrupt exit in fast mode"); /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then interrupts, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESFAST); assert(rc!=-1); /* Add interrupt entry's */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_INTEXIT); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* Wait a bit, so some timer interrupts should fire */ delay(1000); /* flush the trace buffer */ rc=TraceEvent(_NTO_TRACE_FLUSHBUFFER); assert(rc!=-1); rc=waitpid(tlpid, &status, 0); assert(tlpid==rc); /* Now, setup the traceparser lib to pull out the interrupt events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb, _NTO_TRACE_INTEXIT, _NTO_TRACE_INTFIRST, _NTO_TRACE_INTLAST); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (correct_values==0) testpntfail("Our callback never got called, no events?"); else if (correct_values==-1) testpntfail("Wrong parameters in the event"); else if (correct_values==1) testpntpass("Got the correct values"); else testpntfail("This should not happen"); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /* If the tracelogger was running when we started, we should restart it again */ if (tlkilled==1) system("reopen /dev/null ; tracelogger -n 0 -f /dev/null &"); teststop(argv[0]); return 0; }
/**************************************************************************** * * Subroutine main * *****************************************************************************/ int main(int argc, char *argv[]) { int tlkilled,tlpid, rc,status,x,firstfail,child; /*tlpid=trace logger pid*/ struct traceparser_state * tp_state; struct stat statbuf; char buf[100]; int events[] = {__KER_MSG_SENDV,__KER_MSG_SENDVNC,__KER_MSG_ERROR,__KER_MSG_RECEIVEV,__KER_MSG_REPLYV, __KER_MSG_READV,__KER_MSG_WRITEV,__KER_MSG_READWRITEV,__KER_MSG_INFO,__KER_MSG_SEND_PULSE,__KER_MSG_DELIVER_EVENT, __KER_MSG_KEYDATA,__KER_MSG_READIOV,__KER_MSG_RECEIVEPULSEV,__KER_MSG_VERIFY_EVENT,__KER_SIGNAL_KILL, __KER_SIGNAL_RETURN, __KER_SIGNAL_FAULT, __KER_SIGNAL_ACTION, __KER_SIGNAL_PROCMASK,__KER_SIGNAL_SUSPEND,__KER_SIGNAL_WAITINFO,__KER_CHANNEL_CREATE, __KER_CHANNEL_DESTROY,__KER_CONNECT_ATTACH,__KER_CONNECT_DETACH,__KER_CONNECT_SERVER_INFO,__KER_CONNECT_CLIENT_INFO, __KER_CONNECT_FLAGS,__KER_THREAD_CREATE,__KER_THREAD_DESTROY,__KER_THREAD_DESTROYALL, __KER_THREAD_DETACH, __KER_THREAD_JOIN,__KER_THREAD_CANCEL,__KER_THREAD_CTL,__KER_SYNC_CREATE,__KER_SYNC_DESTROY,__KER_SYNC_MUTEX_LOCK, __KER_SYNC_MUTEX_UNLOCK,__KER_SYNC_CONDVAR_WAIT,__KER_SYNC_CONDVAR_SIGNAL,__KER_SYNC_SEM_POST, __KER_SYNC_SEM_WAIT,__KER_SYNC_CTL,__KER_SYNC_MUTEX_REVIVE, /* 46 kernel calls*/ _NTO_TRACE_THCONDVAR,_NTO_TRACE_THCREATE,_NTO_TRACE_THDEAD,_NTO_TRACE_THDESTROY,_NTO_TRACE_THINTR, _NTO_TRACE_THJOIN,_NTO_TRACE_THMUTEX,_NTO_TRACE_THNANOSLEEP,_NTO_TRACE_THNET_REPLY,_NTO_TRACE_THNET_SEND, _NTO_TRACE_THREADY,_NTO_TRACE_THRECEIVE,_NTO_TRACE_THREPLY,_NTO_TRACE_THRUNNING,_NTO_TRACE_THSEM, _NTO_TRACE_THSEND,_NTO_TRACE_THSIGSUSPEND,_NTO_TRACE_THSIGWAITINFO,_NTO_TRACE_THSTACK,_NTO_TRACE_THSTOPPED, _NTO_TRACE_THWAITCTX,_NTO_TRACE_THWAITPAGE,_NTO_TRACE_THWAITTHREAD, /* 23 thread states */ -1}; /* * Start the tests. */ teststart(argv[0]); /* Get rid of tracelogger if it is running */ tlkilled=kill_tl(); /***********************************************************************/ /***********************************************************************/ /* * This is a simple test to make sure we need to have io privity to * add event handlers. */ testpntbegin("need io privity to add event handler"); errno=0; my_event_data[0].data_array=data_array[0]; rc=TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY, event_handler, &my_event_data[0]); if (rc!=-1) { testpntfail("Was able to attach an event handler"); TraceEvent(_NTO_TRACE_DELEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY); }else { if (errno==EPERM) testpntpass("Good"); else testpntfail(strerror(errno)); } testpntend(); /* We should need io privity to attach event handlers */ rc=ThreadCtl( _NTO_TCTL_IO, 0 ); assert(rc!=-1); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if the event_handler returns 1 that the events get * logged. */ testpntbegin("Event handler returns 1"); to_return=1; correct_values_eh=0; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then our thread state, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD, 1<<STATE_READY); assert(rc!=-1); /* Setup the event handler */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); my_event_data[0].data_array=data_array[0]; TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY, event_handler, &my_event_data[0]); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* Make sure there is some system activity going on */ while(waitpid(tlpid, &status, WNOHANG)!=tlpid ) { stat("/proc/", &statbuf); } /* Now, setup the traceparser lib to pull out the thread state events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb,_NTO_TRACE_THREAD, _NTO_TRACE_THDEAD, _NTO_TRACE_THDESTROY); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if ((correct_values<=correct_values_eh) && (correct_values>0)) testpntpass("Good"); else if (correct_values==0) testpntfail("No events were logged"); else if (correct_values_eh<correct_values) testpntfail("Different number of events in eventhandler and tracebuffer"); TraceEvent(_NTO_TRACE_DELEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if the event_handler returns 1 that the events get * logged. */ testpntbegin("Event handler returns 0"); to_return=0; correct_values_eh=0; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then our thread state, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD, 1<<STATE_READY); assert(rc!=-1); /* Setup the event handler */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); my_event_data[0].data_array=data_array[0]; TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY, event_handler, &my_event_data[0]); rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); assert(rc!=-1); /* Make sure there is some system activity going on */ x=0; while(waitpid(tlpid, &status, WNOHANG)!=tlpid ) { stat("/proc/", &statbuf); x++; if (x>100) TraceEvent(_NTO_TRACE_FLUSHBUFFER); } /* Now, setup the traceparser lib to pull out the thread state events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb,_NTO_TRACE_THREAD, _NTO_TRACE_THDEAD, _NTO_TRACE_THDESTROY); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if ((correct_values_eh>0) && (correct_values==0)) { testpntpass("Good"); } else if (correct_values_eh==0) { testpntfail("Event handler was not called"); } else testpntfail("Events were logged when event handler returned 0"); TraceEvent(_NTO_TRACE_DELEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY); traceparser_destroy(&tp_state); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if the event_handler returns a large number (other * then 1) that all events are still logged. */ testpntbegin("Event handler returns a large number"); to_return=9999999; correct_values_eh=0; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then our thread state, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD, 1<<STATE_READY); assert(rc!=-1); /* Setup the event handler */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); my_event_data[0].data_array=data_array[0]; TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY, event_handler, &my_event_data[0]); errno=0; rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); if (rc==-1) { testnote(strerror(errno)); } assert(rc!=-1); /* Make sure there is some system activity going on */ while(waitpid(tlpid, &status, WNOHANG)!=tlpid ) { stat("/proc/", &statbuf); } /* Now, setup the traceparser lib to pull out the thread state events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb,_NTO_TRACE_THREAD, _NTO_TRACE_THDEAD, _NTO_TRACE_THDESTROY); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if ((correct_values<=correct_values_eh) && (correct_values>0)) testpntpass("Good"); else if (correct_values==0) testpntfail("No events were logged"); else if (correct_values_eh<correct_values) testpntfail("Different number of events in eventhandler and tracebuffer"); traceparser_destroy(&tp_state); TraceEvent(_NTO_TRACE_DELEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * Make sure that if the event_handler returns a negitive number that * that all events are still logged. */ testpntbegin("Event handler returns a negitive"); to_return=-2; correct_values_eh=0; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then our thread state, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD, 1<<STATE_READY); assert(rc!=-1); /* Setup the event handler */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); my_event_data[0].data_array=data_array[0]; TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY, event_handler, &my_event_data[0]); errno=0; rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); if (rc==-1) { testnote(strerror(errno)); } assert(rc!=-1); /* Make sure there is some system activity going on */ while(waitpid(tlpid, &status, WNOHANG)!=tlpid ) { stat("/proc/", &statbuf); } /* Now, setup the traceparser lib to pull out the thread state events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb,_NTO_TRACE_THREAD, _NTO_TRACE_THDEAD, _NTO_TRACE_THDESTROY); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if ((correct_values<=correct_values_eh) && (correct_values>0)) testpntpass("Good"); else if (correct_values==0) testpntfail("No events were logged"); else if (correct_values_eh<correct_values) testpntfail("Different number of events in eventhandler and tracebuffer"); traceparser_destroy(&tp_state); TraceEvent(_NTO_TRACE_DELEVENTHANDLER, _NTO_TRACE_THREAD,1<<STATE_READY); testpntend(); /***********************************************************************/ /***********************************************************************/ /* * At the time of writing, there is a system limit of 64 event handlers * that can be attached at one time. Try to attach 64 to make sure it * works as expected. */ testpntbegin("64 event handlers attached"); to_return=1; correct_values_eh=0; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then our thread state, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_KERCALLENTER); assert(rc!=-1); /* Setup the event handlers */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); for (x=0;x<64;x++) { my_event_data[x].data_array=data_array[x]; rc=TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_KERCALLENTER,x, event_handler, &my_event_data[x]); if (rc==-1) break; } errno=0; rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); if (rc==-1) { testnote(strerror(errno)); } assert(rc!=-1); /* Make sure there is some system activity going on */ while(waitpid(tlpid, &status, WNOHANG)!=tlpid ) { stat("/proc/", &statbuf); } /* Now, setup the traceparser lib to pull out the thread state events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb,_NTO_TRACE_KERCALLENTER, 0, 64); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (x<64) { snprintf(buf,sizeof(buf), "Could only attach %d event handler\n", x); testpntfail(buf); } else if ((correct_values<=correct_values_eh) && (correct_values>0)) testpntpass("Good"); else if (correct_values==0) testpntfail("No events were logged"); else if (correct_values_eh<correct_values) testpntfail("Different number of events in eventhandler and tracebuffer"); traceparser_destroy(&tp_state); for (x=0;x<64;x++) { TraceEvent(_NTO_TRACE_DELEVENTHANDLER, _NTO_TRACE_KERCALLENTER,x); } testpntend(); /***********************************************************************/ /***********************************************************************/ /* * At the time of writing, there is a system limit of 64 event handlers * that can be attached at one time. Try to attach more then 64 to make * sure it works as expected. */ testpntbegin("More then 64 event handlers attached"); to_return=1; correct_values_eh=0; /* We need to start up the tracelogger in daemon mode, 1 itteration. * we will filter out everything other then our thread state, then * start logging. */ tlpid=start_logger(); sleep(1); /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_KERCALLENTER); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_THREAD); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_VTHREAD); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_PROCESS); assert(rc!=-1); /* Setup the event handlers */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); firstfail=-1; for (x=0;x<69;x++) { my_event_data[x].data_array=data_array[x]; rc=TraceEvent(_NTO_TRACE_ADDEVENTHANDLER,(x>45)?_NTO_TRACE_THREAD:_NTO_TRACE_KERCALLENTER,events[x], event_handler, &my_event_data[x]); if ((rc==-1) &&(firstfail==-1)) firstfail=x; } errno=0; rc=TraceEvent(_NTO_TRACE_STARTNOSTATE); if (rc==-1) { testnote(strerror(errno)); } assert(rc!=-1); /* Make sure there is some system activity going on */ while(waitpid(tlpid, &status, WNOHANG)!=tlpid ) { stat("/proc/", &statbuf); } /* Now, setup the traceparser lib to pull out the thread state events * and make sure our event shows up */ tp_state=traceparser_init(NULL); assert(tp_state!=NULL); traceparser_cs_range(tp_state, NULL, parse_cb,_NTO_TRACE_KERCALLENTER, 0, 64); /* Since we don't want a bunch of output being displayed in the * middle of the tests, turn off verbose output. */ traceparser_debug(tp_state, stdout, _TRACEPARSER_DEBUG_NONE); /* Set correct_values to 0, so we can see if the callback actually * got called. */ correct_values=0; /* And parse the tracebuffer */ traceparser(tp_state, NULL, "/dev/shmem/tracebuffer"); if (firstfail<64) { snprintf(buf,sizeof(buf), "Could only attach %d event handler\n", firstfail); testpntfail(buf); } else if (firstfail>64) { snprintf(buf,sizeof(buf), "Was allowed to attach %d handler, should only be 64\n", firstfail); testpntfail(buf); } else if ((correct_values<=correct_values_eh) && (correct_values>0)) testpntpass("Good"); else if (correct_values==0) testpntfail("No events were logged"); else if (correct_values_eh<correct_values) testpntfail("Different number of events in eventhandler and tracebuffer"); traceparser_destroy(&tp_state); for (x=0;x<69;x++) { TraceEvent(_NTO_TRACE_DELEVENTHANDLER,(x>45)?_NTO_TRACE_THREAD:_NTO_TRACE_KERCALLENTER,events[x]); } testpntend(); /***********************************************************************/ /***********************************************************************/ /* * At the time of writing, there is a system limit of 64 event handlers * that can be attached at one time. Try to attach more then 64 to make * sure it works as expected. * This test will do the same as above, but it will fork a child to add * the event handlers. The child will then exit without starting * tracelogger or removing the event handlers. This is just to make * sure it does not cause any problems. */ testpntbegin("64+ event handlers - not cleaned up "); to_return=1; correct_values_eh=0; child=fork(); assert(child!=-1); if (child==0) { /* Set the logger to wide emmiting mode */ rc=TraceEvent(_NTO_TRACE_SETALLCLASSESWIDE); assert(rc!=-1); /* Add the classes we want to look at */ rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_KERCALL); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_THREAD); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_VTHREAD); assert(rc!=-1); rc=TraceEvent(_NTO_TRACE_ADDCLASS, _NTO_TRACE_PROCESS); assert(rc!=-1); /* Setup the event handlers */ memset(&my_event_data, 0, sizeof(my_event_data)); memset(data_array, 0, sizeof(data_array)); firstfail=-1; for (x=0;x<69;x++) { my_event_data[x].data_array=data_array[x]; rc=TraceEvent(_NTO_TRACE_ADDEVENTHANDLER,(x>45)?_NTO_TRACE_THREAD:_NTO_TRACE_KERCALLENTER,events[x], event_handler, &my_event_data[x]); if ((rc==-1) &&(firstfail==-1)) firstfail=x; } exit(0); } rc=waitpid(child, &x, 0); assert(rc==child); child=fork(); assert(child!=-1); /* Make a request to proc to generate a bit of activity */ if (child==0) { exit(0); } rc=waitpid(child, &x, 0); assert(rc==child); testpntpass("OK"); testpntend(); /***********************************************************************/ /* If the tracelogger was running when we started, we should restart it again */ if (tlkilled==1) system("reopen /dev/null ; tracelogger -n 0 -f /dev/null &"); teststop(argv[0]); return 0; }
int mainprog(void) { Sint4 frame,t,x; loadscores(); escape=false; do { soundstop(); creatembspr(); detectjoy(); gclear(); gtitle(); outtext("D I G G E R",100,0,3); shownplayers(); showtable(); started=false; frame=0; newframe(); teststart(); while (!started) { started=teststart(); if ((akeypressed==27 || akeypressed=='n' || akeypressed=='N') && !gauntlet && diggers==1) { switchnplayers(); shownplayers(); akeypressed=0; } if (frame==0) for (t=54;t<174;t+=12) outtext(" ",164,t,0); if (frame==50) { movedrawspr(FIRSTMONSTER,292,63); x=292; } if (frame>50 && frame<=77) { x-=4; drawmon(0,1,DIR_LEFT,x,63); } if (frame>77) drawmon(0,1,DIR_RIGHT,184,63); if (frame==83) outtext("NOBBIN",216,64,2); if (frame==90) { movedrawspr(FIRSTMONSTER+1,292,82); drawmon(1,0,DIR_LEFT,292,82); x=292; } if (frame>90 && frame<=117) { x-=4; drawmon(1,0,DIR_LEFT,x,82); } if (frame>117) drawmon(1,0,DIR_RIGHT,184,82); if (frame==123) outtext("HOBBIN",216,83,2); if (frame==130) { movedrawspr(FIRSTDIGGER,292,101); drawdigger(0,DIR_LEFT,292,101,1); x=292; } if (frame>130 && frame<=157) { x-=4; drawdigger(0,DIR_LEFT,x,101,1); } if (frame>157) drawdigger(0,DIR_RIGHT,184,101,1); if (frame==163) outtext("DIGGER",216,102,2); if (frame==178) { movedrawspr(FIRSTBAG,184,120); drawgold(0,0,184,120); } if (frame==183) outtext("GOLD",216,121,2); if (frame==198) drawemerald(184,141); if (frame==203) outtext("EMERALD",216,140,2); if (frame==218) drawbonus(184,158); if (frame==223) outtext("BONUS",216,159,2); newframe(); frame++; if (frame>250) frame=0; } if (savedrf) { if (gotgame) { recsavedrf(); gotgame=false; } savedrf=false; continue; } if (escape) break; recinit(); game(); gotgame=true; if (gotname) { recsavedrf(); gotgame=false; } savedrf=false; escape=false; } while (!escape); finish(); return 0; }