1 /* $NetBSD: npftest.c,v 1.1 2012/04/14 21:57:29 rmind Exp $ */ 2 3 /* 4 * NPF testing framework. 5 * 6 * Public Domain. 7 */ 8 9 #include <stdio.h> 10 #include <stdlib.h> 11 #include <stdbool.h> 12 #include <unistd.h> 13 #include <assert.h> 14 15 #include <rump/rump.h> 16 17 #include "npftest.h" 18 19 static bool benchmark, verbose, quiet; 20 21 static void 22 usage(void) 23 { 24 printf("%s: [ -b ] [ -v ]\n", getprogname()); 25 exit(EXIT_SUCCESS); 26 } 27 28 static void 29 result(const char *test, bool ok) 30 { 31 if (!quiet) { 32 printf("NPF %-10s\t%s\n", test, ok ? "OK" : "fail"); 33 } 34 if (verbose) { 35 puts("-----"); 36 } 37 if (!ok) { 38 exit(EXIT_FAILURE); 39 } 40 } 41 42 int 43 main(int argc, char **argv) 44 { 45 bool ok; 46 int ch; 47 48 benchmark = false; 49 verbose = false; 50 quiet = false; 51 52 while ((ch = getopt(argc, argv, "bqv")) != -1) { 53 switch (ch) { 54 case 'b': 55 benchmark = true; 56 break; 57 case 'q': 58 quiet = true; 59 break; 60 case 'v': 61 verbose = true; 62 break; 63 default: 64 usage(); 65 } 66 } 67 68 /* XXX rn_init */ 69 extern int rumpns_max_keylen; 70 rumpns_max_keylen = 1; 71 72 rump_init(); 73 rump_schedule(); 74 75 ok = rumpns_npf_nbuf_test(verbose); 76 result("nbuf", ok); 77 78 ok = rumpns_npf_processor_test(verbose); 79 result("processor", ok); 80 81 ok = rumpns_npf_table_test(verbose); 82 result("table", ok); 83 84 rump_unschedule(); 85 86 return EXIT_SUCCESS; 87 } 88