mbuf: remove rte_ctrlmbuf
[dpdk.git] / app / test / test_eal_flags.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   Copyright(c) 2014 6WIND S.A.
6  *   All rights reserved.
7  *
8  *   Redistribution and use in source and binary forms, with or without
9  *   modification, are permitted provided that the following conditions
10  *   are met:
11  *
12  *     * Redistributions of source code must retain the above copyright
13  *       notice, this list of conditions and the following disclaimer.
14  *     * Redistributions in binary form must reproduce the above copyright
15  *       notice, this list of conditions and the following disclaimer in
16  *       the documentation and/or other materials provided with the
17  *       distribution.
18  *     * Neither the name of Intel Corporation nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 #include <stdio.h>
35
36 #include "test.h"
37
38 #include <string.h>
39 #include <stdarg.h>
40 #include <libgen.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <errno.h>
44 #include <unistd.h>
45 #include <dirent.h>
46 #include <sys/wait.h>
47 #include <sys/file.h>
48 #include <limits.h>
49
50 #include <rte_debug.h>
51 #include <rte_string_fns.h>
52
53 #include "process.h"
54
55 #define mp_flag "--proc-type=secondary"
56 #define no_hpet "--no-hpet"
57 #define no_huge "--no-huge"
58 #define no_shconf "--no-shconf"
59 #define pci_whitelist "--pci-whitelist"
60 #define vdev "--vdev"
61 #define memtest "memtest"
62 #define memtest1 "memtest1"
63 #define memtest2 "memtest2"
64 #define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10)
65 #define launch_proc(ARGV) process_dup(ARGV, \
66                 sizeof(ARGV)/(sizeof(ARGV[0])), __func__)
67
68 enum hugepage_action {
69         HUGEPAGE_CHECK_EXISTS = 0,
70         HUGEPAGE_CHECK_LOCKED,
71         HUGEPAGE_DELETE,
72         HUGEPAGE_INVALID
73 };
74
75 /* if string contains a hugepage path */
76 static int
77 get_hugepage_path(char * src, int src_len, char * dst, int dst_len)
78 {
79 #define NUM_TOKENS 4
80         char *tokens[NUM_TOKENS];
81
82         /* if we couldn't properly split the string */
83         if (rte_strsplit(src, src_len, tokens, NUM_TOKENS, ' ') < NUM_TOKENS)
84                 return 0;
85
86         if (strncmp(tokens[2], "hugetlbfs", sizeof("hugetlbfs")) == 0) {
87                 snprintf(dst, dst_len, "%s", tokens[1]);
88                 return 1;
89         }
90         return 0;
91 }
92
93 /*
94  * Cycles through hugepage directories and looks for hugepage
95  * files associated with a given prefix. Depending on value of
96  * action, the hugepages are checked if they exist, checked if
97  * they can be locked, or are simply deleted.
98  *
99  * Returns 1 if it finds at least one hugepage matching the action
100  * Returns 0 if no matching hugepages were found
101  * Returns -1 if it encounters an error
102  */
103 static int
104 process_hugefiles(const char * prefix, enum hugepage_action action)
105 {
106         FILE * hugedir_handle = NULL;
107         DIR * hugepage_dir = NULL;
108         struct dirent *dirent = NULL;
109
110         char hugefile_prefix[PATH_MAX] = {0};
111         char hugedir[PATH_MAX] = {0};
112         char line[PATH_MAX] = {0};
113
114         int fd, lck_result, result = 0;
115
116         const int prefix_len = snprintf(hugefile_prefix,
117                         sizeof(hugefile_prefix), "%smap_", prefix);
118         if (prefix_len <= 0 || prefix_len >= (int)sizeof(hugefile_prefix)
119                         || prefix_len >= (int)sizeof(dirent->d_name)) {
120                 printf("Error creating hugefile filename prefix\n");
121                 return -1;
122         }
123
124         /* get hugetlbfs mountpoints from /proc/mounts */
125         hugedir_handle = fopen("/proc/mounts", "r");
126
127         if (hugedir_handle == NULL) {
128                 printf("Error parsing /proc/mounts!\n");
129                 return -1;
130         }
131
132         /* read and parse script output */
133         while (fgets(line, sizeof(line), hugedir_handle) != NULL) {
134
135                 /* check if we have a hugepage filesystem path */
136                 if (!get_hugepage_path(line, sizeof(line), hugedir, sizeof(hugedir)))
137                         continue;
138
139                 /* check if directory exists */
140                 if ((hugepage_dir = opendir(hugedir)) == NULL) {
141                         fclose(hugedir_handle);
142                         printf("Error reading %s: %s\n", hugedir, strerror(errno));
143                         return -1;
144                 }
145
146                 while ((dirent = readdir(hugepage_dir)) != NULL) {
147                         if (memcmp(dirent->d_name, hugefile_prefix, prefix_len) != 0)
148                                 continue;
149
150                         switch (action) {
151                         case HUGEPAGE_CHECK_EXISTS:
152                                 {
153                                         /* file exists, return */
154                                         result = 1;
155                                         goto end;
156                                 }
157                                 break;
158                         case HUGEPAGE_DELETE:
159                                 {
160                                         char file_path[PATH_MAX] = {0};
161
162                                         snprintf(file_path, sizeof(file_path),
163                                                 "%s/%s", hugedir, dirent->d_name);
164
165                                         /* remove file */
166                                         if (remove(file_path) < 0) {
167                                                 printf("Error deleting %s - %s!\n",
168                                                                 dirent->d_name, strerror(errno));
169                                                 closedir(hugepage_dir);
170                                                 result = -1;
171                                                 goto end;
172                                         }
173                                         result = 1;
174                                 }
175                                 break;
176                         case HUGEPAGE_CHECK_LOCKED:
177                                 {
178                                         /* try and lock the file */
179                                         fd = openat(dirfd(hugepage_dir), dirent->d_name, O_RDONLY);
180
181                                         /* this shouldn't happen */
182                                         if (fd == -1) {
183                                                 printf("Error opening %s - %s!\n",
184                                                                 dirent->d_name, strerror(errno));
185                                                 closedir(hugepage_dir);
186                                                 result = -1;
187                                                 goto end;
188                                         }
189
190                                         /* non-blocking lock */
191                                         lck_result = flock(fd, LOCK_EX | LOCK_NB);
192
193                                         /* if lock succeeds, there's something wrong */
194                                         if (lck_result != -1) {
195                                                 result = 0;
196
197                                                 /* unlock the resulting lock */
198                                                 flock(fd, LOCK_UN);
199                                                 close(fd);
200                                                 closedir(hugepage_dir);
201                                                 goto end;
202                                         }
203                                         result = 1;
204                                         close(fd);
205                                 }
206                                 break;
207                                 /* shouldn't happen */
208                         default:
209                                 goto end;
210                         } /* switch */
211
212                 } /* read hugepage directory */
213                 closedir(hugepage_dir);
214         } /* read /proc/mounts */
215 end:
216         fclose(hugedir_handle);
217         return result;
218 }
219
220 #ifdef RTE_EXEC_ENV_LINUXAPP
221 /*
222  * count the number of "node*" files in /sys/devices/system/node/
223  */
224 static int
225 get_number_of_sockets(void)
226 {
227         struct dirent *dirent = NULL;
228         const char * nodedir = "/sys/devices/system/node/";
229         DIR * dir = NULL;
230         int result = 0;
231
232         /* check if directory exists */
233         if ((dir = opendir(nodedir)) == NULL) {
234                 /* if errno==ENOENT this means we don't have NUMA support */
235                 if (errno == ENOENT) {
236                         printf("No NUMA nodes detected: assuming 1 available socket\n");
237                         return 1;
238                 }
239                 printf("Error opening %s: %s\n", nodedir, strerror(errno));
240                 return -1;
241         }
242
243         while ((dirent = readdir(dir)) != NULL)
244                 if (strncmp(dirent->d_name, "node", sizeof("node") - 1) == 0)
245                         result++;
246
247         closedir(dir);
248         return result;
249 }
250 #endif
251
252 static char*
253 get_current_prefix(char * prefix, int size)
254 {
255         char path[PATH_MAX] = {0};
256         char buf[PATH_MAX] = {0};
257
258         /* get file for config (fd is always 3) */
259         snprintf(path, sizeof(path), "/proc/self/fd/%d", 3);
260
261         /* return NULL on error */
262         if (readlink(path, buf, sizeof(buf)) == -1)
263                 return NULL;
264
265         /* get the basename */
266         snprintf(buf, sizeof(buf), "%s", basename(buf));
267
268         /* copy string all the way from second char up to start of _config */
269         snprintf(prefix, size, "%.*s",
270                         (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")),
271                         &buf[1]);
272
273         return prefix;
274 }
275
276 /*
277  * Test that the app doesn't run with invalid whitelist option.
278  * Final tests ensures it does run with valid options as sanity check (one
279  * test for with Domain+BDF, second for just with BDF)
280  */
281 static int
282 test_whitelist_flag(void)
283 {
284         unsigned i;
285 #ifdef RTE_EXEC_ENV_BSDAPP
286         /* BSD target doesn't support prefixes at this point */
287         const char * prefix = "";
288 #else
289         char prefix[PATH_MAX], tmp[PATH_MAX];
290         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
291                 printf("Error - unable to get current prefix!\n");
292                 return -1;
293         }
294         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
295 #endif
296
297         const char *wlinval[][11] = {
298                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
299                                 pci_whitelist, "error", "", ""},
300                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
301                                 pci_whitelist, "0:0:0", "", ""},
302                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
303                                 pci_whitelist, "0:error:0.1", "", ""},
304                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
305                                 pci_whitelist, "0:0:0.1error", "", ""},
306                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
307                                 pci_whitelist, "error0:0:0.1", "", ""},
308                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
309                                 pci_whitelist, "0:0:0.1.2", "", ""},
310         };
311         /* Test with valid whitelist option */
312         const char *wlval1[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
313                         pci_whitelist, "00FF:09:0B.3"};
314         const char *wlval2[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
315                         pci_whitelist, "09:0B.3", pci_whitelist, "0a:0b.1"};
316         const char *wlval3[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
317                         pci_whitelist, "09:0B.3,type=test",
318                         pci_whitelist, "08:00.1,type=normal",
319         };
320
321         for (i = 0; i < sizeof(wlinval) / sizeof(wlinval[0]); i++) {
322                 if (launch_proc(wlinval[i]) == 0) {
323                         printf("Error - process did run ok with invalid "
324                             "whitelist parameter\n");
325                         return -1;
326                 }
327         }
328         if (launch_proc(wlval1) != 0 ) {
329                 printf("Error - process did not run ok with valid whitelist\n");
330                 return -1;
331         }
332         if (launch_proc(wlval2) != 0 ) {
333                 printf("Error - process did not run ok with valid whitelist value set\n");
334                 return -1;
335         }
336         if (launch_proc(wlval3) != 0 ) {
337                 printf("Error - process did not run ok with valid whitelist + args\n");
338                 return -1;
339         }
340
341         return 0;
342 }
343
344 /*
345  * Test that the app doesn't run with invalid blacklist option.
346  * Final test ensures it does run with valid options as sanity check
347  */
348 static int
349 test_invalid_b_flag(void)
350 {
351 #ifdef RTE_EXEC_ENV_BSDAPP
352         /* BSD target doesn't support prefixes at this point */
353         const char * prefix = "";
354 #else
355         char prefix[PATH_MAX], tmp[PATH_MAX];
356         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
357                 printf("Error - unable to get current prefix!\n");
358                 return -1;
359         }
360         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
361 #endif
362
363         const char *blinval[][9] = {
364                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "error"},
365                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "0:0:0"},
366                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "0:error:0.1"},
367                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "0:0:0.1error"},
368                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "error0:0:0.1"},
369                 {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "0:0:0.1.2"},
370         };
371         /* Test with valid blacklist option */
372         const char *blval[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-b", "FF:09:0B.3"};
373
374         int i;
375
376         for (i = 0; i != sizeof (blinval) / sizeof (blinval[0]); i++) {
377                 if (launch_proc(blinval[i]) == 0) {
378                         printf("Error - process did run ok with invalid "
379                             "blacklist parameter\n");
380                         return -1;
381                 }
382         }
383         if (launch_proc(blval) != 0) {
384                 printf("Error - process did not run ok with valid blacklist value\n");
385                 return -1;
386         }
387         return 0;
388 }
389
390 /*
391  *  Test that the app doesn't run with invalid vdev option.
392  *  Final test ensures it does run with valid options as sanity check
393  */
394 #ifdef RTE_LIBRTE_PMD_RING
395 static int
396 test_invalid_vdev_flag(void)
397 {
398         /* Test with invalid vdev option */
399         const char *vdevinval[] = {prgname, "--file-prefix=vdev","-n", "1",
400                                 "-c", "1", vdev, "eth_dummy"};
401
402         /* Test with valid vdev option */
403         const char *vdevval1[] = {prgname, "--file-prefix=vdev", "-n", "1",
404         "-c", "1", vdev, "eth_ring0"};
405
406         const char *vdevval2[] = {prgname, "--file-prefix=vdev", "-n", "1",
407         "-c", "1", vdev, "eth_ring0,args=test"};
408
409         const char *vdevval3[] = {prgname, "--file-prefix=vdev", "-n", "1",
410         "-c", "1", vdev, "eth_ring0,nodeaction=r1:0:CREATE"};
411
412         if (launch_proc(vdevinval) == 0) {
413                 printf("Error - process did run ok with invalid "
414                         "vdev parameter\n");
415                 return -1;
416         }
417
418         if (launch_proc(vdevval1) != 0) {
419                 printf("Error - process did not run ok with valid vdev value\n");
420                 return -1;
421         }
422
423         if (launch_proc(vdevval2) != 0) {
424                 printf("Error - process did not run ok with valid vdev value,"
425                         "with dummy args\n");
426                 return -1;
427         }
428
429         if (launch_proc(vdevval3) != 0) {
430                 printf("Error - process did not run ok with valid vdev value,"
431                         "with valid args\n");
432                 return -1;
433         }
434         return 0;
435 }
436 #endif
437
438 /*
439  * Test that the app doesn't run with invalid -r option.
440  */
441 static int
442 test_invalid_r_flag(void)
443 {
444 #ifdef RTE_EXEC_ENV_BSDAPP
445         /* BSD target doesn't support prefixes at this point */
446         const char * prefix = "";
447 #else
448         char prefix[PATH_MAX], tmp[PATH_MAX];
449         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
450                 printf("Error - unable to get current prefix!\n");
451                 return -1;
452         }
453         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
454 #endif
455
456         const char *rinval[][9] = {
457                         {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-r", "error"},
458                         {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-r", "0"},
459                         {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-r", "-1"},
460                         {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-r", "17"},
461         };
462         /* Test with valid blacklist option */
463         const char *rval[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1", "-r", "16"};
464
465         int i;
466
467         for (i = 0; i != sizeof (rinval) / sizeof (rinval[0]); i++) {
468                 if (launch_proc(rinval[i]) == 0) {
469                         printf("Error - process did run ok with invalid "
470                             "-r (rank) parameter\n");
471                         return -1;
472                 }
473         }
474         if (launch_proc(rval) != 0) {
475                 printf("Error - process did not run ok with valid -r (rank) value\n");
476                 return -1;
477         }
478         return 0;
479 }
480
481 /*
482  * Test that the app doesn't run without the coremask flag. In all cases
483  * should give an error and fail to run
484  */
485 static int
486 test_missing_c_flag(void)
487 {
488 #ifdef RTE_EXEC_ENV_BSDAPP
489         /* BSD target doesn't support prefixes at this point */
490         const char * prefix = "";
491 #else
492         char prefix[PATH_MAX], tmp[PATH_MAX];
493         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
494                 printf("Error - unable to get current prefix!\n");
495                 return -1;
496         }
497         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
498 #endif
499
500         /* -c flag but no coremask value */
501         const char *argv1[] = { prgname, prefix, mp_flag, "-n", "3", "-c"};
502         /* No -c flag at all */
503         const char *argv2[] = { prgname, prefix, mp_flag, "-n", "3"};
504         /* bad coremask value */
505         const char *argv3[] = { prgname, prefix, mp_flag, "-n", "3", "-c", "error" };
506         /* sanity check of tests - valid coremask value */
507         const char *argv4[] = { prgname, prefix, mp_flag, "-n", "3", "-c", "1" };
508
509         if (launch_proc(argv1) == 0
510                         || launch_proc(argv2) == 0
511                         || launch_proc(argv3) == 0) {
512                 printf("Error - process ran without error when missing -c flag\n");
513                 return -1;
514         }
515         if (launch_proc(argv4) != 0) {
516                 printf("Error - process did not run ok with valid coremask value\n");
517                 return -1;
518         }
519         return 0;
520 }
521
522 /*
523  * Test that the app doesn't run without the -n flag. In all cases
524  * should give an error and fail to run.
525  * Since -n is not compulsory for MP, we instead use --no-huge and --no-shconf
526  * flags.
527  */
528 static int
529 test_missing_n_flag(void)
530 {
531 #ifdef RTE_EXEC_ENV_BSDAPP
532         /* BSD target doesn't support prefixes at this point */
533         const char * prefix = "";
534 #else
535         char prefix[PATH_MAX], tmp[PATH_MAX];
536         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
537                 printf("Error - unable to get current prefix!\n");
538                 return -1;
539         }
540         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
541 #endif
542
543         /* -n flag but no value */
544         const char *argv1[] = { prgname, prefix, no_huge, no_shconf, "-c", "1", "-n"};
545         /* No -n flag at all */
546         const char *argv2[] = { prgname, prefix, no_huge, no_shconf, "-c", "1"};
547         /* bad numeric value */
548         const char *argv3[] = { prgname, prefix, no_huge, no_shconf, "-c", "1", "-n", "e" };
549         /* out-of-range value */
550         const char *argv4[] = { prgname, prefix, no_huge, no_shconf, "-c", "1", "-n", "9" };
551         /* sanity test - check with good value */
552         const char *argv5[] = { prgname, prefix, no_huge, no_shconf, "-c", "1", "-n", "2" };
553
554         if (launch_proc(argv1) == 0
555                         || launch_proc(argv2) == 0
556                         || launch_proc(argv3) == 0
557                         || launch_proc(argv4) == 0) {
558                 printf("Error - process ran without error when missing -n flag\n");
559                 return -1;
560         }
561         if (launch_proc(argv5) != 0) {
562                 printf("Error - process did not run ok with valid num-channel value\n");
563                 return -1;
564         }
565         return 0;
566 }
567
568 /*
569  * Test that the app runs with HPET, and without HPET
570  */
571 static int
572 test_no_hpet_flag(void)
573 {
574         char prefix[PATH_MAX], tmp[PATH_MAX];
575
576 #ifdef RTE_EXEC_ENV_BSDAPP
577         return 0;
578 #endif
579         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
580                 printf("Error - unable to get current prefix!\n");
581                 return -1;
582         }
583         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
584
585         /* With --no-hpet */
586         const char *argv1[] = {prgname, prefix, mp_flag, no_hpet, "-c", "1", "-n", "2"};
587         /* Without --no-hpet */
588         const char *argv2[] = {prgname, prefix, mp_flag, "-c", "1", "-n", "2"};
589
590         if (launch_proc(argv1) != 0) {
591                 printf("Error - process did not run ok with --no-hpet flag\n");
592                 return -1;
593         }
594         if (launch_proc(argv2) != 0) {
595                 printf("Error - process did not run ok without --no-hpet flag\n");
596                 return -1;
597         }
598         return 0;
599 }
600
601 /*
602  * Test that the app runs with --no-huge and doesn't run when either
603  * -m or --socket-mem are specified with --no-huge.
604  */
605 static int
606 test_no_huge_flag(void)
607 {
608 #ifdef RTE_EXEC_ENV_BSDAPP
609         /* BSD target doesn't support prefixes at this point, and we also need to
610          * run another primary process here */
611         const char * prefix = no_shconf;
612 #else
613         const char * prefix = "--file-prefix=nohuge";
614 #endif
615
616         /* With --no-huge */
617         const char *argv1[] = {prgname, prefix, no_huge, "-c", "1", "-n", "2"};
618         /* With --no-huge and -m */
619         const char *argv2[] = {prgname, prefix, no_huge, "-c", "1", "-n", "2", "-m", "2"};
620
621         /* With --no-huge and --socket-mem */
622         const char *argv3[] = {prgname, prefix, no_huge, "-c", "1", "-n", "2",
623                         "--socket-mem=2"};
624         /* With --no-huge, -m and --socket-mem */
625         const char *argv4[] = {prgname, prefix, no_huge, "-c", "1", "-n", "2",
626                         "-m", "2", "--socket-mem=2"};
627         if (launch_proc(argv1) != 0) {
628                 printf("Error - process did not run ok with --no-huge flag\n");
629                 return -1;
630         }
631         if (launch_proc(argv2) == 0) {
632                 printf("Error - process run ok with --no-huge and -m flags\n");
633                 return -1;
634         }
635 #ifdef RTE_EXEC_ENV_BSDAPP
636         /* BSD target does not support NUMA, hence no --socket-mem tests */
637         return 0;
638 #endif
639
640         if (launch_proc(argv3) == 0) {
641                 printf("Error - process run ok with --no-huge and --socket-mem "
642                                 "flags\n");
643                 return -1;
644         }
645         if (launch_proc(argv4) == 0) {
646                 printf("Error - process run ok with --no-huge, -m and "
647                                 "--socket-mem flags\n");
648                 return -1;
649         }
650         return 0;
651 }
652
653 #ifdef RTE_LIBRTE_XEN_DOM0
654 static int
655 test_dom0_misc_flags(void)
656 {
657         char prefix[PATH_MAX], tmp[PATH_MAX];
658
659         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
660                 printf("Error - unable to get current prefix!\n");
661                 return -1;
662         }
663         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
664
665         /* check that some general flags don't prevent things from working.
666          * All cases, apart from the first, app should run.
667          * No futher testing of output done.
668          */
669         /* sanity check - failure with invalid option */
670         const char *argv0[] = {prgname, prefix, mp_flag, "-c", "1", "--invalid-opt"};
671
672         /* With --no-pci */
673         const char *argv1[] = {prgname, prefix, mp_flag, "-c", "1", "--no-pci"};
674         /* With -v */
675         const char *argv2[] = {prgname, prefix, mp_flag, "-c", "1", "-v"};
676         /* With valid --syslog */
677         const char *argv3[] = {prgname, prefix, mp_flag, "-c", "1",
678                         "--syslog", "syslog"};
679         /* With empty --syslog (should fail) */
680         const char *argv4[] = {prgname, prefix, mp_flag, "-c", "1", "--syslog"};
681         /* With invalid --syslog */
682         const char *argv5[] = {prgname, prefix, mp_flag, "-c", "1", "--syslog", "error"};
683         /* With no-sh-conf */
684         const char *argv6[] = {prgname, "-c", "1", "-n", "2", "-m", "20",
685                         "--no-shconf", "--file-prefix=noshconf" };
686
687         if (launch_proc(argv0) == 0) {
688                 printf("Error - process ran ok with invalid flag\n");
689                 return -1;
690         }
691         if (launch_proc(argv1) != 0) {
692                 printf("Error - process did not run ok with --no-pci flag\n");
693                 return -1;
694         }
695         if (launch_proc(argv2) != 0) {
696                 printf("Error - process did not run ok with -v flag\n");
697                 return -1;
698         }
699         if (launch_proc(argv3) != 0) {
700                 printf("Error - process did not run ok with --syslog flag\n");
701                 return -1;
702         }
703         if (launch_proc(argv4) == 0) {
704                 printf("Error - process run ok with empty --syslog flag\n");
705                 return -1;
706         }
707         if (launch_proc(argv5) == 0) {
708                 printf("Error - process run ok with invalid --syslog flag\n");
709                 return -1;
710         }
711         if (launch_proc(argv6) != 0) {
712                 printf("Error - process did not run ok with --no-shconf flag\n");
713                 return -1;
714         }
715
716         return 0;
717 }
718 #else
719 static int
720 test_misc_flags(void)
721 {
722         char hugepath[PATH_MAX] = {0};
723 #ifdef RTE_EXEC_ENV_BSDAPP
724         /* BSD target doesn't support prefixes at this point */
725         const char * prefix = "";
726         const char * nosh_prefix = "";
727 #else
728         char prefix[PATH_MAX], tmp[PATH_MAX];
729         const char * nosh_prefix = "--file-prefix=noshconf";
730         FILE * hugedir_handle = NULL;
731         char line[PATH_MAX] = {0};
732         unsigned i, isempty = 1;
733         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
734                 printf("Error - unable to get current prefix!\n");
735                 return -1;
736         }
737         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
738
739         /*
740          * get first valid hugepage path
741          */
742
743         /* get hugetlbfs mountpoints from /proc/mounts */
744         hugedir_handle = fopen("/proc/mounts", "r");
745
746         if (hugedir_handle == NULL) {
747                 printf("Error opening /proc/mounts!\n");
748                 return -1;
749         }
750
751         /* read /proc/mounts */
752         while (fgets(line, sizeof(line), hugedir_handle) != NULL) {
753
754                 /* find first valid hugepath */
755                 if (get_hugepage_path(line, sizeof(line), hugepath, sizeof(hugepath)))
756                         break;
757         }
758
759         fclose(hugedir_handle);
760
761         /* check if path is not empty */
762         for (i = 0; i < sizeof(hugepath); i++)
763                 if (hugepath[i] != '\0')
764                         isempty = 0;
765
766         if (isempty) {
767                 printf("No mounted hugepage dir found!\n");
768                 return -1;
769         }
770 #endif
771
772
773         /* check that some general flags don't prevent things from working.
774          * All cases, apart from the first, app should run.
775          * No futher testing of output done.
776          */
777         /* sanity check - failure with invalid option */
778         const char *argv0[] = {prgname, prefix, mp_flag, "-c", "1", "--invalid-opt"};
779
780         /* With --no-pci */
781         const char *argv1[] = {prgname, prefix, mp_flag, "-c", "1", "--no-pci"};
782         /* With -v */
783         const char *argv2[] = {prgname, prefix, mp_flag, "-c", "1", "-v"};
784         /* With valid --syslog */
785         const char *argv3[] = {prgname, prefix, mp_flag, "-c", "1",
786                         "--syslog", "syslog"};
787         /* With empty --syslog (should fail) */
788         const char *argv4[] = {prgname, prefix, mp_flag, "-c", "1", "--syslog"};
789         /* With invalid --syslog */
790         const char *argv5[] = {prgname, prefix, mp_flag, "-c", "1", "--syslog", "error"};
791         /* With no-sh-conf */
792         const char *argv6[] = {prgname, "-c", "1", "-n", "2", "-m", "2",
793                         no_shconf, nosh_prefix };
794
795 #ifdef RTE_EXEC_ENV_BSDAPP
796         return 0;
797 #endif
798         /* With --huge-dir */
799         const char *argv7[] = {prgname, "-c", "1", "-n", "2", "-m", "2",
800                         "--file-prefix=hugedir", "--huge-dir", hugepath};
801         /* With empty --huge-dir (should fail) */
802         const char *argv8[] = {prgname, "-c", "1", "-n", "2", "-m", "2",
803                         "--file-prefix=hugedir", "--huge-dir"};
804         /* With invalid --huge-dir */
805         const char *argv9[] = {prgname, "-c", "1", "-n", "2", "-m", "2",
806                         "--file-prefix=hugedir", "--huge-dir", "invalid"};
807         /* Secondary process with invalid --huge-dir (should run as flag has no
808          * effect on secondary processes) */
809         const char *argv10[] = {prgname, prefix, mp_flag, "-c", "1", "--huge-dir", "invalid"};
810
811         /* try running with base-virtaddr param */
812         const char *argv11[] = {prgname, "--file-prefix=virtaddr",
813                         "-c", "1", "-n", "2", "--base-virtaddr=0x12345678"};
814
815         /* try running with --vfio-intr INTx flag */
816         const char *argv12[] = {prgname, "--file-prefix=intr",
817                         "-c", "1", "-n", "2", "--vfio-intr=legacy"};
818
819         /* try running with --vfio-intr MSI flag */
820         const char *argv13[] = {prgname, "--file-prefix=intr",
821                         "-c", "1", "-n", "2", "--vfio-intr=msi"};
822
823         /* try running with --vfio-intr MSI-X flag */
824         const char *argv14[] = {prgname, "--file-prefix=intr",
825                         "-c", "1", "-n", "2", "--vfio-intr=msix"};
826
827         /* try running with --vfio-intr invalid flag */
828         const char *argv15[] = {prgname, "--file-prefix=intr",
829                         "-c", "1", "-n", "2", "--vfio-intr=invalid"};
830
831
832         if (launch_proc(argv0) == 0) {
833                 printf("Error - process ran ok with invalid flag\n");
834                 return -1;
835         }
836         if (launch_proc(argv1) != 0) {
837                 printf("Error - process did not run ok with --no-pci flag\n");
838                 return -1;
839         }
840         if (launch_proc(argv2) != 0) {
841                 printf("Error - process did not run ok with -v flag\n");
842                 return -1;
843         }
844         if (launch_proc(argv3) != 0) {
845                 printf("Error - process did not run ok with --syslog flag\n");
846                 return -1;
847         }
848         if (launch_proc(argv4) == 0) {
849                 printf("Error - process run ok with empty --syslog flag\n");
850                 return -1;
851         }
852         if (launch_proc(argv5) == 0) {
853                 printf("Error - process run ok with invalid --syslog flag\n");
854                 return -1;
855         }
856         if (launch_proc(argv6) != 0) {
857                 printf("Error - process did not run ok with --no-shconf flag\n");
858                 return -1;
859         }
860 #ifdef RTE_EXEC_ENV_BSDAPP
861         return 0;
862 #endif
863         if (launch_proc(argv7) != 0) {
864                 printf("Error - process did not run ok with --huge-dir flag\n");
865                 return -1;
866         }
867         if (launch_proc(argv8) == 0) {
868                 printf("Error - process run ok with empty --huge-dir flag\n");
869                 return -1;
870         }
871         if (launch_proc(argv9) == 0) {
872                 printf("Error - process run ok with invalid --huge-dir flag\n");
873                 return -1;
874         }
875         if (launch_proc(argv10) != 0) {
876                 printf("Error - secondary process did not run ok with invalid --huge-dir flag\n");
877                 return -1;
878         }
879         if (launch_proc(argv11) != 0) {
880                 printf("Error - process did not run ok with --base-virtaddr parameter\n");
881                 return -1;
882         }
883         if (launch_proc(argv12) != 0) {
884                 printf("Error - process did not run ok with "
885                                 "--vfio-intr INTx parameter\n");
886                 return -1;
887         }
888         if (launch_proc(argv13) != 0) {
889                 printf("Error - process did not run ok with "
890                                 "--vfio-intr MSI parameter\n");
891                 return -1;
892         }
893         if (launch_proc(argv14) != 0) {
894                 printf("Error - process did not run ok with "
895                                 "--vfio-intr MSI-X parameter\n");
896                 return -1;
897         }
898         if (launch_proc(argv15) == 0) {
899                 printf("Error - process run ok with "
900                                 "--vfio-intr invalid parameter\n");
901                 return -1;
902         }
903         return 0;
904 }
905 #endif
906
907 static int
908 test_file_prefix(void)
909 {
910         /*
911          * 1. check if current process hugefiles are locked
912          * 2. try to run secondary process without a corresponding primary process
913          * (while failing to run, it will also remove any unused hugepage files)
914          * 3. check if current process hugefiles are still in place and are locked
915          * 4. run a primary process with memtest1 prefix
916          * 5. check if memtest1 hugefiles are created
917          * 6. run a primary process with memtest2 prefix
918          * 7. check that only memtest2 hugefiles are present in the hugedir
919          */
920
921 #ifdef RTE_EXEC_ENV_BSDAPP
922         return 0;
923 #endif
924
925         /* this should fail unless the test itself is run with "memtest" prefix */
926         const char *argv0[] = {prgname, mp_flag, "-c", "1", "-n", "2", "-m", "2",
927                         "--file-prefix=" memtest };
928
929         /* primary process with memtest1 */
930         const char *argv1[] = {prgname, "-c", "1", "-n", "2", "-m", "2",
931                                 "--file-prefix=" memtest1 };
932
933         /* primary process with memtest2 */
934         const char *argv2[] = {prgname, "-c", "1", "-n", "2", "-m", "2",
935                                 "--file-prefix=" memtest2 };
936
937         char prefix[32];
938         if (get_current_prefix(prefix, sizeof(prefix)) == NULL) {
939                 printf("Error - unable to get current prefix!\n");
940                 return -1;
941         }
942 #ifdef RTE_LIBRTE_XEN_DOM0
943         return 0;
944 #endif
945
946         /* check if files for current prefix are present */
947         if (process_hugefiles(prefix, HUGEPAGE_CHECK_EXISTS) != 1) {
948                 printf("Error - hugepage files for %s were not created!\n", prefix);
949                 return -1;
950         }
951
952         /* checks if files for current prefix are locked */
953         if (process_hugefiles(prefix, HUGEPAGE_CHECK_LOCKED) != 1) {
954                 printf("Error - hugepages for current process aren't locked!\n");
955                 return -1;
956         }
957
958         /* check if files for secondary process are present */
959         if (process_hugefiles(memtest, HUGEPAGE_CHECK_EXISTS) == 1) {
960                 /* check if they are not locked */
961                 if (process_hugefiles(memtest, HUGEPAGE_CHECK_LOCKED) == 1) {
962                         printf("Error - hugepages for current process are locked!\n");
963                         return -1;
964                 }
965                 /* they aren't locked, delete them */
966                 else {
967                         if (process_hugefiles(memtest, HUGEPAGE_DELETE) != 1) {
968                                 printf("Error - deleting hugepages failed!\n");
969                                 return -1;
970                         }
971                 }
972         }
973
974         if (launch_proc(argv0) == 0) {
975                 printf("Error - secondary process ran ok without primary process\n");
976                 return -1;
977         }
978
979         /* check if files for current prefix are present */
980         if (process_hugefiles(prefix, HUGEPAGE_CHECK_EXISTS) != 1) {
981                 printf("Error - hugepage files for %s were not created!\n", prefix);
982                 return -1;
983         }
984
985         /* checks if files for current prefix are locked */
986         if (process_hugefiles(prefix, HUGEPAGE_CHECK_LOCKED) != 1) {
987                 printf("Error - hugepages for current process aren't locked!\n");
988                 return -1;
989         }
990
991         if (launch_proc(argv1) != 0) {
992                 printf("Error - failed to run with --file-prefix=%s\n", memtest);
993                 return -1;
994         }
995
996         /* check if memtest1_map0 is present */
997         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 1) {
998                 printf("Error - hugepage files for %s were not created!\n", memtest1);
999                 return -1;
1000         }
1001
1002         if (launch_proc(argv2) != 0) {
1003                 printf("Error - failed to run with --file-prefix=%s\n", memtest2);
1004                 return -1;
1005         }
1006
1007         /* check if hugefiles for memtest2 are present */
1008         if (process_hugefiles(memtest2, HUGEPAGE_CHECK_EXISTS) != 1) {
1009                 printf("Error - hugepage files for %s were not created!\n", memtest2);
1010                 return -1;
1011         }
1012
1013         /* check if hugefiles for memtest1 are present */
1014         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 0) {
1015                 printf("Error - hugepage files for %s were not deleted!\n", memtest1);
1016                 return -1;
1017         }
1018
1019         return 0;
1020 }
1021
1022 /*
1023  * Tests for correct handling of -m and --socket-mem flags
1024  */
1025 static int
1026 test_memory_flags(void)
1027 {
1028         const char* mem_size = NULL;
1029 #ifdef RTE_EXEC_ENV_BSDAPP
1030         /* BSD target doesn't support prefixes at this point */
1031         const char * prefix = "";
1032 #else
1033         char prefix[PATH_MAX], tmp[PATH_MAX];
1034         if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
1035                 printf("Error - unable to get current prefix!\n");
1036                 return -1;
1037         }
1038         snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
1039 #endif
1040 #ifdef RTE_LIBRTE_XEN_DOM0
1041         mem_size = "30";
1042 #else
1043         mem_size = "2";
1044 #endif
1045
1046
1047         /* valid -m flag and mp flag */
1048         const char *argv0[] = {prgname, prefix, mp_flag, "-c", "10",
1049                         "-n", "2", "-m", mem_size};
1050
1051         /* valid -m flag */
1052         const char *argv1[] = {prgname, "-c", "10", "-n", "2",
1053                         "--file-prefix=" memtest, "-m", mem_size};
1054
1055         /* invalid (zero) --socket-mem flag */
1056         const char *argv2[] = {prgname, "-c", "10", "-n", "2",
1057                         "--file-prefix=" memtest, "--socket-mem=0,0,0,0"};
1058
1059         /* invalid (incomplete) --socket-mem flag */
1060         const char *argv3[] = {prgname, "-c", "10", "-n", "2",
1061                         "--file-prefix=" memtest, "--socket-mem=2,2,"};
1062
1063         /* invalid (mixed with invalid data) --socket-mem flag */
1064         const char *argv4[] = {prgname, "-c", "10", "-n", "2",
1065                         "--file-prefix=" memtest, "--socket-mem=2,2,Fred"};
1066
1067         /* invalid (with numeric value as last character) --socket-mem flag */
1068         const char *argv5[] = {prgname, "-c", "10", "-n", "2",
1069                         "--file-prefix=" memtest, "--socket-mem=2,2,Fred0"};
1070
1071         /* invalid (with empty socket) --socket-mem flag */
1072         const char *argv6[] = {prgname, "-c", "10", "-n", "2",
1073                         "--file-prefix=" memtest, "--socket-mem=2,,2"};
1074
1075         /* invalid (null) --socket-mem flag */
1076         const char *argv7[] = {prgname, "-c", "10", "-n", "2",
1077                         "--file-prefix=" memtest, "--socket-mem="};
1078
1079         /* valid --socket-mem specified together with -m flag */
1080         const char *argv8[] = {prgname, "-c", "10", "-n", "2",
1081                         "--file-prefix=" memtest, "-m", "2", "--socket-mem=2,2"};
1082
1083         /* construct an invalid socket mask with 2 megs on each socket plus
1084          * extra 2 megs on socket that doesn't exist on current system */
1085         char invalid_socket_mem[SOCKET_MEM_STRLEN];
1086         char buf[SOCKET_MEM_STRLEN];    /* to avoid copying string onto itself */
1087
1088 #ifdef RTE_EXEC_ENV_BSDAPP
1089         int i, num_sockets = 1;
1090 #else
1091         int i, num_sockets = get_number_of_sockets();
1092 #endif
1093
1094         if (num_sockets <= 0 || num_sockets > RTE_MAX_NUMA_NODES) {
1095                 printf("Error - cannot get number of sockets!\n");
1096                 return -1;
1097         }
1098
1099         snprintf(invalid_socket_mem, sizeof(invalid_socket_mem), "--socket-mem=");
1100
1101         /* add one extra socket */
1102         for (i = 0; i < num_sockets + 1; i++) {
1103                 snprintf(buf, sizeof(buf), "%s2", invalid_socket_mem);
1104                 snprintf(invalid_socket_mem, sizeof(invalid_socket_mem), "%s", buf);
1105
1106                 if (num_sockets + 1 - i > 1) {
1107                         snprintf(buf, sizeof(buf), "%s,", invalid_socket_mem);
1108                         snprintf(invalid_socket_mem, sizeof(invalid_socket_mem), "%s", buf);
1109                 }
1110         }
1111
1112         /* construct a valid socket mask with 2 megs on each existing socket */
1113         char valid_socket_mem[SOCKET_MEM_STRLEN];
1114
1115         snprintf(valid_socket_mem, sizeof(valid_socket_mem), "--socket-mem=");
1116
1117         /* add one extra socket */
1118         for (i = 0; i < num_sockets; i++) {
1119                 snprintf(buf, sizeof(buf), "%s2", valid_socket_mem);
1120                 snprintf(valid_socket_mem, sizeof(valid_socket_mem), "%s", buf);
1121
1122                 if (num_sockets - i > 1) {
1123                         snprintf(buf, sizeof(buf), "%s,", valid_socket_mem);
1124                         snprintf(valid_socket_mem, sizeof(valid_socket_mem), "%s", buf);
1125                 }
1126         }
1127
1128         /* invalid --socket-mem flag (with extra socket) */
1129         const char *argv9[] = {prgname, "-c", "10", "-n", "2",
1130                         "--file-prefix=" memtest, invalid_socket_mem};
1131
1132         /* valid --socket-mem flag */
1133         const char *argv10[] = {prgname, "-c", "10", "-n", "2",
1134                         "--file-prefix=" memtest, valid_socket_mem};
1135
1136         if (launch_proc(argv0) != 0) {
1137                 printf("Error - secondary process failed with valid -m flag !\n");
1138                 return -1;
1139         }
1140
1141 #ifdef RTE_EXEC_ENV_BSDAPP
1142         /* no other tests are applicable to BSD */
1143         return 0;
1144 #endif
1145
1146         if (launch_proc(argv1) != 0) {
1147                 printf("Error - process failed with valid -m flag!\n");
1148                 return -1;
1149         }
1150 #ifdef RTE_LIBRTE_XEN_DOM0
1151         return 0;
1152 #endif
1153         if (launch_proc(argv2) == 0) {
1154                 printf("Error - process run ok with invalid (zero) --socket-mem!\n");
1155                 return -1;
1156         }
1157
1158         if (launch_proc(argv3) == 0) {
1159                 printf("Error - process run ok with invalid "
1160                                 "(incomplete) --socket-mem!\n");
1161                 return -1;
1162         }
1163
1164         if (launch_proc(argv4) == 0) {
1165                 printf("Error - process run ok with invalid "
1166                                 "(mixed with invalid input) --socket-mem!\n");
1167                 return -1;
1168         }
1169
1170         if (launch_proc(argv5) == 0) {
1171                 printf("Error - process run ok with invalid "
1172                                 "(mixed with invalid input with a numeric value as "
1173                                 "last character) --socket-mem!\n");
1174                 return -1;
1175         }
1176
1177         if (launch_proc(argv6) == 0) {
1178                 printf("Error - process run ok with invalid "
1179                                 "(with empty socket) --socket-mem!\n");
1180                 return -1;
1181         }
1182
1183         if (launch_proc(argv7) == 0) {
1184                 printf("Error - process run ok with invalid (null) --socket-mem!\n");
1185                 return -1;
1186         }
1187
1188         if (launch_proc(argv8) == 0) {
1189                 printf("Error - process run ok with --socket-mem and -m specified!\n");
1190                 return -1;
1191         }
1192
1193         if (launch_proc(argv9) == 0) {
1194                 printf("Error - process run ok with extra socket in --socket-mem!\n");
1195                 return -1;
1196         }
1197
1198         if (launch_proc(argv10) != 0) {
1199                 printf("Error - process failed with valid --socket-mem!\n");
1200                 return -1;
1201         }
1202
1203         return 0;
1204 }
1205
1206 static int
1207 test_eal_flags(void)
1208 {
1209         int ret = 0;
1210
1211         ret = test_missing_c_flag();
1212         if (ret < 0) {
1213                 printf("Error in test_missing_c_flag()\n");
1214                 return ret;
1215         }
1216
1217         ret = test_missing_n_flag();
1218         if (ret < 0) {
1219                 printf("Error in test_missing_n_flag()\n");
1220                 return ret;
1221         }
1222
1223         ret = test_no_hpet_flag();
1224         if (ret < 0) {
1225                 printf("Error in test_no_hpet_flag()\n");
1226                 return ret;
1227         }
1228
1229         ret = test_no_huge_flag();
1230         if (ret < 0) {
1231                 printf("Error in test_no_huge_flag()\n");
1232                 return ret;
1233         }
1234
1235         ret = test_whitelist_flag();
1236         if (ret < 0) {
1237                 printf("Error in test_invalid_whitelist_flag()\n");
1238                 return ret;
1239         }
1240
1241         ret = test_invalid_b_flag();
1242         if (ret < 0) {
1243                 printf("Error in test_invalid_b_flag()\n");
1244                 return ret;
1245         }
1246
1247 #ifdef RTE_LIBRTE_PMD_RING
1248         ret = test_invalid_vdev_flag();
1249         if (ret < 0) {
1250                 printf("Error in test_invalid_vdev_flag()\n");
1251                 return ret;
1252         }
1253 #endif
1254         ret = test_invalid_r_flag();
1255         if (ret < 0) {
1256                 printf("Error in test_invalid_r_flag()\n");
1257                 return ret;
1258         }
1259
1260         ret = test_memory_flags();
1261         if (ret < 0) {
1262                 printf("Error in test_memory_flags()\n");
1263                 return ret;
1264         }
1265
1266         ret = test_file_prefix();
1267         if (ret < 0) {
1268                 printf("Error in test_file_prefix()\n");
1269                 return ret;
1270         }
1271
1272 #ifdef RTE_LIBRTE_XEN_DOM0
1273         ret = test_dom0_misc_flags();
1274 #else
1275         ret = test_misc_flags();
1276 #endif
1277         if (ret < 0) {
1278                 printf("Error in test_misc_flags()");
1279                 return ret;
1280         }
1281
1282         return ret;
1283 }
1284
1285 static struct test_command eal_flags_cmd = {
1286         .command = "eal_flags_autotest",
1287         .callback = test_eal_flags,
1288 };
1289 REGISTER_TEST_COMMAND(eal_flags_cmd);