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