... | ... |
@@ -592,7 +592,7 @@ wk_sbufacquire(wk *paramweb) |
592 | 592 |
} |
593 | 593 |
|
594 | 594 |
int |
595 |
-wk_bufrelease(wk *paramweb, int sbufid) |
|
595 |
+wk_sbufrelease(wk *paramweb, int sbufid) |
|
596 | 596 |
{ |
597 | 597 |
sbuf *buf; |
598 | 598 |
int numblock,j,bit; |
... | ... |
@@ -612,7 +612,7 @@ wk_bufrelease(wk *paramweb, int sbufid) |
612 | 612 |
} |
613 | 613 |
|
614 | 614 |
sbuf * |
615 |
-wk_bufget(wk *paramweb, int sbufid) |
|
615 |
+wk_sbufget(wk *paramweb, int sbufid) |
|
616 | 616 |
{ |
617 | 617 |
int numblock,j,bit; |
618 | 618 |
_wk *web=(_wk *)paramweb; |
71 | 71 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,83 @@ |
1 |
+/* |
|
2 |
+ * webkernel_test.c |
|
3 |
+ * |
|
4 |
+ * Tests to stress the webkernel API. |
|
5 |
+ * |
|
6 |
+ * Author: Dario Rodriguez dario@softhome.net |
|
7 |
+ * This program is dual licensed: MIT and in "the public domain". |
|
8 |
+ */ |
|
9 |
+ |
|
10 |
+ |
|
11 |
+#include <stdio.h> |
|
12 |
+#include <stdlib.h> |
|
13 |
+#include <unistd.h> |
|
14 |
+#include <string.h> |
|
15 |
+#include "sbuf.h" |
|
16 |
+#include "socklib.h" |
|
17 |
+#include "webkernel.h" |
|
18 |
+ |
|
19 |
+#define STRING_OK "ok" |
|
20 |
+#define STRING_FAIL "fail" |
|
21 |
+#define STRING_SEP ":" |
|
22 |
+ |
|
23 |
+typedef enum test_action { |
|
24 |
+ test_name=0, |
|
25 |
+ test_description, |
|
26 |
+ test_run |
|
27 |
+} test_action; |
|
28 |
+ |
|
29 |
+char *test1(test_action action); |
|
30 |
+ |
|
31 |
+struct { |
|
32 |
+ char *(*test)(/* test_action action */); |
|
33 |
+} tests[]={{test1}}; |
|
34 |
+ |
|
35 |
+int |
|
36 |
+main(int argc, char *argv[]) |
|
37 |
+{ |
|
38 |
+ int i; |
|
39 |
+ int flagall; |
|
40 |
+ char *resstr; |
|
41 |
+ int total,totalfail; |
|
42 |
+ if(argc==1 || strcmp(argv[argc-1],"--help")==0 || argc!=2) { |
|
43 |
+ printf("Syntax:\n\t%s { --help | --list | test_name | all }\nNOTE: test_name is one of the tests listed in --list\n",argv[0]); |
|
44 |
+ return(0); |
|
45 |
+ } |
|
46 |
+ if(strcmp(argv[argc-1],"--list")==0) { |
|
47 |
+ for(i=0;i<(sizeof(tests)/sizeof(tests[0]));i++) |
|
48 |
+ printf("%s\n\t%s\n",tests[i].test(test_name),tests[i].test(test_description)); |
|
49 |
+ return(0); |
|
50 |
+ } |
|
51 |
+ flagall=(strcmp(argv[argc-1],"all")==0)?1:0; |
|
52 |
+ for(total=totalfail=0,i=0;i<(sizeof(tests)/sizeof(tests[0]));i++) { |
|
53 |
+ if(!flagall && strcmp(tests[i].test(test_name),argv[argc-1])!=0) |
|
54 |
+ continue; |
|
55 |
+ printf("%20s...",tests[i].test(test_name)); |
|
56 |
+ fflush(stdout); |
|
57 |
+ resstr=tests[i].test(test_run); |
|
58 |
+ total++; |
|
59 |
+ totalfail+=((memcmp(resstr,STRING_OK,strlen(STRING_OK))==0)?0:1); |
|
60 |
+ printf("%s\n",resstr); |
|
61 |
+ |
|
62 |
+ } |
|
63 |
+ if(!flagall && i>=(sizeof(tests)/sizeof(tests[0]))) { |
|
64 |
+ printf("ERROR: test not found\n"); |
|
65 |
+ return(1); |
|
66 |
+ } |
|
67 |
+ if(totalfail!=0) |
|
68 |
+ printf("Failed %i of %i tests.\n",totalfail,total); |
|
69 |
+ return((totalfail!=0)?1:0); |
|
70 |
+} |
|
71 |
+ |
|
72 |
+char * |
|
73 |
+test1(test_action action) |
|
74 |
+{ |
|
75 |
+ if(action==test_name) |
|
76 |
+ return("test1"); |
|
77 |
+ else if(action==test_description) |
|
78 |
+ return("test the testing framework"); |
|
79 |
+ /* run test */ |
|
80 |
+ return("ok"); |
|
81 |
+} |
|
82 |
+ |
|
83 |
+ |