00001
00007
00008
00009 #include <kernel.h>
00010 #include <proc.h>
00011 #include <xc.h>
00012
00013 #define NTESTS 9
00014
00015 local testItem(ushort, ushort, ushort, ushort);
00016 extern int test_bigargs(int, char **);
00017 extern int test_schedule(int, char **);
00018 extern int test_recursion(int, char **);
00019 extern int test_semaphore(int, char **);
00020 extern int test_semaphore2(int, char **);
00021 extern int test_semaphore3(int, char **);
00022 extern int test_semaphore4(int, char **);
00023 extern int test_procQueue(int, char **);
00024 extern int test_deltaQueue(int, char **);
00025
00035 command xsh_testsuite(ushort stdin, ushort stdout, ushort stderr,
00036 ushort nargs, char *args[])
00037 {
00038 char n;
00039 int testnum;
00040
00041
00042 if (nargs == 2 && strncmp(args[1],"--help",6) == 0)
00043 {
00044 fprintf(stdout, "Usage: testsuite TESTNUM\n");
00045 fprintf(stdout, "Suite of standard XINU component tests.\n");
00046 fprintf(stdout, "0. Argument passing\n");
00047 fprintf(stdout, "1. Priority Scheduling\n");
00048 fprintf(stdout, "2. Recursion\n");
00049 fprintf(stdout, "3. Single Semaphore\n");
00050 fprintf(stdout, "4. Multiple Semaphores\n");
00051 fprintf(stdout, "5. Counting Semaphores\n");
00052 fprintf(stdout, "6. Killing Semaphores\n");
00053 fprintf(stdout, "7. Process Queues\n");
00054 fprintf(stdout, "8. Delta Queues\n");
00055
00056 fprintf(stdout, "\t--help\t display this help and exit\n");
00057 return OK;
00058 }
00059
00060
00061 if (nargs < 2)
00062 {
00063 for ( n = 0; n < NTESTS; n++ )
00064 { testItem( stdin, stdout, stderr, n ); }
00065
00066 return OK;
00067 }
00068
00069 if (nargs > 2)
00070 {
00071 fprintf(stderr, "testsuite: too many arguments\n");
00072 fprintf(stderr, "Try 'testsuite --help' for more information\n");
00073 return SYSERR;
00074 }
00075
00076
00077 testnum = (ushort)atol(args[1]);
00078 if ( testnum >= NTESTS )
00079 {
00080 fprintf(stderr, "testsuite: (%d) No such test.\n", testnum);
00081 return SYSERR;
00082 }
00083
00084 testItem( stdin, stdout, stderr, testnum );
00085
00086 return OK;
00087 }
00088
00089 local testItem(ushort stdin, ushort stdout, ushort stderr, ushort testnum)
00090 {
00091 irqmask ps;
00092
00093 ps = disable();
00094
00095 switch(testnum)
00096 {
00097 case 0:
00098 ready(create((void *)test_bigargs, INITSTK, 30,
00099 "Test-BigArgs", 2, 0, NULL), RESCHED_YES);
00100 break;
00101 case 1:
00102 ready(create((void *)test_schedule, INITSTK, 30,
00103 "Test-Schedule", 2, 0, NULL), RESCHED_YES);
00104 break;
00105 case 2:
00106 ready(create((void *)test_recursion, INITSTK, 30,
00107 "Test-Recursion", 2, 0, NULL), RESCHED_YES);
00108 break;
00109 case 3:
00110 ready(create((void *)test_semaphore, INITSTK, 30,
00111 "Test-Semaphore", 2, 0, NULL), RESCHED_YES);
00112 break;
00113 case 4:
00114 ready(create((void *)test_semaphore2, INITSTK, 30,
00115 "Test-Semaphores", 2, 0, NULL), RESCHED_YES);
00116 break;
00117 case 5:
00118 ready(create((void *)test_semaphore3, INITSTK, 30,
00119 "Test-CountingSems", 2, 0, NULL), RESCHED_YES);
00120 break;
00121 case 6:
00122 ready(create((void *)test_semaphore4, INITSTK, 30,
00123 "Test-KillSem", 2, 0, NULL), RESCHED_YES);
00124 break;
00125 case 7:
00126 ready(create((void *)test_procQueue, INITSTK, 30,
00127 "Test-ProcQueue", 2, 0, NULL), RESCHED_YES);
00128 break;
00129 case 8:
00130 ready(create((void *)test_deltaQueue, INITSTK, 30,
00131 "Test-DeltaQueue", 2, 0, NULL), RESCHED_YES);
00132 break;
00133
00134 default:
00135 fprintf(stderr, "testsuite: (%d) No such test.\n", testnum);
00136 }
00137
00138 sleep(10);
00139 restore(ps);
00140 return OK;
00141 }