54
54
YELLOW
55
55
};
56
56
57
- static int bflag ; /* run bpf tests */
58
- static int kflag ; /* run kprobe tests */
57
+ static int noforkflag ; /* don't fork on each test */
58
+ static int bflag ; /* run bpf tests */
59
+ static int kflag ; /* run kprobe tests */
59
60
60
61
static int
61
62
fancy_tty (void )
@@ -266,7 +267,7 @@ usage(void)
266
267
{
267
268
fprintf (stderr , "usage: %s -h\n" ,
268
269
program_invocation_short_name );
269
- fprintf (stderr , "usage: %s [-bkv ] [-x test] [tests ...]\n" ,
270
+ fprintf (stderr , "usage: %s [-1bkv ] [-x test] [tests ...]\n" ,
270
271
program_invocation_short_name );
271
272
fprintf (stderr , "usage: %s -l\n" ,
272
273
program_invocation_short_name );
@@ -1082,14 +1083,39 @@ lookup_test(const char *name)
1082
1083
return (NULL );
1083
1084
}
1084
1085
1086
+ static int
1087
+ run_test_doit (struct test * t , struct quark_queue_attr * qa )
1088
+ {
1089
+ int nfd , r ;
1090
+ struct quark_queue_attr qa_copy ;
1091
+
1092
+ /*
1093
+ * Check for FD leaks
1094
+ */
1095
+ nfd = num_open_fd ();
1096
+ assert (nfd == 3 );
1097
+ qa_copy = * qa ;
1098
+ r = t -> func (t , & qa_copy );
1099
+ nfd = num_open_fd ();
1100
+ if (nfd != 3 ) {
1101
+ fprintf (stderr ,
1102
+ "FDLEAK DETECTED! %d opened descriptors, expected 3\n" ,
1103
+ nfd );
1104
+ dump_open_fd (stderr );
1105
+ if (r == 0 )
1106
+ r = 1 ;
1107
+ }
1108
+
1109
+ return (r );
1110
+ }
1085
1111
/*
1086
1112
* A test runs as a subprocess to avoid contamination.
1087
1113
*/
1088
1114
static int
1089
1115
run_test (struct test * t , struct quark_queue_attr * qa )
1090
1116
{
1091
1117
pid_t child ;
1092
- int status , x , linepos , be , nfd , r ;
1118
+ int status , x , linepos , be , r ;
1093
1119
int child_stderr [2 ];
1094
1120
FILE * child_stream ;
1095
1121
char * child_buf ;
@@ -1119,6 +1145,22 @@ run_test(struct test *t, struct quark_queue_attr *qa)
1119
1145
return (0 );
1120
1146
}
1121
1147
1148
+ if (noforkflag ) {
1149
+ r = run_test_doit (t , qa );
1150
+ if (r == 0 ) {
1151
+ x = color (GREEN );
1152
+ printf ("ok\n" );
1153
+ color (x );
1154
+ } else {
1155
+ x = color (RED );
1156
+ printf ("failed\n" );
1157
+ color (x );
1158
+ }
1159
+ fflush (stdout );
1160
+
1161
+ return (r );
1162
+ }
1163
+
1122
1164
/*
1123
1165
* Create a pipe to save the child stderr, so we don't get crappy
1124
1166
* interleaved output with the parent.
@@ -1136,22 +1178,7 @@ run_test(struct test *t, struct quark_queue_attr *qa)
1136
1178
close (child_stderr [1 ]);
1137
1179
close (child_stderr [0 ]);
1138
1180
1139
- /*
1140
- * Check for FD leaks
1141
- */
1142
- nfd = num_open_fd ();
1143
- assert (nfd == 3 );
1144
- r = t -> func (t , qa );
1145
- nfd = num_open_fd ();
1146
- if (nfd != 3 ) {
1147
- fprintf (stderr ,
1148
- "FDLEAK DETECTED! %d opened descriptors, expected 3\n" ,
1149
- nfd );
1150
- dump_open_fd (stderr );
1151
- if (r == 0 )
1152
- r = 1 ;
1153
- }
1154
- exit (r );
1181
+ exit (run_test_doit (t , qa ));
1155
1182
}
1156
1183
close (child_stderr [1 ]);
1157
1184
@@ -1292,8 +1319,11 @@ main(int argc, char *argv[])
1292
1319
int ch , failed , x ;
1293
1320
struct test * t ;
1294
1321
1295
- while ((ch = getopt (argc , argv , "bhklNvVx :" )) != -1 ) {
1322
+ while ((ch = getopt (argc , argv , "1bhklNvVx :" )) != -1 ) {
1296
1323
switch (ch ) {
1324
+ case '1' :
1325
+ noforkflag = 1 ;
1326
+ break ;
1297
1327
case 'b' :
1298
1328
bflag = 1 ;
1299
1329
break ;
0 commit comments