tests: tap: remove semicolons in pass / fail definitions
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 20 Aug 2021 19:36:50 +0000 (15:36 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 24 Aug 2021 20:56:20 +0000 (16:56 -0400)
I wanted to write something like this in a test:

    if (cond)
      fail("message 1");
    else
      fail("message 2");

And was met with

      CC       test_action.o
    /home/simark/src/lttng-tools/tests/unit/test_action.c: In function ‘main’:
    /home/simark/src/lttng-tools/tests/unit/test_action.c:544:9: error: ‘else’ without a previous ‘if’
      544 |         else
          |         ^~~~

I then remembered that it was in our coding style to use braces:

    if (cond) {
      fail("message 1");
    } else {
      fail("message 2");
    }

... which avoids the error.  But still, the former form should work.
Fix this by removing the semi-colons in the pass and fail definitions, I
don't think they belong there.  Doing so finds a spot in ini_config.c
where a semi-colon is missing, add it.

Change-Id: I6ff09d496a0b12f34baa6f993cffc69eef611df0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/unit/ini_config/ini_config.c
tests/utils/tap/tap.h

index a16d1b9e8d8f540a4e87215e6ab9c2162eebc4d9..6775ddd3f2f7d5f0902df5a6c796e78eeb75d091 100644 (file)
@@ -78,7 +78,7 @@ int main(int argc, char **argv)
        }
        path = utils_expand_path(argv[1]);
        if (!path) {
-               fail("Failed to resolve sample INI file path")
+               fail("Failed to resolve sample INI file path");
        }
 
        plan_no_plan();
index ab9aad1aa6f9f080c2829f48552ee852582a1a0a..c15909d897d7e7285a67cfd443be50dd502a60be 100644 (file)
@@ -40,8 +40,8 @@
                 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
                 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
 
-# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
-# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
+# define pass(test, ...) ok(1, test, ## __VA_ARGS__)
+# define fail(test, ...) ok(0, test, ## __VA_ARGS__)
 
 # define skip_start(test, n, fmt, ...)                 \
        do {                                            \
@@ -60,8 +60,8 @@
                 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
                 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
 
-# define pass(...) ok(1, __VA_ARGS__);
-# define fail(...) ok(0, __VA_ARGS__);
+# define pass(...) ok(1, __VA_ARGS__)
+# define fail(...) ok(0, __VA_ARGS__)
 
 # define skip_start(test, n, ...)                      \
        do {                                            \
This page took 0.025911 seconds and 4 git commands to generate.