The eal_fs test needs /proc/self/fd to find the name of the
temporary file it creates. FreeBSD does not have it, so the test
returned early from inside test_parse_sysfs_value(), which clang
reports as unreachable code for the rest of the function.

Worse, returning zero reported the test as passing when it had not
run at all.

Build the skip stub on FreeBSD as well as Windows and return
TEST_SKIPPED, which is what the rest of the file already does.
This also removes the unreachable body rather than hiding it.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 app/test/test_eal_fs.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/app/test/test_eal_fs.c b/app/test/test_eal_fs.c
index 62eea98677..4201b7fc3f 100644
--- a/app/test/test_eal_fs.c
+++ b/app/test/test_eal_fs.c
@@ -10,11 +10,12 @@
 
 #include "eal_filesystem.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
+/* Both need /proc/self/fd to find the name of a temporary file. */
+#if defined(RTE_EXEC_ENV_WINDOWS) || defined(RTE_EXEC_ENV_FREEBSD)
 static int
 test_eal_fs(void)
 {
-       printf("eal_fs not supported on Windows, skipping test\n");
+       printf("eal_fs not supported on this platform, skipping test\n");
        return TEST_SKIPPED;
 }
 
@@ -31,11 +32,6 @@ test_parse_sysfs_value(void)
        unsigned valid_number;
        unsigned long retval = 0;
 
-#ifdef RTE_EXEC_ENV_FREEBSD
-       /* BSD doesn't have /proc/pid/fd */
-       return 0;
-#endif
-
        printf("Testing function eal_parse_sysfs_value()\n");
 
        /* get a temporary filename to use for all tests - create temp file 
handle and then
@@ -183,6 +179,6 @@ test_eal_fs(void)
        return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
+#endif /* !RTE_EXEC_ENV_WINDOWS && !RTE_EXEC_ENV_FREEBSD */
 
 REGISTER_FAST_TEST(eal_fs_autotest, NOHUGE_OK, ASAN_OK, test_eal_fs);
-- 
2.53.0

Reply via email to