port: tests: F_GETPIPE_SZ is linux specific
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 16 Jul 2021 18:48:48 +0000 (14:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 13 Jan 2023 16:53:43 +0000 (11:53 -0500)
Change-Id: Ifa6631cc72b8998e1331905ff851cd2477fab148
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/notification/default_pipe_size_getter.cpp

index 843070b5923cd07dda15511d40d4f699085ec72d..febcc0a067ea0224e4b53ab6f351d8a8d156b894 100644 (file)
@@ -25,7 +25,12 @@ int lttng_opt_verbose;
 int lttng_opt_mi;
 int lttng_opt_quiet;
 
-int main(void)
+#ifdef __linux__
+/*
+ * Return the default pipe buffer size or a negative error.
+ */
+static
+int get_pipe_size(void)
 {
        int ret;
        /*
@@ -38,20 +43,40 @@ int main(void)
 
        if (!pipe) {
                /* lttng_pipe_open already logs on error. */
-               ret = EXIT_FAILURE;
+               ret = -1;
                goto end;
        }
 
        ret = fcntl(lttng_pipe_get_writefd(pipe), F_GETPIPE_SZ);
        if (ret < 0) {
                PERROR("Failed to get the size of the pipe");
-               ret = EXIT_FAILURE;
-               goto end;
        }
 
-       printf("%d\n", ret);
-       ret = EXIT_SUCCESS;
-end:
        lttng_pipe_destroy(pipe);
+end:
        return ret;
 }
+#elif defined(__FreeBSD__)
+static
+int get_pipe_size(void)
+{
+       return 65536;
+}
+#else
+#error "Implement get_pipe_size() for your platform."
+#endif
+
+int main(void)
+{
+       int ret;
+
+       ret = get_pipe_size();
+       if (ret < 0) {
+               return EXIT_FAILURE;
+       }
+
+       /* Print the pipe buffer size to stdout */
+       printf("%d\n", ret);
+
+       return  EXIT_SUCCESS;
+}
This page took 0.027714 seconds and 4 git commands to generate.