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