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