LCOV - code coverage report
Current view: top level - app/test - test_eal_flags.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 363 514 70.6 %
Date: 2026-05-01 18:54:57 Functions: 27 27 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 195 394 49.5 %

           Branch data     Line data    Source code
       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                 :            : 
      13                 :            : #ifndef RTE_EXEC_ENV_LINUX
      14                 :            : static int
      15                 :            : test_missing_c_flag(void)
      16                 :            : {
      17                 :            :         printf("missing_c_flag only supported on Linux, skipping test\n");
      18                 :            :         return TEST_SKIPPED;
      19                 :            : }
      20                 :            : 
      21                 :            : static int
      22                 :            : test_main_lcore_flag(void)
      23                 :            : {
      24                 :            :         printf("main_lcore_flag only supported on Linux, skipping test\n");
      25                 :            :         return TEST_SKIPPED;
      26                 :            : }
      27                 :            : 
      28                 :            : static int
      29                 :            : test_invalid_n_flag(void)
      30                 :            : {
      31                 :            :         printf("invalid_n_flag only supported on Linux, skipping test\n");
      32                 :            :         return TEST_SKIPPED;
      33                 :            : }
      34                 :            : 
      35                 :            : static int
      36                 :            : test_no_hpet_flag(void)
      37                 :            : {
      38                 :            :         printf("no_hpet_flag only supported on Linux, skipping test\n");
      39                 :            :         return TEST_SKIPPED;
      40                 :            : }
      41                 :            : 
      42                 :            : static int
      43                 :            : test_no_huge_flag(void)
      44                 :            : {
      45                 :            :         printf("no_huge_flag only supported on Linux, skipping test\n");
      46                 :            :         return TEST_SKIPPED;
      47                 :            : }
      48                 :            : 
      49                 :            : static int
      50                 :            : test_allow_flag(void)
      51                 :            : {
      52                 :            :         printf("allow_flag only supported on Linux, skipping test\n");
      53                 :            :         return TEST_SKIPPED;
      54                 :            : }
      55                 :            : 
      56                 :            : static int
      57                 :            : test_invalid_b_flag(void)
      58                 :            : {
      59                 :            :         printf("invalid_b_flag only supported on Linux, skipping test\n");
      60                 :            :         return TEST_SKIPPED;
      61                 :            : }
      62                 :            : 
      63                 :            : static int
      64                 :            : test_invalid_vdev_flag(void)
      65                 :            : {
      66                 :            :         printf("invalid_vdev_flag only supported on Linux, skipping test\n");
      67                 :            :         return TEST_SKIPPED;
      68                 :            : }
      69                 :            : 
      70                 :            : static int
      71                 :            : test_invalid_r_flag(void)
      72                 :            : {
      73                 :            :         printf("invalid_r_flag only supported on Linux, skipping test\n");
      74                 :            :         return TEST_SKIPPED;
      75                 :            : }
      76                 :            : 
      77                 :            : static int
      78                 :            : test_memory_flags(void)
      79                 :            : {
      80                 :            :         printf("memory_flags only supported on Linux, skipping test\n");
      81                 :            :         return TEST_SKIPPED;
      82                 :            : }
      83                 :            : 
      84                 :            : static int
      85                 :            : test_file_prefix(void)
      86                 :            : {
      87                 :            :         printf("file_prefix only supported on Linux, skipping test\n");
      88                 :            :         return TEST_SKIPPED;
      89                 :            : }
      90                 :            : 
      91                 :            : static int
      92                 :            : test_misc_flags(void)
      93                 :            : {
      94                 :            :         printf("misc_flags only supported on Linux, skipping test\n");
      95                 :            :         return TEST_SKIPPED;
      96                 :            : }
      97                 :            : 
      98                 :            : #else
      99                 :            : 
     100                 :            : #include <libgen.h>
     101                 :            : #include <stdlib.h>
     102                 :            : #include <errno.h>
     103                 :            : #include <unistd.h>
     104                 :            : #include <dirent.h>
     105                 :            : #include <sys/file.h>
     106                 :            : #include <sys/stat.h>
     107                 :            : #include <sys/wait.h>
     108                 :            : #include <limits.h>
     109                 :            : #include <fcntl.h>
     110                 :            : 
     111                 :            : #include <rte_lcore.h>
     112                 :            : #include <rte_debug.h>
     113                 :            : #include <rte_string_fns.h>
     114                 :            : 
     115                 :            : #include "process.h"
     116                 :            : 
     117                 :            : #define DEFAULT_MEM_SIZE "18"
     118                 :            : #define mp_flag "--proc-type=secondary"
     119                 :            : #define no_hpet "--no-hpet"
     120                 :            : #define no_huge "--no-huge"
     121                 :            : #define no_shconf "--no-shconf"
     122                 :            : #define auto_probing "--auto-probing"
     123                 :            : #define no_auto_probing "--no-auto-probing"
     124                 :            : #define allow "--allow"
     125                 :            : #define vdev "--vdev"
     126                 :            : #define no_pci "--no-pci"
     127                 :            : #define eal_debug_logs "--log-level=lib.eal:debug"
     128                 :            : #define bus_debug_logs "--log-level=bus.*:debug"
     129                 :            : 
     130                 :            : #define FS_HUGETLB "hugetlbfs"
     131                 :            : 
     132                 :            : #define memtest "memtest"
     133                 :            : #define memtest1 "memtest1"
     134                 :            : #define memtest2 "memtest2"
     135                 :            : #define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 20)
     136                 :            : #define launch_proc(ARGV) process_dup(ARGV, RTE_DIM(ARGV), __func__)
     137                 :            : 
     138                 :            : #ifdef RTE_EXEC_ENV_LINUX
     139                 :            : #include <mntent.h>
     140                 :            : 
     141                 :            : enum hugepage_action {
     142                 :            :         HUGEPAGE_CHECK_EXISTS = 0,
     143                 :            :         HUGEPAGE_CHECK_LOCKED,
     144                 :            :         HUGEPAGE_DELETE,
     145                 :            :         HUGEPAGE_INVALID
     146                 :            : };
     147                 :            : 
     148                 :            : /*
     149                 :            :  * Cycles through hugepage directories and looks for hugepage
     150                 :            :  * files associated with a given prefix. Depending on value of
     151                 :            :  * action, the hugepages are checked if they exist, checked if
     152                 :            :  * they can be locked, or are simply deleted.
     153                 :            :  *
     154                 :            :  * Returns 1 if it finds at least one hugepage matching the action
     155                 :            :  * Returns 0 if no matching hugepages were found
     156                 :            :  * Returns -1 if it encounters an error
     157                 :            :  */
     158                 :            : static int
     159         [ -  + ]:         15 : process_hugefiles(const char *prefix, enum hugepage_action action)
     160                 :            : {
     161                 :            :         const struct mntent *entry;
     162                 :            :         char hugefile_prefix[PATH_MAX];
     163                 :            :         int result = 0;
     164                 :            : 
     165                 :            :         const int prefix_len = snprintf(hugefile_prefix, sizeof(hugefile_prefix), "%smap_", prefix);
     166         [ -  + ]:         15 :         if (prefix_len <= 0 || prefix_len >= NAME_MAX) {
     167                 :            :                 printf("Error (line %d) - cannot create hugefile filename prefix\n", __LINE__);
     168                 :          0 :                 return -1;
     169                 :            :         }
     170                 :            : 
     171                 :            :         /* get hugetlbfs mountpoints from /proc/mounts */
     172                 :         15 :         FILE *mounts = setmntent("/proc/mounts", "r");
     173         [ -  + ]:         15 :         if (mounts == NULL) {
     174                 :            :                 printf("Error (line %d) - cannot parse /proc/mounts!\n", __LINE__);
     175                 :          0 :                 return -1;
     176                 :            :         }
     177                 :            : 
     178                 :            :         /* foreach mountpoint */
     179         [ +  + ]:        220 :         while ((entry = getmntent(mounts)) != NULL) {
     180                 :            :                 DIR *hugepage_dir;
     181                 :            :                 struct dirent *dirent;
     182                 :            : 
     183                 :            :                 /* only want hugetlbfs filesystems */
     184         [ +  + ]:        210 :                 if (strcmp(entry->mnt_type, FS_HUGETLB) != 0)
     185                 :        195 :                         continue;
     186                 :            : 
     187                 :            :                 /* check if directory exists */
     188                 :         15 :                 hugepage_dir = opendir(entry->mnt_dir);
     189         [ -  + ]:         15 :                 if (hugepage_dir == NULL) {
     190                 :          0 :                         endmntent(mounts);
     191                 :          0 :                         printf("Error (line %d) - cannot open %s: %s\n",
     192                 :          0 :                                 __LINE__, entry->mnt_dir, strerror(errno));
     193                 :          0 :                         return -1;
     194                 :            :                 }
     195                 :            : 
     196         [ +  + ]:         73 :                 while ((dirent = readdir(hugepage_dir)) != NULL) {
     197         [ +  + ]:         63 :                         if (memcmp(dirent->d_name, hugefile_prefix, prefix_len) != 0)
     198                 :         47 :                                 continue;
     199                 :            : 
     200   [ +  +  +  - ]:         16 :                         switch (action) {
     201                 :          5 :                         case HUGEPAGE_CHECK_EXISTS:
     202                 :            :                                 {
     203                 :            :                                         /* file exists, return */
     204                 :            :                                         printf("Hugepage file %s/%s exists, matching prefix %s\n",
     205                 :          5 :                                                 entry->mnt_dir, dirent->d_name, hugefile_prefix);
     206                 :          5 :                                         closedir(hugepage_dir);
     207                 :            :                                         result = 1;
     208                 :          5 :                                         goto end;
     209                 :            :                                 }
     210                 :            :                                 break;
     211                 :          9 :                         case HUGEPAGE_DELETE:
     212                 :            :                                 {
     213                 :            :                                         char file_path[PATH_MAX];
     214                 :            : 
     215                 :            :                                         snprintf(file_path, sizeof(file_path),
     216                 :          9 :                                                 "%s/%s", entry->mnt_dir, dirent->d_name);
     217                 :            : 
     218                 :            :                                         /* remove file */
     219         [ -  + ]:          9 :                                         if (remove(file_path) < 0) {
     220                 :          0 :                                                 printf("Error (line %d) - cannot delete %s - %s!\n",
     221                 :          0 :                                                         __LINE__, dirent->d_name, strerror(errno));
     222                 :          0 :                                                 closedir(hugepage_dir);
     223                 :            :                                                 result = -1;
     224                 :          0 :                                                 goto end;
     225                 :            :                                         }
     226                 :            :                                         printf("Deleted hugepage file %s\n", file_path);
     227                 :            :                                         result = 1;
     228                 :            :                                 }
     229                 :          9 :                                 break;
     230                 :          2 :                         case HUGEPAGE_CHECK_LOCKED:
     231                 :            :                                 {
     232                 :            :                                         int fd;
     233                 :            : 
     234                 :            :                                         /* try and lock the file */
     235                 :          2 :                                         fd = openat(dirfd(hugepage_dir), dirent->d_name, O_RDONLY);
     236                 :            : 
     237                 :            :                                         /* this shouldn't happen */
     238         [ -  + ]:          2 :                                         if (fd == -1) {
     239                 :          0 :                                                 printf("Error (line %d) - cannot open %s - %s!\n",
     240                 :          0 :                                                         __LINE__, dirent->d_name, strerror(errno));
     241                 :          0 :                                                 closedir(hugepage_dir);
     242                 :            :                                                 result = -1;
     243                 :          0 :                                                 goto end;
     244                 :            :                                         }
     245                 :            : 
     246                 :            :                                         /* non-blocking lock */
     247         [ -  + ]:          2 :                                         if (flock(fd, LOCK_EX | LOCK_NB) != -1) {
     248                 :            :                                                 result = 0;
     249                 :            : 
     250                 :            :                                                 /* unlock the resulting lock */
     251                 :          0 :                                                 flock(fd, LOCK_UN);
     252                 :          0 :                                                 close(fd);
     253                 :          0 :                                                 closedir(hugepage_dir);
     254                 :          0 :                                                 goto end;
     255                 :            :                                         }
     256                 :            :                                         result = 1;
     257                 :            :                                         printf("Hugepage file %s/%s is locked\n",
     258                 :          2 :                                                 entry->mnt_dir, dirent->d_name);
     259                 :          2 :                                         close(fd);
     260                 :            :                                 }
     261                 :          2 :                                 break;
     262                 :            :                                 /* shouldn't happen */
     263                 :          0 :                         default:
     264                 :          0 :                                 goto end;
     265                 :            :                         } /* switch */
     266                 :            : 
     267                 :            :                 } /* read hugepage directory */
     268                 :         10 :                 closedir(hugepage_dir);
     269                 :            :         } /* read /proc/mounts */
     270                 :         10 : end:
     271                 :         15 :         endmntent(mounts);
     272                 :         15 :         return result;
     273                 :            : }
     274                 :            : 
     275                 :            : /*
     276                 :            :  * count the number of "node*" files in /sys/devices/system/node/
     277                 :            :  */
     278                 :            : static int
     279                 :          1 : get_number_of_sockets(void)
     280                 :            : {
     281                 :            :         struct dirent *dirent = NULL;
     282                 :            :         const char * nodedir = "/sys/devices/system/node/";
     283                 :            :         DIR * dir = NULL;
     284                 :            :         int result = 0;
     285                 :            : 
     286                 :            :         /* check if directory exists */
     287         [ -  + ]:          1 :         if ((dir = opendir(nodedir)) == NULL) {
     288                 :            :                 /* if errno==ENOENT this means we don't have NUMA support */
     289         [ #  # ]:          0 :                 if (errno == ENOENT) {
     290                 :            :                         printf("No NUMA nodes detected: assuming 1 available socket\n");
     291                 :          0 :                         return 1;
     292                 :            :                 }
     293                 :          0 :                 printf("Error (line %d) - cannot open %s: %s\n",
     294                 :            :                         __LINE__, nodedir, strerror(errno));
     295                 :          0 :                 return -1;
     296                 :            :         }
     297                 :            : 
     298         [ +  + ]:         13 :         while ((dirent = readdir(dir)) != NULL)
     299         [ +  + ]:         12 :                 if (strncmp(dirent->d_name, "node", sizeof("node") - 1) == 0)
     300                 :          2 :                         result++;
     301                 :            : 
     302                 :          1 :         closedir(dir);
     303                 :          1 :         return result;
     304                 :            : }
     305                 :            : #endif /* RTE_EXEC_ENV_LINUX */
     306                 :            : 
     307                 :            : /*
     308                 :            :  * Test that the app doesn't run with invalid allow option.
     309                 :            :  * Final tests ensures it does run with valid options as sanity check (one
     310                 :            :  * test for with Domain+BDF, second for just with BDF)
     311                 :            :  */
     312                 :            : static int
     313                 :          1 : test_allow_flag(void)
     314                 :            : {
     315                 :            :         unsigned int i;
     316                 :          1 :         const char *prefix = file_prefix_arg();
     317         [ +  - ]:          1 :         if (prefix == NULL)
     318                 :            :                 return -1;
     319                 :            : 
     320                 :          1 :         const char *wlinval[][8] = {
     321                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs,
     322                 :            :                                 allow, "error", "", ""},
     323                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs,
     324                 :            :                                 allow, "0:0:0", "", ""},
     325                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs,
     326                 :            :                                 allow, "0:error:0.1", "", ""},
     327                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs,
     328                 :            :                                 allow, "0:0:0.1error", "", ""},
     329                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs,
     330                 :            :                                 allow, "error0:0:0.1", "", ""},
     331                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs,
     332                 :            :                                 allow, "0:0:0.1.2", "", ""},
     333                 :            :         };
     334                 :            :         /* Test with valid allow option */
     335                 :          1 :         const char *wlval1[] = {prgname, prefix, mp_flag, eal_debug_logs,
     336                 :            :                         allow, "00FF:09:0B.3"};
     337                 :          1 :         const char *wlval2[] = {prgname, prefix, mp_flag, eal_debug_logs,
     338                 :            :                         allow, "09:0B.3", allow, "0a:0b.1"};
     339                 :          1 :         const char *wlval3[] = {prgname, prefix, mp_flag, eal_debug_logs,
     340                 :            :                         allow, "09:0B.3,type=test",
     341                 :            :                         allow, "08:00.1,type=normal",
     342                 :            :         };
     343                 :          1 :         const char *wlval4[] = {prgname, prefix, mp_flag, eal_debug_logs,
     344                 :            :                         no_auto_probing };
     345                 :          1 :         const char *wlval5[] = {prgname, prefix, mp_flag, eal_debug_logs,
     346                 :            :                         no_auto_probing, allow, "00FF:09:0B.3"};
     347                 :          1 :         const char *wlval6[] = {prgname, prefix, mp_flag, eal_debug_logs,
     348                 :            :                         auto_probing };
     349                 :          1 :         const char *wlval7[] = {prgname, prefix, mp_flag, eal_debug_logs,
     350                 :            :                         auto_probing, allow, "00FF:09:0B.3"};
     351                 :            : 
     352         [ +  + ]:          7 :         for (i = 0; i < RTE_DIM(wlinval); i++) {
     353         [ -  + ]:          6 :                 if (launch_proc(wlinval[i]) == 0) {
     354                 :            :                         printf("Error (line %d) - process did run ok with invalid allow parameter\n",
     355                 :            :                                 __LINE__);
     356                 :          0 :                         return -1;
     357                 :            :                 }
     358                 :            :         }
     359         [ -  + ]:          1 :         if (launch_proc(wlval1) != 0 ) {
     360                 :            :                 printf("Error (line %d) - process did not run ok with valid allow\n", __LINE__);
     361                 :          0 :                 return -1;
     362                 :            :         }
     363         [ -  + ]:          1 :         if (launch_proc(wlval2) != 0 ) {
     364                 :            :                 printf("Error (line %d) - process did not run ok with valid allow value set\n",
     365                 :            :                         __LINE__);
     366                 :          0 :                 return -1;
     367                 :            :         }
     368         [ -  + ]:          1 :         if (launch_proc(wlval3) != 0 ) {
     369                 :            :                 printf("Error (line %d) - process did not run ok with valid allow + args\n",
     370                 :            :                         __LINE__);
     371                 :          0 :                 return -1;
     372                 :            :         }
     373         [ -  + ]:          1 :         if (launch_proc(wlval4) != 0) {
     374                 :            :                 printf("Error (line %d) - process did not run ok with no-auto-probing\n",
     375                 :            :                         __LINE__);
     376                 :          0 :                 return -1;
     377                 :            :         }
     378         [ -  + ]:          1 :         if (launch_proc(wlval5) != 0) {
     379                 :            :                 printf("Error (line %d) - process did not run ok with no-auto-probing + allow\n",
     380                 :            :                         __LINE__);
     381                 :          0 :                 return -1;
     382                 :            :         }
     383         [ -  + ]:          1 :         if (launch_proc(wlval6) != 0) {
     384                 :            :                 printf("Error (line %d) - process did not run ok with auto-probing\n",
     385                 :            :                         __LINE__);
     386                 :          0 :                 return -1;
     387                 :            :         }
     388         [ -  + ]:          1 :         if (launch_proc(wlval7) != 0) {
     389                 :            :                 printf("Error (line %d) - process did not run ok with auto-probing + allow\n",
     390                 :            :                         __LINE__);
     391                 :          0 :                 return -1;
     392                 :            :         }
     393                 :            : 
     394                 :            :         return 0;
     395                 :            : }
     396                 :            : 
     397                 :            : /*
     398                 :            :  * Test that the app doesn't run with invalid blocklist option.
     399                 :            :  * Final test ensures it does run with valid options as sanity check
     400                 :            :  */
     401                 :            : static int
     402                 :          1 : test_invalid_b_flag(void)
     403                 :            : {
     404                 :          1 :         const char *prefix = file_prefix_arg();
     405         [ +  - ]:          1 :         if (prefix == NULL)
     406                 :            :                 return -1;
     407                 :            : 
     408                 :          1 :         const char *blinval[][6] = {
     409                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error"},
     410                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0"},
     411                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:error:0.1"},
     412                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1error"},
     413                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error0:0:0.1"},
     414                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1.2"},
     415                 :            :         };
     416                 :          1 :         const char *blinval_probing[] =
     417                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0.0", auto_probing};
     418                 :          1 :         const char *blinval_probing_inval[] =
     419                 :            :                 {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0.0", no_auto_probing};
     420                 :            : 
     421                 :            :         /* Test with valid blocklist option */
     422                 :          1 :         const char *blval[] = {prgname, prefix, mp_flag, eal_debug_logs,
     423                 :            :                                "-b", "FF:09:0B.3"};
     424                 :            : 
     425                 :            :         int i;
     426                 :            : 
     427         [ +  + ]:          7 :         for (i = 0; i != RTE_DIM(blinval); i++) {
     428         [ -  + ]:          6 :                 if (launch_proc(blinval[i]) == 0) {
     429                 :            :                         printf("Error (line %d) - process did run ok with invalid blocklist parameter\n",
     430                 :            :                                 __LINE__);
     431                 :          0 :                         return -1;
     432                 :            :                 }
     433                 :            :         }
     434         [ -  + ]:          1 :         if (launch_proc(blinval_probing) != 0) {
     435                 :            :                 printf("Error (line %d) - process did not run ok with blocklist and auto-probing\n",
     436                 :            :                         __LINE__);
     437                 :          0 :                 return -1;
     438                 :            :         }
     439         [ -  + ]:          1 :         if (launch_proc(blinval_probing_inval) == 0) {
     440                 :            :                 printf("Error (line %d) - process did run ok with blocklist and no-auto-probing\n",
     441                 :            :                         __LINE__);
     442                 :          0 :                 return -1;
     443                 :            :         }
     444         [ -  + ]:          1 :         if (launch_proc(blval) != 0) {
     445                 :            :                 printf("Error (line %d) - process did not run ok with valid blocklist value\n",
     446                 :            :                         __LINE__);
     447                 :          0 :                 return -1;
     448                 :            :         }
     449                 :            :         return 0;
     450                 :            : }
     451                 :            : 
     452                 :            : /*
     453                 :            :  *  Test that the app doesn't run with invalid vdev option.
     454                 :            :  *  Final test ensures it does run with valid options as sanity check
     455                 :            :  */
     456                 :            : static int
     457                 :          1 : test_invalid_vdev_flag(void)
     458                 :            : {
     459                 :            : #ifdef RTE_NET_RING
     460                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
     461                 :            :         /* BSD target doesn't support prefixes at this point, and we also need to
     462                 :            :          * run another primary process here */
     463                 :            :         const char * prefix = no_shconf;
     464                 :            : #else
     465                 :            :         const char * prefix = "--file-prefix=vdev";
     466                 :            : #endif /* !RTE_EXEC_ENV_FREEBSD */
     467                 :            : 
     468                 :            :         /* Test with invalid vdev option */
     469                 :          1 :         const char *vdevinval[] = {prgname, prefix, no_huge, eal_debug_logs,
     470                 :            :                                 bus_debug_logs, no_pci, vdev, "eth_dummy"};
     471                 :            : 
     472                 :            :         /* Test with valid vdev option */
     473                 :          1 :         const char *vdevval1[] = {prgname, prefix, no_huge, eal_debug_logs,
     474                 :            :                                 bus_debug_logs, no_pci, vdev, "net_ring0"};
     475                 :            : 
     476                 :          1 :         const char *vdevval2[] = {prgname, prefix, no_huge, eal_debug_logs,
     477                 :            :                                 bus_debug_logs, no_pci, vdev, "net_ring0,args=test"};
     478                 :            : 
     479                 :          1 :         const char *vdevval3[] = {prgname, prefix, no_huge, eal_debug_logs,
     480                 :            :                                 bus_debug_logs, no_pci, vdev, "net_ring0,nodeaction=r1:0:CREATE"};
     481                 :            : 
     482                 :          1 :         const char *vdevval4[] = {prgname, prefix, no_huge, eal_debug_logs,
     483                 :            :                                 bus_debug_logs, no_auto_probing, vdev, "net_ring0"};
     484                 :            : 
     485                 :          1 :         const char *vdevval5[] = {prgname, prefix, no_huge, eal_debug_logs,
     486                 :            :                                 bus_debug_logs, auto_probing, vdev, "net_ring0"};
     487                 :            : 
     488         [ -  + ]:          1 :         if (launch_proc(vdevinval) == 0) {
     489                 :            :                 printf("Error (line %d) - process did run ok with invalid vdev parameter\n",
     490                 :            :                         __LINE__);
     491                 :          0 :                 return -1;
     492                 :            :         }
     493                 :            : 
     494         [ -  + ]:          1 :         if (launch_proc(vdevval1) != 0) {
     495                 :            :                 printf("Error (line %d) - process did not run ok with valid vdev value\n",
     496                 :            :                         __LINE__);
     497                 :          0 :                 return -1;
     498                 :            :         }
     499                 :            : 
     500         [ -  + ]:          1 :         if (launch_proc(vdevval2) != 0) {
     501                 :            :                 printf("Error (line %d) - process did not run ok with valid vdev value with dummy args\n",
     502                 :            :                         __LINE__);
     503                 :          0 :                 return -1;
     504                 :            :         }
     505                 :            : 
     506         [ -  + ]:          1 :         if (launch_proc(vdevval3) != 0) {
     507                 :            :                 printf("Error (line %d) - process did not run ok with valid vdev value with valid args\n",
     508                 :            :                         __LINE__);
     509                 :          0 :                 return -1;
     510                 :            :         }
     511                 :            : 
     512         [ -  + ]:          1 :         if (launch_proc(vdevval4) != 0) {
     513                 :            :                 printf("Error (line %d) - process did not run ok with valid vdev value and no-auto-probing\n",
     514                 :            :                         __LINE__);
     515                 :          0 :                 return -1;
     516                 :            :         }
     517                 :            : 
     518         [ -  + ]:          1 :         if (launch_proc(vdevval5) != 0) {
     519                 :            :                 printf("Error (line %d) - process did not run ok with valid vdev value and auto-probing\n",
     520                 :            :                         __LINE__);
     521                 :          0 :                 return -1;
     522                 :            :         }
     523                 :            :         return 0;
     524                 :            : #else
     525                 :            :         return TEST_SKIPPED;
     526                 :            : #endif /* !RTE_NET_RING */
     527                 :            : }
     528                 :            : 
     529                 :            : /*
     530                 :            :  * Test that the app doesn't run with invalid -r option.
     531                 :            :  */
     532                 :            : static int
     533                 :          1 : test_invalid_r_flag(void)
     534                 :            : {
     535                 :          1 :         const char *prefix = file_prefix_arg();
     536         [ +  - ]:          1 :         if (prefix == NULL)
     537                 :            :                 return -1;
     538                 :            : 
     539                 :          1 :         const char *rinval[][6] = {
     540                 :            :                         {prgname, prefix, mp_flag, eal_debug_logs, "-r", "error"},
     541                 :            :                         {prgname, prefix, mp_flag, eal_debug_logs, "-r", "0"},
     542                 :            :                         {prgname, prefix, mp_flag, eal_debug_logs, "-r", "-1"},
     543                 :            :                         {prgname, prefix, mp_flag, eal_debug_logs, "-r", "17"},
     544                 :            :         };
     545                 :            :         /* Test with valid blocklist option */
     546                 :          1 :         const char *rval[] = {prgname, prefix, mp_flag, eal_debug_logs, "-r", "16"};
     547                 :            : 
     548                 :            :         int i;
     549                 :            : 
     550         [ +  + ]:          5 :         for (i = 0; i != RTE_DIM(rinval); i++) {
     551         [ -  + ]:          4 :                 if (launch_proc(rinval[i]) == 0) {
     552                 :            :                         printf("Error (line %d) - process did run ok with invalid -r (rank) parameter\n",
     553                 :            :                                 __LINE__);
     554                 :          0 :                         return -1;
     555                 :            :                 }
     556                 :            :         }
     557         [ -  + ]:          1 :         if (launch_proc(rval) != 0) {
     558                 :            :                 printf("Error (line %d) - process did not run ok with valid -r (rank) value\n",
     559                 :            :                         __LINE__);
     560                 :          0 :                 return -1;
     561                 :            :         }
     562                 :            :         return 0;
     563                 :            : }
     564                 :            : 
     565                 :            : /*
     566                 :            :  * Test that the app doesn't run without the coremask/corelist flags. In all cases
     567                 :            :  * should give an error and fail to run
     568                 :            :  */
     569                 :            : static int
     570                 :          1 : test_missing_c_flag(void)
     571                 :            : {
     572                 :          1 :         const char *prefix = file_prefix_arg();
     573         [ +  - ]:          1 :         if (prefix == NULL)
     574                 :            :                 return -1;
     575                 :            : 
     576                 :            :         /* -c flag but no coremask value */
     577                 :          1 :         const char *argv1[] = { prgname, prefix, mp_flag, eal_debug_logs, "-c"};
     578                 :            :         /* No -c, -l or --lcores flag at all */
     579                 :          1 :         const char *argv2[] = { prgname, prefix, mp_flag};
     580                 :            :         /* bad coremask value */
     581                 :          1 :         const char *argv3[] = { prgname, prefix, mp_flag, eal_debug_logs,
     582                 :            :                                 "-c", "error" };
     583                 :            :         /* sanity check of tests - valid coremask value */
     584                 :          1 :         const char *argv4[] = { prgname, prefix, mp_flag, eal_debug_logs,
     585                 :            :                                 "-c", "1" };
     586                 :            :         /* -l flag but no corelist value */
     587                 :          1 :         const char *argv5[] = { prgname, prefix, mp_flag, eal_debug_logs,
     588                 :            :                                 "-l"};
     589                 :          1 :         const char *argv6[] = { prgname, prefix, mp_flag, eal_debug_logs,
     590                 :            :                                 "-l", " " };
     591                 :            :         /* bad corelist values */
     592                 :          1 :         const char *argv7[] = { prgname, prefix, mp_flag, eal_debug_logs,
     593                 :            :                                 "-l", "error" };
     594                 :          1 :         const char *argv8[] = { prgname, prefix, mp_flag, eal_debug_logs,
     595                 :            :                                 "-l", "1-" };
     596                 :          1 :         const char *argv9[] = { prgname, prefix, mp_flag, eal_debug_logs,
     597                 :            :                                 "-l", "1," };
     598                 :          1 :         const char *argv10[] = { prgname, prefix, mp_flag, eal_debug_logs,
     599                 :            :                                  "-l", "1#2" };
     600                 :            :         /* core number is negative value */
     601                 :          1 :         const char * const argv11[] = { prgname, prefix, mp_flag, eal_debug_logs,
     602                 :            :                                 "-l", "-5" };
     603                 :          1 :         const char * const argv12[] = { prgname, prefix, mp_flag, eal_debug_logs,
     604                 :            :                                 "-l", "-5-7" };
     605                 :            :         /* core number is maximum value */
     606                 :          1 :         const char * const argv13[] = { prgname, prefix, mp_flag, eal_debug_logs,
     607                 :            :                                 "-l", RTE_STR(RTE_MAX_LCORE) };
     608                 :          1 :         const char * const argv14[] = { prgname, prefix, mp_flag, eal_debug_logs,
     609                 :            :                                 "-l", "1-"RTE_STR(RTE_MAX_LCORE) };
     610                 :            :         /* sanity check test - valid corelist value */
     611                 :          1 :         const char * const argv15[] = { prgname, prefix, mp_flag, eal_debug_logs,
     612                 :            :                                  "-l", "1-2,3" };
     613                 :            : 
     614                 :            :         /* --lcores flag but no lcores value */
     615                 :          1 :         const char * const argv16[] = { prgname, prefix, mp_flag, eal_debug_logs,
     616                 :            :                                  "--lcores" };
     617                 :          1 :         const char * const argv17[] = { prgname, prefix, mp_flag, eal_debug_logs,
     618                 :            :                                  "--lcores", " " };
     619                 :            :         /* bad lcores value */
     620                 :          1 :         const char * const argv18[] = { prgname, prefix, mp_flag, eal_debug_logs,
     621                 :            :                                  "--lcores", "1-3-5" };
     622                 :          1 :         const char * const argv19[] = { prgname, prefix, mp_flag, eal_debug_logs,
     623                 :            :                                  "--lcores", "0-1,,2" };
     624                 :          1 :         const char * const argv20[] = { prgname, prefix, mp_flag, eal_debug_logs,
     625                 :            :                                  "--lcores", "0-,1" };
     626                 :          1 :         const char * const argv21[] = { prgname, prefix, mp_flag, eal_debug_logs,
     627                 :            :                                  "--lcores", "(0-,2-4)" };
     628                 :          1 :         const char * const argv22[] = { prgname, prefix, mp_flag, eal_debug_logs,
     629                 :            :                                  "--lcores", "(-1,2)" };
     630                 :          1 :         const char * const argv23[] = { prgname, prefix, mp_flag, eal_debug_logs,
     631                 :            :                                  "--lcores", "(2-4)@(2-4-6)" };
     632                 :          1 :         const char * const argv24[] = { prgname, prefix, mp_flag, eal_debug_logs,
     633                 :            :                                  "--lcores", "(a,2)" };
     634                 :          1 :         const char * const argv25[] = { prgname, prefix, mp_flag, eal_debug_logs,
     635                 :            :                                  "--lcores", "1-3@(1,3)" };
     636                 :          1 :         const char * const argv26[] = { prgname, prefix, mp_flag, eal_debug_logs,
     637                 :            :                                  "--lcores", "3@((1,3)" };
     638                 :          1 :         const char * const argv27[] = { prgname, prefix, mp_flag, eal_debug_logs,
     639                 :            :                                  "--lcores", "(4-7)=(1,3)" };
     640                 :          1 :         const char * const argv28[] = { prgname, prefix, mp_flag, eal_debug_logs,
     641                 :            :                                  "--lcores", "[4-7]@(1,3)" };
     642                 :            :         /* sanity check of tests - valid lcores value */
     643                 :          1 :         const char * const argv29[] = { prgname, prefix, mp_flag, eal_debug_logs,
     644                 :            :                                  "--lcores",
     645                 :            :                                  "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
     646                 :            :         /* check an invalid cpu value >= CPU_SETSIZE */
     647                 :          1 :         const char * const argv30[] = { prgname, prefix, mp_flag, eal_debug_logs,
     648                 :            :                                  "--lcores", "3@" RTE_STR(CPU_SETSIZE) };
     649                 :            : 
     650         [ -  + ]:          1 :         if (launch_proc(argv2) != 0) {
     651                 :            :                 printf("Error (line %d) - process did not run ok when missing -c flag\n",
     652                 :            :                         __LINE__);
     653                 :          0 :                 return -1;
     654                 :            :         }
     655                 :            : 
     656         [ +  - ]:          1 :         if (launch_proc(argv1) == 0
     657         [ -  + ]:          1 :                         || launch_proc(argv3) == 0) {
     658                 :            :                 printf("Error (line %d) - process ran without error with invalid -c flag\n",
     659                 :            :                         __LINE__);
     660                 :          0 :                 return -1;
     661                 :            :         }
     662         [ -  + ]:          1 :         if (launch_proc(argv4) != 0) {
     663                 :            :                 printf("Error (line %d) - process did not run ok with valid coremask value\n",
     664                 :            :                         __LINE__);
     665                 :          0 :                 return -1;
     666                 :            :         }
     667                 :            : 
     668                 :            :         /* start -l test */
     669         [ +  - ]:          1 :         if (launch_proc(argv5) == 0
     670         [ +  - ]:          1 :                         || launch_proc(argv6) == 0
     671         [ +  - ]:          1 :                         || launch_proc(argv7) == 0
     672         [ +  - ]:          1 :                         || launch_proc(argv8) == 0
     673         [ +  - ]:          1 :                         || launch_proc(argv9) == 0
     674         [ +  - ]:          1 :                         || launch_proc(argv10) == 0
     675         [ +  - ]:          1 :                         || launch_proc(argv11) == 0
     676         [ +  - ]:          1 :                         || launch_proc(argv12) == 0
     677         [ +  - ]:          1 :                         || launch_proc(argv13) == 0
     678         [ -  + ]:          1 :                         || launch_proc(argv14) == 0) {
     679                 :            :                 printf("Error (line %d) - process ran without error with invalid -l flag\n",
     680                 :            :                         __LINE__);
     681                 :          0 :                 return -1;
     682                 :            :         }
     683   [ +  -  +  -  :          2 :         if (rte_lcore_is_enabled(0) && rte_lcore_is_enabled(1) &&
                   -  + ]
     684   [ -  -  -  - ]:          1 :             rte_lcore_is_enabled(2) && rte_lcore_is_enabled(3) &&
     685                 :          0 :             launch_proc(argv15) != 0) {
     686                 :            :                 printf("Error (line %d) - process did not run ok with valid corelist value\n",
     687                 :            :                         __LINE__);
     688                 :          0 :                 return -1;
     689                 :            :         }
     690                 :            : 
     691                 :            :         /* start --lcores tests */
     692   [ +  -  +  -  :          2 :         if (launch_proc(argv16) == 0 || launch_proc(argv17) == 0 ||
                   +  - ]
     693   [ +  -  +  - ]:          3 :             launch_proc(argv18) == 0 || launch_proc(argv19) == 0 ||
     694   [ +  -  +  - ]:          3 :             launch_proc(argv20) == 0 || launch_proc(argv21) == 0 ||
     695   [ +  -  +  - ]:          3 :             launch_proc(argv22) == 0 || launch_proc(argv23) == 0 ||
     696   [ +  -  +  - ]:          3 :             launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
     697   [ +  -  +  - ]:          3 :             launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
     698         [ -  + ]:          2 :             launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
     699                 :            :                 printf("Error (line %d) - process ran without error with invalid --lcores flag\n",
     700                 :            :                         __LINE__);
     701                 :          0 :                 return -1;
     702                 :            :         }
     703                 :            : 
     704   [ +  -  +  -  :          2 :         if (rte_lcore_is_enabled(0) && rte_lcore_is_enabled(1) &&
                   -  + ]
     705   [ -  -  -  - ]:          1 :             rte_lcore_is_enabled(2) && rte_lcore_is_enabled(3) &&
     706   [ #  #  #  # ]:          0 :             rte_lcore_is_enabled(4) && rte_lcore_is_enabled(5) &&
     707   [ #  #  #  # ]:          0 :             rte_lcore_is_enabled(6) && rte_lcore_is_enabled(7) &&
     708                 :          0 :             launch_proc(argv29) != 0) {
     709                 :            :                 printf("Error (line %d) - process did not run ok with valid corelist value\n",
     710                 :            :                         __LINE__);
     711                 :          0 :                 return -1;
     712                 :            :         }
     713                 :            : 
     714                 :            :         return 0;
     715                 :            : }
     716                 :            : 
     717                 :            : /*
     718                 :            :  * Test --main-lcore option with matching coremask
     719                 :            :  */
     720                 :            : static int
     721                 :          1 : test_main_lcore_flag(void)
     722                 :            : {
     723                 :          1 :         const char *prefix = file_prefix_arg();
     724         [ +  - ]:          1 :         if (prefix == NULL)
     725                 :            :                 return -1;
     726                 :            : 
     727   [ +  -  -  + ]:          1 :         if (!rte_lcore_is_enabled(0) || !rte_lcore_is_enabled(1))
     728                 :          0 :                 return TEST_SKIPPED;
     729                 :            : 
     730                 :            :         /* --main-lcore flag but no value */
     731                 :          1 :         const char *argv1[] = { prgname, prefix, mp_flag, eal_debug_logs,
     732                 :            :                                 "-c", "3", "--main-lcore"};
     733                 :            :         /* --main-lcore flag with invalid value */
     734                 :          1 :         const char *argv2[] = { prgname, prefix, mp_flag, eal_debug_logs,
     735                 :            :                                 "-c", "3", "--main-lcore", "-1"};
     736                 :          1 :         const char *argv3[] = { prgname, prefix, mp_flag, eal_debug_logs,
     737                 :            :                                 "-c", "3", "--main-lcore", "X"};
     738                 :            :         /* main lcore not in coremask */
     739                 :          1 :         const char *argv4[] = { prgname, prefix, mp_flag, eal_debug_logs,
     740                 :            :                                 "-c", "3", "--main-lcore", "2"};
     741                 :            :         /* valid value */
     742                 :          1 :         const char *argv5[] = { prgname, prefix, mp_flag, eal_debug_logs,
     743                 :            :                                 "-c", "3", "--main-lcore", "1"};
     744                 :            :         /* valid value set before coremask */
     745                 :          1 :         const char *argv6[] = { prgname, prefix, mp_flag, eal_debug_logs,
     746                 :            :                                 "--main-lcore", "1", "-c", "3"};
     747                 :            : 
     748         [ +  - ]:          1 :         if (launch_proc(argv1) == 0
     749         [ +  - ]:          1 :                         || launch_proc(argv2) == 0
     750         [ +  - ]:          1 :                         || launch_proc(argv3) == 0
     751         [ -  + ]:          1 :                         || launch_proc(argv4) == 0) {
     752                 :            :                 printf("Error (line %d) - process ran without error with wrong --main-lcore\n",
     753                 :            :                         __LINE__);
     754                 :          0 :                 return -1;
     755                 :            :         }
     756         [ +  - ]:          1 :         if (launch_proc(argv5) != 0
     757         [ -  + ]:          1 :                         || launch_proc(argv6) != 0) {
     758                 :            :                 printf("Error (line %d) - process did not run ok with valid --main-lcore\n",
     759                 :            :                         __LINE__);
     760                 :          0 :                 return -1;
     761                 :            :         }
     762                 :            :         return 0;
     763                 :            : }
     764                 :            : 
     765                 :            : /*
     766                 :            :  * Test that the app doesn't run with invalid -n flag option.
     767                 :            :  * Final test ensures it does run with valid options as sanity check
     768                 :            :  * Since -n is not compulsory for MP, we instead use --no-huge and --no-shconf
     769                 :            :  * flags.
     770                 :            :  */
     771                 :            : static int
     772                 :          1 : test_invalid_n_flag(void)
     773                 :            : {
     774                 :          1 :         const char *prefix = file_prefix_arg();
     775         [ +  - ]:          1 :         if (prefix == NULL)
     776                 :            :                 return -1;
     777                 :            : 
     778                 :            :         /* -n flag but no value */
     779                 :          1 :         const char *argv1[] = { prgname, prefix, no_huge, no_shconf,
     780                 :            :                                 "-n"};
     781                 :            :         /* bad numeric value */
     782                 :          1 :         const char *argv2[] = { prgname, prefix, no_huge, no_shconf,
     783                 :            :                                 "-n", "e" };
     784                 :            :         /* zero is invalid */
     785                 :          1 :         const char *argv3[] = { prgname, prefix, no_huge, no_shconf,
     786                 :            :                                 "-n", "0" };
     787                 :            :         /* sanity test - check with good value */
     788                 :          1 :         const char *argv4[] = { prgname, prefix, no_huge, no_shconf,
     789                 :            :                                 "-n", "2" };
     790                 :            :         /* sanity test - check with no -n flag */
     791                 :          1 :         const char *argv5[] = { prgname, prefix, no_huge, no_shconf};
     792                 :            : 
     793         [ +  - ]:          1 :         if (launch_proc(argv1) == 0
     794         [ +  - ]:          1 :                         || launch_proc(argv2) == 0
     795         [ -  + ]:          1 :                         || launch_proc(argv3) == 0) {
     796                 :            :                 printf("Error (line %d) - process ran without error when invalid -n flag\n",
     797                 :            :                         __LINE__);
     798                 :          0 :                 return -1;
     799                 :            :         }
     800         [ -  + ]:          1 :         if (launch_proc(argv4) != 0) {
     801                 :            :                 printf("Error (line %d) - process did not run ok with valid num-channel value\n",
     802                 :            :                         __LINE__);
     803                 :          0 :                 return -1;
     804                 :            :         }
     805         [ -  + ]:          1 :         if (launch_proc(argv5) != 0) {
     806                 :            :                 printf("Error (line %d) - process did not run ok without -n flag\n", __LINE__);
     807                 :          0 :                 return -1;
     808                 :            :         }
     809                 :            : 
     810                 :            :         return 0;
     811                 :            : }
     812                 :            : 
     813                 :            : /*
     814                 :            :  * Test that the app runs with HPET, and without HPET
     815                 :            :  */
     816                 :            : static int
     817                 :          1 : test_no_hpet_flag(void)
     818                 :            : {
     819                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
     820                 :            :         return 0;
     821                 :            : #else
     822                 :          1 :         const char *prefix = file_prefix_arg();
     823         [ -  + ]:          1 :         if (prefix == NULL) {
     824                 :            :                 printf("Error (line %d) - unable to get current prefix!\n", __LINE__);
     825                 :          0 :                 return -1;
     826                 :            :         }
     827                 :            : 
     828                 :            :         /* With --no-hpet */
     829                 :          1 :         const char *argv1[] = {prgname, prefix, mp_flag, eal_debug_logs, no_hpet};
     830                 :            :         /* Without --no-hpet */
     831                 :          1 :         const char *argv2[] = {prgname, prefix, mp_flag, eal_debug_logs};
     832                 :            : 
     833         [ -  + ]:          1 :         if (launch_proc(argv1) != 0) {
     834                 :            :                 printf("Error (line %d) - process did not run ok with --no-hpet flag\n", __LINE__);
     835                 :          0 :                 return -1;
     836                 :            :         }
     837         [ -  + ]:          1 :         if (launch_proc(argv2) != 0) {
     838                 :            :                 printf("Error (line %d) - process did not run ok without --no-hpet flag\n",
     839                 :            :                         __LINE__);
     840                 :          0 :                 return -1;
     841                 :            :         }
     842                 :            :         return 0;
     843                 :            : #endif
     844                 :            : }
     845                 :            : 
     846                 :            : /*
     847                 :            :  * Test that the app runs with --no-huge and doesn't run when --socket-mem are
     848                 :            :  * specified with --no-huge.
     849                 :            :  */
     850                 :            : static int
     851                 :          1 : test_no_huge_flag(void)
     852                 :            : {
     853                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
     854                 :            :         /* BSD target doesn't support prefixes at this point, and we also need to
     855                 :            :          * run another primary process here */
     856                 :            :         const char * prefix = no_shconf;
     857                 :            : #else
     858                 :            :         const char * prefix = "--file-prefix=nohuge";
     859                 :            : #endif
     860                 :            : 
     861                 :            :         /* With --no-huge */
     862                 :          1 :         const char *argv1[] = {prgname, prefix, no_huge};
     863                 :            :         /* With --no-huge and -m */
     864                 :          1 :         const char *argv2[] = {prgname, prefix, no_huge,
     865                 :            :                         "-m", DEFAULT_MEM_SIZE};
     866                 :            : 
     867         [ -  + ]:          1 :         if (launch_proc(argv1) != 0) {
     868                 :            :                 printf("Error - process did not run ok with --no-huge flag\n");
     869                 :          0 :                 return -1;
     870                 :            :         }
     871         [ -  + ]:          1 :         if (launch_proc(argv2) != 0) {
     872                 :            :                 printf("Error - process did not run ok with --no-huge and -m flags\n");
     873                 :          0 :                 return -1;
     874                 :            :         }
     875                 :            : #ifndef RTE_EXEC_ENV_FREEBSD
     876                 :            :         /* With --no-huge and --socket-mem */
     877                 :          1 :         const char *argv3[] = {prgname, prefix, no_huge,
     878                 :            :                         "--socket-mem=" DEFAULT_MEM_SIZE};
     879                 :            :         /* With --no-huge, -m and --socket-mem */
     880                 :          1 :         const char *argv4[] = {prgname, prefix, no_huge,
     881                 :            :                         "-m", DEFAULT_MEM_SIZE, "--socket-mem=" DEFAULT_MEM_SIZE};
     882                 :            : 
     883                 :            :         /* With --no-huge and --huge-worker-stack (should fail) */
     884                 :          1 :         const char * const argv5[] = {prgname, prefix, no_huge,
     885                 :            :                         "--huge-worker-stack"};
     886                 :            :         /* With --no-huge and --huge-worker-stack=512 (should fail) */
     887                 :          1 :         const char * const argv6[] = {prgname, prefix, no_huge,
     888                 :            :                         "--huge-worker-stack=512"};
     889                 :            : 
     890         [ -  + ]:          1 :         if (launch_proc(argv3) == 0) {
     891                 :            :                 printf("Error (line %d) - process run ok with --no-huge and --socket-mem flags\n",
     892                 :            :                         __LINE__);
     893                 :          0 :                 return -1;
     894                 :            :         }
     895         [ -  + ]:          1 :         if (launch_proc(argv4) == 0) {
     896                 :            :                 printf("Error (line %d) - process run ok with --no-huge, -m and --socket-mem flags\n",
     897                 :            :                         __LINE__);
     898                 :          0 :                 return -1;
     899                 :            :         }
     900         [ -  + ]:          1 :         if (launch_proc(argv5) == 0) {
     901                 :            :                 printf("Error (line %d) - process run ok with --no-huge and --huge-worker-stack flags\n",
     902                 :            :                         __LINE__);
     903                 :          0 :                 return -1;
     904                 :            :         }
     905         [ -  + ]:          1 :         if (launch_proc(argv6) == 0) {
     906                 :            :                 printf("Error (line %d) - process run ok with --no-huge and --huge-worker-stack=size flags\n",
     907                 :            :                         __LINE__);
     908                 :          0 :                 return -1;
     909                 :            :         }
     910                 :            : #endif /* !RTE_EXEC_ENV_FREEBSD */
     911                 :            :         return 0;
     912                 :            : }
     913                 :            : 
     914                 :            : static int
     915                 :          1 : test_misc_flags(void)
     916                 :            : {
     917                 :            :         const char *hugepath = "";
     918                 :            :         char hugepath_dir[PATH_MAX];
     919                 :            :         char hugepath_dir2[PATH_MAX];
     920                 :            :         char hugepath_dir3[PATH_MAX];
     921                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
     922                 :            :         /* BSD target doesn't support prefixes at this point */
     923                 :            :         const char * prefix = "";
     924                 :            :         const char * nosh_prefix = "";
     925                 :            : #else
     926                 :          1 :         const char *prefix = file_prefix_arg();
     927                 :            :         const char * nosh_prefix = "--file-prefix=noshconf";
     928                 :            :         struct mntent *entry;
     929                 :            : 
     930         [ -  + ]:          1 :         if (prefix == NULL) {
     931                 :            :                 printf("Error (line %d) - unable to get current prefix!\n", __LINE__);
     932                 :          0 :                 return -1;
     933                 :            :         }
     934                 :            : 
     935                 :            :         /*
     936                 :            :          * get first valid hugepage path
     937                 :            :          */
     938                 :            : 
     939                 :            :         /* get hugetlbfs mountpoints from /proc/mounts */
     940                 :          1 :         FILE *mounts = setmntent("/proc/mounts", "r");
     941         [ -  + ]:          1 :         if (mounts == NULL) {
     942                 :            :                 printf("Error (line %d) - cannot open /proc/mounts!\n", __LINE__);
     943                 :          0 :                 return -1;
     944                 :            :         }
     945                 :            : 
     946                 :            :         /* foreach mount point */
     947                 :            :         hugepath = NULL;
     948         [ +  - ]:         10 :         while ((entry = getmntent(mounts)) != NULL) {
     949                 :            :                 /* only want hugetlbfs filesystems */
     950         [ +  + ]:         10 :                 if (strcmp(entry->mnt_type, FS_HUGETLB) == 0) {
     951                 :          1 :                         hugepath = strdupa(entry->mnt_dir);
     952                 :          1 :                         break;
     953                 :            :                 }
     954                 :            :         }
     955                 :          1 :         endmntent(mounts);
     956                 :            : 
     957         [ -  + ]:          1 :         if (hugepath == NULL) {
     958                 :            :                 printf("No mounted hugepage dir found!\n");
     959                 :          0 :                 return -1;
     960                 :            :         }
     961                 :            : #endif
     962                 :            : 
     963                 :            :         snprintf(hugepath_dir, sizeof(hugepath_dir), "%s/dpdk.missing", hugepath);
     964                 :            :         snprintf(hugepath_dir2, sizeof(hugepath_dir2), "%s/dpdk.dir", hugepath);
     965                 :            : 
     966   [ -  +  -  - ]:          1 :         if (mkdir(hugepath_dir2, 0700) != 0 && errno != EEXIST) {
     967                 :            :                 printf("Error (line %d) - failed to mkdir(%s)\n", __LINE__, hugepath_dir2);
     968                 :          0 :                 return -1;
     969                 :            :         }
     970                 :            : 
     971                 :            :         snprintf(hugepath_dir3, sizeof(hugepath_dir3), "%s/dpdk.dir/sub", hugepath);
     972                 :            : 
     973   [ -  +  -  - ]:          1 :         if (mkdir(hugepath_dir3, 0700) != 0 && errno != EEXIST) {
     974                 :            :                 printf("Error (line %d) - failed to mkdir(%s)\n", __LINE__, hugepath_dir3);
     975                 :          0 :                 goto fail;
     976                 :            :         }
     977                 :            : 
     978                 :            :         /* check that some general flags don't prevent things from working.
     979                 :            :          * All cases, apart from the first, app should run.
     980                 :            :          * No further testing of output done.
     981                 :            :          */
     982                 :            :         /* sanity check - failure with invalid option */
     983                 :          1 :         const char *argv0[] = {prgname, prefix, mp_flag, eal_debug_logs, "--invalid-opt"};
     984                 :            : 
     985                 :            :         /* With --no-pci */
     986                 :          1 :         const char *argv1[] = {prgname, prefix, mp_flag, eal_debug_logs, "--no-pci"};
     987                 :            :         /* With -v */
     988                 :          1 :         const char *argv2[] = {prgname, prefix, mp_flag, eal_debug_logs, "-v"};
     989                 :            :         /* With valid --syslog */
     990                 :          1 :         const char *argv3[] = {prgname, prefix, mp_flag, eal_debug_logs, "--syslog=user"};
     991                 :            :         /* With empty --syslog (now defaults) */
     992                 :          1 :         const char *argv4[] = {prgname, prefix, mp_flag, eal_debug_logs, "--syslog"};
     993                 :            :         /* With invalid --syslog */
     994                 :          1 :         const char *argv5[] = {prgname, prefix, mp_flag, eal_debug_logs, "--syslog=invalid"};
     995                 :            : 
     996                 :            :         /* With no-sh-conf, also use no-huge to ensure this test runs on BSD */
     997                 :          1 :         const char *argv6[] = {prgname, eal_debug_logs, no_pci, "-m", DEFAULT_MEM_SIZE,
     998                 :            :                         no_shconf, nosh_prefix, no_huge};
     999                 :            : 
    1000                 :            :         /* With --huge-dir */
    1001                 :          1 :         const char *argv7[] = {prgname, "-m", DEFAULT_MEM_SIZE,
    1002                 :            :                         eal_debug_logs, no_pci,
    1003                 :            :                         "--file-prefix=hugedir", "--huge-dir", hugepath};
    1004                 :            :         /* With empty --huge-dir (should fail) */
    1005                 :          1 :         const char *argv8[] = {prgname, "-m", DEFAULT_MEM_SIZE,
    1006                 :            :                         eal_debug_logs, no_pci,
    1007                 :            :                         "--file-prefix=hugedir", "--huge-dir"};
    1008                 :            :         /* With invalid --huge-dir */
    1009                 :          1 :         const char *argv9[] = {prgname, "-m", DEFAULT_MEM_SIZE,
    1010                 :            :                         eal_debug_logs, no_pci,
    1011                 :            :                         "--file-prefix=hugedir", "--huge-dir", "invalid"};
    1012                 :            :         /* With invalid --huge-dir sub-directory */
    1013                 :          1 :         const char *argv10[] = {prgname, "-m", DEFAULT_MEM_SIZE,
    1014                 :            :                         eal_debug_logs, no_pci,
    1015                 :            :                         "--file-prefix=hugedir", "--huge-dir", hugepath_dir};
    1016                 :            :         /* With valid --huge-dir sub-directory */
    1017                 :          1 :         const char *argv11[] = {prgname, "-m", DEFAULT_MEM_SIZE,
    1018                 :            :                         eal_debug_logs, no_pci,
    1019                 :            :                         "--file-prefix=hugedir", "--huge-dir", hugepath_dir2};
    1020                 :            :         /* Secondary process with invalid --huge-dir (should run as flag has no
    1021                 :            :          * effect on secondary processes) */
    1022                 :          1 :         const char *argv12[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1023                 :            :                         "--huge-dir", "invalid"};
    1024                 :            : 
    1025                 :            :         /* try running with base-virtaddr param */
    1026                 :          1 :         const char *argv13[] = {prgname, "--file-prefix=virtaddr",
    1027                 :            :                         eal_debug_logs, no_pci,
    1028                 :            :                         "--base-virtaddr=0x23456789"};
    1029                 :            : 
    1030                 :            :         /* try running with --vfio-intr INTx flag */
    1031                 :          1 :         const char *argv14[] = {prgname, "--file-prefix=intr",
    1032                 :            :                         eal_debug_logs, no_pci,
    1033                 :            :                         "--vfio-intr=legacy"};
    1034                 :            : 
    1035                 :            :         /* try running with --vfio-intr MSI flag */
    1036                 :          1 :         const char *argv15[] = {prgname, "--file-prefix=intr",
    1037                 :            :                         eal_debug_logs, no_pci,
    1038                 :            :                         "--vfio-intr=msi"};
    1039                 :            : 
    1040                 :            :         /* try running with --vfio-intr MSI-X flag */
    1041                 :          1 :         const char *argv16[] = {prgname, "--file-prefix=intr",
    1042                 :            :                         eal_debug_logs, no_pci,
    1043                 :            :                         "--vfio-intr=msix"};
    1044                 :            : 
    1045                 :            :         /* try running with --vfio-intr invalid flag */
    1046                 :          1 :         const char *argv17[] = {prgname, "--file-prefix=intr",
    1047                 :            :                         eal_debug_logs, no_pci,
    1048                 :            :                         "--vfio-intr=invalid"};
    1049                 :            : 
    1050                 :            :         /* With process type as auto-detect */
    1051                 :          1 :         const char * const argv18[] = {prgname, "--file-prefix=auto",
    1052                 :            :                         eal_debug_logs, no_pci,
    1053                 :            :                         "--proc-type=auto"};
    1054                 :            : 
    1055                 :            :         /* With process type as auto-detect with no-shconf */
    1056                 :          1 :         const char * const argv19[] = {prgname, "--proc-type=auto", eal_debug_logs, no_pci,
    1057                 :            :                         no_shconf, nosh_prefix, no_huge};
    1058                 :            : 
    1059                 :            :         /* With process type as --create-uio-dev flag */
    1060                 :          1 :         const char * const argv20[] = {prgname, "--file-prefix=uiodev",
    1061                 :            :                         eal_debug_logs, no_pci,
    1062                 :            :                         "--create-uio-dev"};
    1063                 :            : 
    1064                 :            :         /* Try running with --huge-worker-stack flag */
    1065                 :          1 :         const char * const argv21[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1066                 :            :                                        "--huge-worker-stack"};
    1067                 :            : 
    1068                 :            :         /* Try running with --huge-worker-stack=512 flag */
    1069                 :          1 :         const char * const argv22[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1070                 :            :                                        "--huge-worker-stack=512"};
    1071                 :            : 
    1072                 :            :         /* Try running with --log-timestamp */
    1073                 :          1 :         const char * const argv23[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1074                 :            :                                        "--log-timestamp" };
    1075                 :            : 
    1076                 :            :         /* Try running with --log-timestamp=iso */
    1077                 :          1 :         const char * const argv24[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1078                 :            :                                        "--log-timestamp=iso" };
    1079                 :            : 
    1080                 :            :         /* Try running with invalid timestamp */
    1081                 :          1 :         const char * const argv25[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1082                 :            :                                        "--log-timestamp=invalid" };
    1083                 :            : 
    1084                 :            :         /* Try running with --log-color */
    1085                 :          1 :         const char * const argv26[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1086                 :            :                                        "--log-color" };
    1087                 :            : 
    1088                 :            :         /* Try running with --log-color=never */
    1089                 :          1 :         const char * const argv27[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1090                 :            :                                        "--log-color=never" };
    1091                 :            : 
    1092                 :            :         /* Try running with --log-color=invalid */
    1093                 :          1 :         const char * const argv28[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1094                 :            :                                        "--log-color=invalid" };
    1095                 :            : 
    1096                 :            :         /* run all tests also applicable to FreeBSD first */
    1097                 :            : 
    1098         [ -  + ]:          1 :         if (launch_proc(argv0) == 0) {
    1099                 :            :                 printf("Error (line %d) - process ran ok with invalid flag\n", __LINE__);
    1100                 :          0 :                 goto fail;
    1101                 :            :         }
    1102         [ -  + ]:          1 :         if (launch_proc(argv1) != 0) {
    1103                 :            :                 printf("Error (line %d) - process did not run ok with --no-pci flag\n", __LINE__);
    1104                 :          0 :                 goto fail;
    1105                 :            :         }
    1106         [ -  + ]:          1 :         if (launch_proc(argv2) != 0) {
    1107                 :            :                 printf("Error (line %d) - process did not run ok with -v flag\n", __LINE__);
    1108                 :          0 :                 goto fail;
    1109                 :            :         }
    1110         [ -  + ]:          1 :         if (launch_proc(argv6) != 0) {
    1111                 :            :                 printf("Error (line %d) - process did not run ok with --no-shconf flag\n",
    1112                 :            :                         __LINE__);
    1113                 :          0 :                 goto fail;
    1114                 :            :         }
    1115                 :            : 
    1116                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
    1117                 :            :         /* no more tests to be done on FreeBSD */
    1118                 :            :         return 0;
    1119                 :            : #endif
    1120                 :            : 
    1121         [ -  + ]:          1 :         if (launch_proc(argv3) != 0) {
    1122                 :            :                 printf("Error (line %d) - process did not run ok with --syslog=user flag\n",
    1123                 :            :                         __LINE__);
    1124                 :          0 :                 goto fail;
    1125                 :            :         }
    1126         [ -  + ]:          1 :         if (launch_proc(argv4) != 0) {
    1127                 :            :                 printf("Error (line %d) - process did not run ok with --syslog flag\n", __LINE__);
    1128                 :          0 :                 goto fail;
    1129                 :            :         }
    1130         [ -  + ]:          1 :         if (launch_proc(argv5) == 0) {
    1131                 :            :                 printf("Error (line %d) - process run ok with --syslog=invalid flag\n", __LINE__);
    1132                 :          0 :                 goto fail;
    1133                 :            :         }
    1134         [ -  + ]:          1 :         if (launch_proc(argv7) != 0) {
    1135                 :            :                 printf("Error (line %d) - process did not run ok with --huge-dir flag\n",
    1136                 :            :                         __LINE__);
    1137                 :          0 :                 goto fail;
    1138                 :            :         }
    1139         [ -  + ]:          1 :         if (launch_proc(argv8) == 0) {
    1140                 :            :                 printf("Error (line %d) - process run ok with empty --huge-dir flag\n", __LINE__);
    1141                 :          0 :                 goto fail;
    1142                 :            :         }
    1143         [ -  + ]:          1 :         if (launch_proc(argv9) == 0) {
    1144                 :            :                 printf("Error (line %d) - process run ok with invalid --huge-dir flag\n", __LINE__);
    1145                 :          0 :                 goto fail;
    1146                 :            :         }
    1147         [ -  + ]:          1 :         if (launch_proc(argv10) == 0) {
    1148                 :            :                 printf("Error (line %d) - process run ok with invalid --huge-dir sub-dir flag\n",
    1149                 :            :                         __LINE__);
    1150                 :          0 :                 goto fail;
    1151                 :            :         }
    1152         [ -  + ]:          1 :         if (launch_proc(argv11) != 0) {
    1153                 :            :                 printf("Error (line %d) - process did not run ok with --huge-dir subdir flag\n",
    1154                 :            :                         __LINE__);
    1155                 :          0 :                 goto fail;
    1156                 :            :         }
    1157         [ -  + ]:          1 :         if (launch_proc(argv12) != 0) {
    1158                 :            :                 printf("Error (line %d) - secondary process did not run ok with invalid --huge-dir flag\n",
    1159                 :            :                         __LINE__);
    1160                 :          0 :                 goto fail;
    1161                 :            :         }
    1162         [ -  + ]:          1 :         if (launch_proc(argv13) != 0) {
    1163                 :            :                 printf("Error (line %d) - process did not run ok with --base-virtaddr parameter\n",
    1164                 :            :                         __LINE__);
    1165                 :          0 :                 goto fail;
    1166                 :            :         }
    1167         [ -  + ]:          1 :         if (launch_proc(argv14) != 0) {
    1168                 :            :                 printf("Error (line %d) - process did not run ok with --vfio-intr INTx parameter\n",
    1169                 :            :                         __LINE__);
    1170                 :          0 :                 goto fail;
    1171                 :            :         }
    1172         [ -  + ]:          1 :         if (launch_proc(argv15) != 0) {
    1173                 :            :                 printf("Error (line %d) - process did not run ok with --vfio-intr MSI parameter\n",
    1174                 :            :                         __LINE__);
    1175                 :          0 :                 goto fail;
    1176                 :            :         }
    1177         [ -  + ]:          1 :         if (launch_proc(argv16) != 0) {
    1178                 :            :                 printf("Error (line %d) - process did not run ok with --vfio-intr MSI-X parameter\n",
    1179                 :            :                         __LINE__);
    1180                 :          0 :                 goto fail;
    1181                 :            :         }
    1182         [ -  + ]:          1 :         if (launch_proc(argv17) == 0) {
    1183                 :            :                 printf("Error (line %d) - process run ok with --vfio-intr invalid parameter\n",
    1184                 :            :                         __LINE__);
    1185                 :          0 :                 goto fail;
    1186                 :            :         }
    1187         [ -  + ]:          1 :         if (launch_proc(argv18) != 0) {
    1188                 :            :                 printf("Error (line %d) - process did not run ok with --proc-type as auto parameter\n",
    1189                 :            :                         __LINE__);
    1190                 :          0 :                 goto fail;
    1191                 :            :         }
    1192         [ -  + ]:          1 :         if (launch_proc(argv19) != 0) {
    1193                 :            :                 printf("Error (line %d) - process did not run ok with --proc-type and --no-shconf parameter\n",
    1194                 :            :                         __LINE__);
    1195                 :          0 :                 goto fail;
    1196                 :            :         }
    1197         [ -  + ]:          1 :         if (launch_proc(argv20) != 0) {
    1198                 :            :                 printf("Error (line %d) - process did not run ok with --create-uio-dev parameter\n",
    1199                 :            :                         __LINE__);
    1200                 :          0 :                 goto fail;
    1201                 :            :         }
    1202         [ -  + ]:          1 :         if (launch_proc(argv21) != 0) {
    1203                 :            :                 printf("Error (line %d) - process did not run ok with --huge-worker-stack parameter\n",
    1204                 :            :                         __LINE__);
    1205                 :          0 :                 goto fail;
    1206                 :            :         }
    1207         [ -  + ]:          1 :         if (launch_proc(argv22) != 0) {
    1208                 :            :                 printf("Error (line %d) - process did not run ok with --huge-worker-stack=size parameter\n",
    1209                 :            :                         __LINE__);
    1210                 :          0 :                 goto fail;
    1211                 :            :         }
    1212         [ -  + ]:          1 :         if (launch_proc(argv23) != 0) {
    1213                 :            :                 printf("Error (line %d) - process did not run ok with --log-timestamp parameter\n",
    1214                 :            :                         __LINE__);
    1215                 :          0 :                 goto fail;
    1216                 :            :         }
    1217         [ -  + ]:          1 :         if (launch_proc(argv24) != 0) {
    1218                 :            :                 printf("Error (line %d) - process did not run ok with --log-timestamp=iso parameter\n",
    1219                 :            :                         __LINE__);
    1220                 :          0 :                 goto fail;
    1221                 :            :         }
    1222         [ -  + ]:          1 :         if (launch_proc(argv25) == 0) {
    1223                 :            :                 printf("Error (line %d) - process did run ok with --log-timestamp=invalid parameter\n",
    1224                 :            :                         __LINE__);
    1225                 :          0 :                 goto fail;
    1226                 :            :         }
    1227         [ -  + ]:          1 :         if (launch_proc(argv26) != 0) {
    1228                 :            :                 printf("Error (line %d) - process did not run ok with --log-color parameter\n",
    1229                 :            :                         __LINE__);
    1230                 :          0 :                 goto fail;
    1231                 :            :         }
    1232         [ -  + ]:          1 :         if (launch_proc(argv27) != 0) {
    1233                 :            :                 printf("Error (line %d) - process did not run ok with --log-color=never parameter\n",
    1234                 :            :                         __LINE__);
    1235                 :          0 :                 goto fail;
    1236                 :            :         }
    1237         [ -  + ]:          1 :         if (launch_proc(argv28) == 0) {
    1238                 :            :                 printf("Error (line %d) - process did run ok with --log-timestamp=invalid parameter\n",
    1239                 :            :                         __LINE__);
    1240                 :          0 :                 goto fail;
    1241                 :            :         }
    1242                 :            : 
    1243                 :          1 :         rmdir(hugepath_dir3);
    1244                 :          1 :         rmdir(hugepath_dir2);
    1245                 :          1 :         return 0;
    1246                 :            : 
    1247                 :          0 : fail:
    1248                 :          0 :         rmdir(hugepath_dir3);
    1249                 :          0 :         rmdir(hugepath_dir2);
    1250                 :          0 :         return -1;
    1251                 :            : }
    1252                 :            : 
    1253                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
    1254                 :            : 
    1255                 :            : static int
    1256                 :            : test_file_prefix(void)
    1257                 :            : {
    1258                 :            :         printf("file_prefix not supported on FreeBSD, skipping test\n");
    1259                 :            :         return TEST_SKIPPED;
    1260                 :            : }
    1261                 :            : 
    1262                 :            : #else
    1263                 :            : 
    1264                 :            : static int
    1265                 :          1 : test_file_prefix(void)
    1266                 :            : {
    1267                 :            :         /*
    1268                 :            :          * 1. check if current process hugefiles are locked
    1269                 :            :          * 2. try to run secondary process without a corresponding primary process
    1270                 :            :          * (while failing to run, it will also remove any unused hugepage files)
    1271                 :            :          * 3. check if current process hugefiles are still in place and are locked
    1272                 :            :          * 4. run a primary process with memtest1 prefix in default and legacy
    1273                 :            :          *    mem mode
    1274                 :            :          * 5. check if memtest1 hugefiles are created in case of legacy mem
    1275                 :            :          *    mode, and deleted in case of default mem mode
    1276                 :            :          * 6. run a primary process with memtest2 prefix in default and legacy
    1277                 :            :          *    mem modes
    1278                 :            :          * 7. check that memtest2 hugefiles are present in the hugedir after a
    1279                 :            :          *    run in legacy mode, and not present at all after run in default
    1280                 :            :          *    mem mode
    1281                 :            :          */
    1282                 :            :         char prefix[PATH_MAX];
    1283                 :            : 
    1284                 :            :         if (get_current_prefix(prefix, sizeof(prefix)) == NULL) {
    1285                 :            :                 printf("Error (line %d) - unable to get current prefix!\n", __LINE__);
    1286                 :            :                 return -1;
    1287                 :            :         }
    1288                 :            : 
    1289                 :            :         /* this should fail unless the test itself is run with "memtest" prefix */
    1290                 :          1 :         const char *argv0[] = {prgname, mp_flag, eal_debug_logs, "-m",
    1291                 :            :                         DEFAULT_MEM_SIZE, "--file-prefix=" memtest };
    1292                 :            : 
    1293                 :            :         /* primary process with memtest1 and default mem mode */
    1294                 :          1 :         const char *argv1[] = {prgname, eal_debug_logs, no_pci, "-m",
    1295                 :            :                         DEFAULT_MEM_SIZE, "--file-prefix=" memtest1 };
    1296                 :            : 
    1297                 :            :         /* primary process with memtest1 and legacy mem mode */
    1298                 :          1 :         const char *argv2[] = {prgname, eal_debug_logs, no_pci, "-m",
    1299                 :            :                         DEFAULT_MEM_SIZE, "--file-prefix=" memtest1,
    1300                 :            :                         "--legacy-mem" };
    1301                 :            : 
    1302                 :            :         /* primary process with memtest2 and legacy mem mode */
    1303                 :          1 :         const char *argv3[] = {prgname, eal_debug_logs, no_pci, "-m",
    1304                 :            :                         DEFAULT_MEM_SIZE, "--file-prefix=" memtest2,
    1305                 :            :                         "--legacy-mem" };
    1306                 :            : 
    1307                 :            :         /* primary process with memtest2 and default mem mode */
    1308                 :          1 :         const char *argv4[] = {prgname, eal_debug_logs, no_pci, "-m",
    1309                 :            :                         DEFAULT_MEM_SIZE, "--file-prefix=" memtest2 };
    1310                 :            : 
    1311                 :            :         /* primary process with --in-memory mode */
    1312                 :          1 :         const char * const argv5[] = {prgname, eal_debug_logs, no_pci, "-m",
    1313                 :            :                 DEFAULT_MEM_SIZE, "--in-memory" };
    1314                 :            : 
    1315                 :            :         /* primary process with memtest1 and --in-memory mode */
    1316                 :          1 :         const char * const argv6[] = {prgname, eal_debug_logs, no_pci, "-m",
    1317                 :            :                 DEFAULT_MEM_SIZE, "--in-memory",
    1318                 :            :                 "--file-prefix=" memtest1 };
    1319                 :            : 
    1320                 :            :         /* primary process with parent file-prefix and --in-memory mode */
    1321                 :          1 :         const char * const argv7[] = {prgname, eal_debug_logs, no_pci, "-m",
    1322                 :            :                 DEFAULT_MEM_SIZE, "--in-memory", "--file-prefix", prefix };
    1323                 :            : 
    1324                 :            :         /* primary process with memtest1 and --single-file-segments mode */
    1325                 :          1 :         const char * const argv8[] = {prgname, eal_debug_logs, no_pci, "-m",
    1326                 :            :                 DEFAULT_MEM_SIZE, "--single-file-segments",
    1327                 :            :                 "--file-prefix=" memtest1 };
    1328                 :            : 
    1329                 :            :         /* primary process with memtest1 and --huge-unlink=never mode */
    1330                 :          1 :         const char * const argv9[] = {prgname, eal_debug_logs, no_pci, "-m",
    1331                 :            :                 DEFAULT_MEM_SIZE, "--huge-unlink=never",
    1332                 :            :                 "--file-prefix=" memtest1 };
    1333                 :            : 
    1334                 :            :         /* check if files for current prefix are present */
    1335         [ -  + ]:          1 :         if (process_hugefiles(prefix, HUGEPAGE_CHECK_EXISTS) != 1) {
    1336                 :            :                 printf("Error (line %d) - hugepage files for %s were not created!\n",
    1337                 :            :                         __LINE__, prefix);
    1338                 :          0 :                 return -1;
    1339                 :            :         }
    1340                 :            : 
    1341                 :            :         /* checks if files for current prefix are locked */
    1342         [ -  + ]:          1 :         if (process_hugefiles(prefix, HUGEPAGE_CHECK_LOCKED) != 1) {
    1343                 :            :                 printf("Error (line %d) - hugepages for current process aren't locked!\n",
    1344                 :            :                         __LINE__);
    1345                 :          0 :                 return -1;
    1346                 :            :         }
    1347                 :            : 
    1348                 :            :         /* check if files for secondary process are present */
    1349         [ -  + ]:          1 :         if (process_hugefiles(memtest, HUGEPAGE_CHECK_EXISTS) == 1) {
    1350                 :            :                 /* check if they are not locked */
    1351         [ #  # ]:          0 :                 if (process_hugefiles(memtest, HUGEPAGE_CHECK_LOCKED) == 1) {
    1352                 :            :                         printf("Error (line %d) - hugepages for current process are locked!\n",
    1353                 :            :                                 __LINE__);
    1354                 :          0 :                         return -1;
    1355                 :            :                 }
    1356                 :            :                 /* they aren't locked, delete them */
    1357                 :            :                 else {
    1358         [ #  # ]:          0 :                         if (process_hugefiles(memtest, HUGEPAGE_DELETE) != 1) {
    1359                 :            :                                 printf("Error (line %d) - deleting hugepages failed!\n",
    1360                 :            :                                         __LINE__);
    1361                 :          0 :                                 return -1;
    1362                 :            :                         }
    1363                 :            :                 }
    1364                 :            :         }
    1365                 :            : 
    1366         [ -  + ]:          1 :         if (launch_proc(argv0) == 0) {
    1367                 :            :                 printf("Error (line %d) - secondary process ran ok without primary process\n",
    1368                 :            :                         __LINE__);
    1369                 :          0 :                 return -1;
    1370                 :            :         }
    1371                 :            : 
    1372                 :            :         /* check if files for current prefix are present */
    1373         [ -  + ]:          1 :         if (process_hugefiles(prefix, HUGEPAGE_CHECK_EXISTS) != 1) {
    1374                 :            :                 printf("Error (line %d) - hugepage files for %s were not created!\n",
    1375                 :            :                         __LINE__, prefix);
    1376                 :          0 :                 return -1;
    1377                 :            :         }
    1378                 :            : 
    1379                 :            :         /* checks if files for current prefix are locked */
    1380         [ -  + ]:          1 :         if (process_hugefiles(prefix, HUGEPAGE_CHECK_LOCKED) != 1) {
    1381                 :            :                 printf("Error (line %d) - hugepages for current process aren't locked!\n",
    1382                 :            :                         __LINE__);
    1383                 :          0 :                 return -1;
    1384                 :            :         }
    1385                 :            : 
    1386                 :            :         /* we're running this process in default memory mode, which means it
    1387                 :            :          * should clean up after itself on exit and leave no hugepages behind.
    1388                 :            :          */
    1389         [ -  + ]:          1 :         if (launch_proc(argv1) != 0) {
    1390                 :            :                 printf("Error (line %d) - failed to run with --file-prefix=%s\n",
    1391                 :            :                         __LINE__, memtest1);
    1392                 :          0 :                 return -1;
    1393                 :            :         }
    1394                 :            : 
    1395                 :            :         /* check if memtest1_map0 is present */
    1396         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 0) {
    1397                 :            :                 printf("Error (line %d) - hugepage files for %s were not deleted!\n",
    1398                 :            :                         __LINE__, memtest1);
    1399                 :          0 :                 return -1;
    1400                 :            :         }
    1401                 :            : 
    1402                 :            :         /* now, we're running a process under the same prefix, but with legacy
    1403                 :            :          * mem mode - this should leave behind hugepage files.
    1404                 :            :          */
    1405         [ -  + ]:          1 :         if (launch_proc(argv2) != 0) {
    1406                 :            :                 printf("Error (line %d) - failed to run with --file-prefix=%s\n",
    1407                 :            :                         __LINE__, memtest1);
    1408                 :          0 :                 return -1;
    1409                 :            :         }
    1410                 :            : 
    1411                 :            :         /* check if memtest1_map0 is present */
    1412         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 1) {
    1413                 :            :                 printf("Error (line %d) - hugepage files for %s were not created!\n",
    1414                 :            :                         __LINE__, memtest1);
    1415                 :          0 :                 return -1;
    1416                 :            :         }
    1417                 :            : 
    1418         [ -  + ]:          1 :         if (launch_proc(argv3) != 0) {
    1419                 :            :                 printf("Error (line %d) - failed to run with --file-prefix=%s\n",
    1420                 :            :                         __LINE__, memtest2);
    1421                 :          0 :                 return -1;
    1422                 :            :         }
    1423                 :            : 
    1424                 :            :         /* check if hugefiles for memtest2 are present */
    1425         [ -  + ]:          1 :         if (process_hugefiles(memtest2, HUGEPAGE_CHECK_EXISTS) != 1) {
    1426                 :            :                 printf("Error (line %d) - hugepage files for %s were not created!\n",
    1427                 :            :                         __LINE__, memtest2);
    1428                 :          0 :                 return -1;
    1429                 :            :         }
    1430                 :            : 
    1431                 :            :         /* check if hugefiles for memtest1 are present */
    1432         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 0) {
    1433                 :            :                 printf("Error (line %d) - hugepage files for %s were not deleted!\n",
    1434                 :            :                         __LINE__, memtest1);
    1435                 :          0 :                 return -1;
    1436                 :            :         }
    1437                 :            : 
    1438                 :            :         /* this process will run in default mem mode, so it should not leave any
    1439                 :            :          * hugepage files behind.
    1440                 :            :          */
    1441         [ -  + ]:          1 :         if (launch_proc(argv4) != 0) {
    1442                 :            :                 printf("Error (line %d) - failed to run with --file-prefix=%s\n",
    1443                 :            :                         __LINE__, memtest2);
    1444                 :          0 :                 return -1;
    1445                 :            :         }
    1446                 :            : 
    1447                 :            :         /* check if hugefiles for memtest2 are present */
    1448         [ -  + ]:          1 :         if (process_hugefiles(memtest2, HUGEPAGE_CHECK_EXISTS) != 0) {
    1449                 :            :                 printf("Error (line %d) - hugepage files for %s were not deleted!\n",
    1450                 :            :                         __LINE__, memtest2);
    1451                 :          0 :                 return -1;
    1452                 :            :         }
    1453                 :            : 
    1454                 :            :         /* check if hugefiles for memtest1 are present */
    1455         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 0) {
    1456                 :            :                 printf("Error (line %d) - hugepage files for %s were not deleted!\n",
    1457                 :            :                         __LINE__, memtest1);
    1458                 :          0 :                 return -1;
    1459                 :            :         }
    1460                 :            : 
    1461                 :            :         /* this process will run in --in-memory mode, so it should not leave any
    1462                 :            :          * hugepage files behind.
    1463                 :            :          */
    1464                 :            : 
    1465                 :            :         /* test case to check eal-options with --in-memory mode */
    1466         [ -  + ]:          1 :         if (launch_proc(argv5) != 0) {
    1467                 :            :                 printf("Error (line %d) - failed to run with --in-memory mode\n",
    1468                 :            :                         __LINE__);
    1469                 :          0 :                 return -1;
    1470                 :            :         }
    1471                 :            : 
    1472                 :            :         /*test case to check eal-options with --in-memory mode with
    1473                 :            :          * custom file-prefix.
    1474                 :            :          */
    1475         [ -  + ]:          1 :         if (launch_proc(argv6) != 0) {
    1476                 :            :                 printf("Error (line %d) - failed to run with --in-memory mode\n", __LINE__);
    1477                 :          0 :                 return -1;
    1478                 :            :         }
    1479                 :            : 
    1480                 :            :         /* check if hugefiles for memtest1 are present */
    1481         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 0) {
    1482                 :            :                 printf("Error (line %d) - hugepage files for %s were created and not deleted!\n",
    1483                 :            :                         __LINE__, memtest1);
    1484                 :          0 :                 return -1;
    1485                 :            :         }
    1486                 :            : 
    1487                 :            :         /* test case to check eal-options with --in-memory mode with
    1488                 :            :          * parent file-prefix.
    1489                 :            :          */
    1490         [ -  + ]:          1 :         if (launch_proc(argv7) != 0) {
    1491                 :            :                 printf("Error (line %d) - failed to run with --file-prefix=%s\n", __LINE__, prefix);
    1492                 :          0 :                 return -1;
    1493                 :            :         }
    1494                 :            : 
    1495                 :            :         /* this process will run in --single-file-segments mode,
    1496                 :            :          * so it should not leave any hugepage files behind.
    1497                 :            :          */
    1498         [ -  + ]:          1 :         if (launch_proc(argv8) != 0) {
    1499                 :            :                 printf("Error (line %d) - failed to run with --single-file-segments mode\n",
    1500                 :            :                         __LINE__);
    1501                 :          0 :                 return -1;
    1502                 :            :         }
    1503                 :            : 
    1504                 :            :         /* check if hugefiles for memtest1 are present */
    1505         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) != 0) {
    1506                 :            :                 printf("Error (line %d) - hugepage files for %s were not deleted!\n",
    1507                 :            :                         __LINE__, memtest1);
    1508                 :          0 :                 return -1;
    1509                 :            :         }
    1510                 :            : 
    1511                 :            :         /* this process will run with --huge-unlink,
    1512                 :            :          * so it should not remove hugepage files when it exits
    1513                 :            :          */
    1514         [ -  + ]:          1 :         if (launch_proc(argv9) != 0) {
    1515                 :            :                 printf("Error (line %d) - failed to run with --huge-unlink=never\n", __LINE__);
    1516                 :          0 :                 return -1;
    1517                 :            :         }
    1518                 :            : 
    1519                 :            :         /* check if hugefiles for memtest1 are present */
    1520         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_CHECK_EXISTS) == 0) {
    1521                 :            :                 printf("Error (line %d) - hugepage files for %s were deleted!\n",
    1522                 :            :                         __LINE__, memtest1);
    1523                 :          0 :                 return -1;
    1524                 :            :         }
    1525         [ -  + ]:          1 :         if (process_hugefiles(memtest1, HUGEPAGE_DELETE) != 1) {
    1526                 :            :                 printf("Error (line %d) - deleting hugepages failed!\n", __LINE__);
    1527                 :          0 :                 return -1;
    1528                 :            :         }
    1529                 :            : 
    1530                 :            :         return 0;
    1531                 :            : }
    1532                 :            : #endif
    1533                 :            : 
    1534                 :            : /* This function writes in passed buf pointer a valid --socket-mem= option
    1535                 :            :  * for num_sockets then concatenates the provided suffix string.
    1536                 :            :  *
    1537                 :            :  * Example for num_sockets 4, mem "2", suffix "plop"
    1538                 :            :  * --socket-mem=2,2,2,2plop
    1539                 :            :  */
    1540                 :            : static void
    1541         [ +  - ]:          7 : populate_socket_mem_param(int num_sockets, const char *mem,
    1542                 :            :                 const char *suffix, char *buf, size_t buf_size)
    1543                 :            : {
    1544                 :            :         unsigned int offset = 0;
    1545                 :            :         int written;
    1546                 :            :         int i;
    1547                 :            : 
    1548                 :            :         written = snprintf(&buf[offset], buf_size - offset, "--socket-mem=");
    1549   [ +  -  +  - ]:          7 :         if (written < 0 || written + offset >= buf_size)
    1550                 :            :                 return;
    1551                 :            :         offset += written;
    1552                 :            : 
    1553         [ +  + ]:         12 :         for (i = 0; i < num_sockets - 1; i++) {
    1554         [ +  - ]:          5 :                 written = snprintf(&buf[offset], buf_size - offset,
    1555                 :            :                         "%s,", mem);
    1556   [ +  -  +  - ]:          5 :                 if (written < 0 || written + offset >= buf_size)
    1557                 :            :                         return;
    1558                 :            :                 offset += written;
    1559                 :            :         }
    1560                 :            : 
    1561                 :          7 :         written = snprintf(&buf[offset], buf_size - offset, "%s%s", mem,
    1562                 :            :                 suffix);
    1563                 :            :         if (written < 0 || written + offset >= buf_size)
    1564                 :          7 :                 return;
    1565                 :            :         offset += written;
    1566                 :            : }
    1567                 :            : 
    1568                 :            : /*
    1569                 :            :  * Tests for correct handling of -m and --socket-mem flags
    1570                 :            :  */
    1571                 :            : static int
    1572                 :          1 : test_memory_flags(void)
    1573                 :            : {
    1574                 :          1 :         const char *prefix = file_prefix_arg();
    1575         [ -  + ]:          1 :         if (prefix == NULL) {
    1576                 :            :                 printf("Error (line %d) - unable to get current prefix!\n", __LINE__);
    1577                 :          0 :                 return -1;
    1578                 :            :         }
    1579                 :            : 
    1580                 :            :         /* valid -m flag and mp flag */
    1581                 :          1 :         const char *argv0[] = {prgname, prefix, mp_flag, eal_debug_logs,
    1582                 :            :                         "-m", DEFAULT_MEM_SIZE};
    1583                 :            : 
    1584                 :            :         /* valid -m flag */
    1585                 :          1 :         const char *argv1[] = {prgname, eal_debug_logs, no_pci,
    1586                 :            :                         "--file-prefix=" memtest, "-m", DEFAULT_MEM_SIZE};
    1587                 :            : 
    1588                 :            :         /* valid (zero) --socket-mem flag */
    1589                 :            :         char arg2_socket_mem[SOCKET_MEM_STRLEN];
    1590                 :          1 :         const char *argv2[] = {prgname, eal_debug_logs, no_pci,
    1591                 :            :                         "--file-prefix=" memtest, arg2_socket_mem};
    1592                 :            : 
    1593                 :            :         /* invalid (incomplete) --socket-mem flag */
    1594                 :            :         char arg3_socket_mem[SOCKET_MEM_STRLEN];
    1595                 :          1 :         const char *argv3[] = {prgname, eal_debug_logs, no_pci,
    1596                 :            :                         "--file-prefix=" memtest, arg3_socket_mem};
    1597                 :            : 
    1598                 :            :         /* invalid (mixed with invalid data) --socket-mem flag */
    1599                 :            :         char arg4_socket_mem[SOCKET_MEM_STRLEN];
    1600                 :          1 :         const char *argv4[] = {prgname, eal_debug_logs, no_pci,
    1601                 :            :                         "--file-prefix=" memtest, arg4_socket_mem};
    1602                 :            : 
    1603                 :            :         /* invalid (with numeric value as last character) --socket-mem flag */
    1604                 :            :         char arg5_socket_mem[SOCKET_MEM_STRLEN];
    1605                 :          1 :         const char *argv5[] = {prgname, eal_debug_logs, no_pci,
    1606                 :            :                         "--file-prefix=" memtest, arg5_socket_mem};
    1607                 :            : 
    1608                 :            :         /* invalid (with empty socket) --socket-mem flag */
    1609                 :            :         char arg6_socket_mem[SOCKET_MEM_STRLEN];
    1610                 :          1 :         const char *argv6[] = {prgname, eal_debug_logs, no_pci,
    1611                 :            :                         "--file-prefix=" memtest, arg6_socket_mem};
    1612                 :            : 
    1613                 :            :         /* invalid (null) --socket-mem flag */
    1614                 :          1 :         const char *argv7[] = {prgname, eal_debug_logs, no_pci,
    1615                 :            :                         "--file-prefix=" memtest, "--socket-mem="};
    1616                 :            : 
    1617                 :            :         /* valid --socket-mem specified together with -m flag */
    1618                 :            :         char arg8_socket_mem[SOCKET_MEM_STRLEN];
    1619                 :          1 :         const char *argv8[] = {prgname, eal_debug_logs, no_pci,
    1620                 :            :                         "--file-prefix=" memtest, "-m", DEFAULT_MEM_SIZE,
    1621                 :            :                         arg8_socket_mem};
    1622                 :            : 
    1623                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
    1624                 :            :         int num_sockets = 1;
    1625                 :            : #else
    1626                 :          1 :         int num_sockets = RTE_MIN(get_number_of_sockets(),
    1627                 :            :                         RTE_MAX_NUMA_NODES);
    1628                 :            : #endif
    1629                 :            : 
    1630         [ -  + ]:          1 :         if (num_sockets <= 0) {
    1631                 :            :                 printf("Error (line %d) - cannot get number of sockets!\n", __LINE__);
    1632                 :          0 :                 return -1;
    1633                 :            :         }
    1634                 :            : 
    1635                 :            :         /* invalid --socket-mem flag (with extra socket) */
    1636                 :            :         char invalid_socket_mem[SOCKET_MEM_STRLEN];
    1637                 :          1 :         const char *argv9[] = {prgname, eal_debug_logs, no_pci,
    1638                 :            :                         "--file-prefix=" memtest, invalid_socket_mem};
    1639                 :            : 
    1640                 :            :         /* valid --socket-mem flag */
    1641                 :            :         char valid_socket_mem[SOCKET_MEM_STRLEN];
    1642                 :          1 :         const char *argv10[] = {prgname, eal_debug_logs, no_pci,
    1643                 :            :                         "--file-prefix=" memtest, valid_socket_mem};
    1644                 :            : 
    1645         [ -  + ]:          1 :         if (launch_proc(argv0) != 0) {
    1646                 :            :                 printf("Error (line %d) - secondary process failed with valid -m flag !\n",
    1647                 :            :                         __LINE__);
    1648                 :          0 :                 return -1;
    1649                 :            :         }
    1650                 :            : 
    1651                 :            : #ifdef RTE_EXEC_ENV_FREEBSD
    1652                 :            :         /* no other tests are applicable to BSD */
    1653                 :            :         return 0;
    1654                 :            : #endif
    1655                 :            : 
    1656         [ -  + ]:          1 :         if (launch_proc(argv1) != 0) {
    1657                 :            :                 printf("Error (line %d) - process failed with valid -m flag!\n", __LINE__);
    1658                 :          0 :                 return -1;
    1659                 :            :         }
    1660                 :            : 
    1661                 :          1 :         populate_socket_mem_param(num_sockets, "0", "",
    1662                 :            :                 arg2_socket_mem, sizeof(arg2_socket_mem));
    1663         [ -  + ]:          1 :         if (launch_proc(argv2) != 0) {
    1664                 :            :                 printf("Error (line %d) - process failed with valid (zero) --socket-mem!\n",
    1665                 :            :                         __LINE__);
    1666                 :          0 :                 return -1;
    1667                 :            :         }
    1668                 :            : 
    1669         [ +  - ]:          1 :         if (num_sockets > 1) {
    1670                 :          1 :                 populate_socket_mem_param(num_sockets - 1, "2", ",",
    1671                 :            :                         arg3_socket_mem, sizeof(arg3_socket_mem));
    1672         [ -  + ]:          1 :                 if (launch_proc(argv3) == 0) {
    1673                 :            :                         printf("Error (line %d) - process run ok with invalid (incomplete) --socket-mem!\n",
    1674                 :            :                                 __LINE__);
    1675                 :          0 :                         return -1;
    1676                 :            :                 }
    1677                 :            : 
    1678                 :          1 :                 populate_socket_mem_param(num_sockets - 1, "2", ",Fred",
    1679                 :            :                         arg4_socket_mem, sizeof(arg4_socket_mem));
    1680         [ -  + ]:          1 :                 if (launch_proc(argv4) == 0) {
    1681                 :            :                         printf("Error (line %d) - process run ok with invalid (mixed with invalid input) --socket-mem!\n",
    1682                 :            :                                 __LINE__);
    1683                 :          0 :                         return -1;
    1684                 :            :                 }
    1685                 :            : 
    1686                 :          1 :                 populate_socket_mem_param(num_sockets - 1, "2", ",Fred0",
    1687                 :            :                         arg5_socket_mem, sizeof(arg5_socket_mem));
    1688         [ -  + ]:          1 :                 if (launch_proc(argv5) == 0) {
    1689                 :            :                         printf("Error (line %d) - process run ok with invalid (mixed with invalid input with a numeric value as last character) --socket-mem!\n",
    1690                 :            :                                 __LINE__);
    1691                 :          0 :                         return -1;
    1692                 :            :                 }
    1693                 :            :         }
    1694                 :            : 
    1695         [ -  + ]:          1 :         if (num_sockets > 2) {
    1696                 :          0 :                 populate_socket_mem_param(num_sockets - 2, "2", ",,2",
    1697                 :            :                         arg6_socket_mem, sizeof(arg6_socket_mem));
    1698         [ #  # ]:          0 :                 if (launch_proc(argv6) == 0) {
    1699                 :            :                         printf("Error (line %d) - process run ok with invalid (with empty socket) --socket-mem!\n",
    1700                 :            :                                 __LINE__);
    1701                 :          0 :                         return -1;
    1702                 :            :                 }
    1703                 :            :         }
    1704                 :            : 
    1705         [ -  + ]:          1 :         if (launch_proc(argv7) == 0) {
    1706                 :            :                 printf("Error (line %d) - process run ok with invalid (null) --socket-mem!\n",
    1707                 :            :                         __LINE__);
    1708                 :          0 :                 return -1;
    1709                 :            :         }
    1710                 :            : 
    1711                 :          1 :         populate_socket_mem_param(num_sockets, "2", "",
    1712                 :            :                 arg8_socket_mem, sizeof(arg8_socket_mem));
    1713         [ -  + ]:          1 :         if (launch_proc(argv8) == 0) {
    1714                 :            :                 printf("Error (line %d) - process run ok with --socket-mem and -m specified!\n",
    1715                 :            :                         __LINE__);
    1716                 :          0 :                 return -1;
    1717                 :            :         }
    1718                 :            : 
    1719                 :          1 :         populate_socket_mem_param(num_sockets + 1, "2", "",
    1720                 :            :                 invalid_socket_mem, sizeof(invalid_socket_mem));
    1721         [ -  + ]:          1 :         if (launch_proc(argv9) == 0) {
    1722                 :            :                 printf("Error (line %d) - process run ok with extra socket in --socket-mem!\n",
    1723                 :            :                         __LINE__);
    1724                 :          0 :                 return -1;
    1725                 :            :         }
    1726                 :            : 
    1727                 :          1 :         populate_socket_mem_param(num_sockets, "2", "",
    1728                 :            :                 valid_socket_mem, sizeof(valid_socket_mem));
    1729         [ -  + ]:          1 :         if (launch_proc(argv10) != 0) {
    1730                 :            :                 printf("Error (line %d) - process failed with valid --socket-mem!\n", __LINE__);
    1731                 :          0 :                 return -1;
    1732                 :            :         }
    1733                 :            : 
    1734                 :            :         return 0;
    1735                 :            : }
    1736                 :            : 
    1737                 :            : #endif /* !RTE_EXEC_ENV_WINDOWS */
    1738                 :            : 
    1739                 :        284 : REGISTER_FAST_TEST(eal_flags_c_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_missing_c_flag);
    1740                 :        284 : REGISTER_FAST_TEST(eal_flags_main_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_main_lcore_flag);
    1741                 :        284 : REGISTER_FAST_TEST(eal_flags_n_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_invalid_n_flag);
    1742                 :        284 : REGISTER_FAST_TEST(eal_flags_hpet_autotest, NOHUGE_SKIP, ASAN_SKIP, test_no_hpet_flag);
    1743                 :        284 : REGISTER_FAST_TEST(eal_flags_no_huge_autotest, NOHUGE_SKIP, ASAN_SKIP, test_no_huge_flag);
    1744                 :        284 : REGISTER_FAST_TEST(eal_flags_a_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_allow_flag);
    1745                 :        284 : REGISTER_FAST_TEST(eal_flags_b_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_invalid_b_flag);
    1746                 :        284 : REGISTER_FAST_TEST(eal_flags_vdev_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_invalid_vdev_flag);
    1747                 :        284 : REGISTER_FAST_TEST(eal_flags_r_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_invalid_r_flag);
    1748                 :        284 : REGISTER_FAST_TEST(eal_flags_mem_autotest, NOHUGE_SKIP, ASAN_SKIP, test_memory_flags);
    1749                 :        284 : REGISTER_FAST_TEST(eal_flags_file_prefix_autotest, NOHUGE_SKIP, ASAN_SKIP, test_file_prefix);
    1750                 :        284 : REGISTER_FAST_TEST(eal_flags_misc_autotest, NOHUGE_SKIP, ASAN_SKIP, test_misc_flags);

Generated by: LCOV version 1.14