selftests: mqueue: delete RUN_TESTS and EMIT_TESTS overrides
authorShuah Khan (Samsung OSG) <shuah@kernel.org>
Wed, 2 May 2018 19:13:11 +0000 (13:13 -0600)
committerShuah Khan (Samsung OSG) <shuah@kernel.org>
Wed, 30 May 2018 21:21:52 +0000 (15:21 -0600)
Delete RUN_TESTS and EMIT_TESTS overrides and use common defines in lib.mk.
The overrides are in place to call mq_open_tests with queue name argument.
The change to delete overrides is coupled with a change to mq_open_tests
to use default queue name when it is called without one.

Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Reviewed-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
tools/testing/selftests/mqueue/Makefile
tools/testing/selftests/mqueue/mq_open_tests.c

index 743d3f9e59181c5f39346727d2a2286c5eabf511..8a58055fc1f59946c40f8d3ededab6dbe34d8b4f 100644 (file)
@@ -1,17 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS += -O2
 LDLIBS = -lrt -lpthread -lpopt
+
 TEST_GEN_PROGS := mq_open_tests mq_perf_tests
 
 include ../lib.mk
-
-override define RUN_TESTS
-       @$(OUTPUT)/mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]"
-       @$(OUTPUT)/mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
-endef
-
-override define EMIT_TESTS
-       echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
-       echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
-endef
-
index e0a74bd207a547c865f2e352f186a5b4cdf14da6..677140aa25fde54bf2c4d64d0e748acefaf46cb1 100644 (file)
@@ -53,6 +53,7 @@ int saved_def_msgs, saved_def_msgsize, saved_max_msgs, saved_max_msgsize;
 int cur_def_msgs, cur_def_msgsize, cur_max_msgs, cur_max_msgsize;
 FILE *def_msgs, *def_msgsize, *max_msgs, *max_msgsize;
 char *queue_path;
+char *default_queue_path = "/test1";
 mqd_t queue = -1;
 
 static inline void __set(FILE *stream, int value, char *err_msg);
@@ -238,27 +239,27 @@ int main(int argc, char *argv[])
        struct mq_attr attr, result;
 
        if (argc != 2) {
-               fprintf(stderr, "Must pass a valid queue name\n\n");
-               fprintf(stderr, usage, argv[0]);
-               exit(1);
-       }
+               printf("Using Default queue path - %s\n", default_queue_path);
+               queue_path = default_queue_path;
+       } else {
 
        /*
         * Although we can create a msg queue with a non-absolute path name,
         * unlink will fail.  So, if the name doesn't start with a /, add one
         * when we save it.
         */
-       if (*argv[1] == '/')
-               queue_path = strdup(argv[1]);
-       else {
-               queue_path = malloc(strlen(argv[1]) + 2);
-               if (!queue_path) {
-                       perror("malloc()");
-                       exit(1);
+               if (*argv[1] == '/')
+                       queue_path = strdup(argv[1]);
+               else {
+                       queue_path = malloc(strlen(argv[1]) + 2);
+                       if (!queue_path) {
+                               perror("malloc()");
+                               exit(1);
+                       }
+                       queue_path[0] = '/';
+                       queue_path[1] = 0;
+                       strcat(queue_path, argv[1]);
                }
-               queue_path[0] = '/';
-               queue_path[1] = 0;
-               strcat(queue_path, argv[1]);
        }
 
        if (getuid() != 0) {