public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 3/3] syscalls/clock_adjtime: create clock_adjtime syscall tests
Date: Thu, 21 Mar 2019 14:54:32 +0100	[thread overview]
Message-ID: <20190321135432.GD1252@rei> (raw)
In-Reply-To: <20190320214135.7029-3-rafael.tinoco@linaro.org>

Hi!
This test fails for me and clock_adjtime() returns 5 (TIME_ERROR) for me.

Looks like the SAFE_ADJTIME() should fail only on rval < 0 and return the rval
too so that we can possibly make use of the return value, the test passes for
me with:

diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h
index a952be4bf..f7776a548 100644
--- a/include/tst_safe_clocks.h
+++ b/include/tst_safe_clocks.h
@@ -46,16 +46,18 @@ static inline void safe_clock_settime(const char *file, const int lineno,
                        "%s:%d clock_gettime() failed", file, lineno);
 }
 
-static inline void safe_clock_adjtime(const char *file, const int lineno,
+static inline int safe_clock_adjtime(const char *file, const int lineno,
        clockid_t clk_id, struct timex *txc)
 {
        int rval;
 
        rval = tst_syscall(__NR_clock_adjtime, clk_id, txc);
 
-       if (rval != 0)
+       if (rval < 0)
                tst_brk(TBROK | TERRNO,
-                       "%s:%d clock_adjtime() failed", file, lineno);
+                       "%s:%d clock_adjtime() failed %i", file, lineno, rval);
+
+       return rval;
 }


Also we should restore the adjtimex only if we actually managed to save it,
with something as:

diff --git a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c
index 48cfbe6c5..6eb823387 100644
--- a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c
+++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c
@@ -58,6 +58,7 @@
 
 static long hz;
 static struct timex saved, ttxc;
+static int clock_saved;
 
 struct test_case {
        unsigned int modes;
@@ -165,10 +166,13 @@ static void verify_clock_adjtime(unsigned int i)
 static void setup(void)
 {
        size_t i;
+       int rval;
 
        /* save original clock flags */
 
-       SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved);
+       rval = SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved);
+       clock_saved = 1;
+       tst_res(TINFO, "clock_adjtime() = %i", rval);
 
        hz = SAFE_SYSCONF(_SC_CLK_TCK);
 
@@ -203,7 +207,8 @@ static void cleanup(void)
 
        /* restore original clock flags */
 
-       SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved);
+       if (clock_saved)
+               SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved);
 }
 
 static struct tst_test test = {


-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2019-03-21 13:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 20:05 [LTP] [PATCH 1/2] lib: include SAFE_CLOCK_ADJTIME() macro Rafael David Tinoco
2019-02-21 20:05 ` [LTP] [PATCH 2/2] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-02-21 20:19   ` Rafael David Tinoco
2019-02-21 20:30   ` [LTP] [PATCH v2 1/2] lib: include SAFE_CLOCK_ADJTIME() macro Rafael David Tinoco
2019-02-21 20:30     ` [LTP] [PATCH v2 2/2] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-02-26  0:17       ` Petr Vorel
2019-02-26  0:24         ` Enji Cooper
2019-02-26 16:08         ` [LTP] [PATCH v3 1/2] lib: include SAFE_CLOCK_ADJTIME() macro Rafael David Tinoco
2019-02-26 16:08           ` [LTP] [PATCH v3 2/2] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-03-13 16:32             ` Cyril Hrubis
2019-03-15 11:07               ` Rafael David Tinoco
2019-03-20 21:41               ` [LTP] [PATCH v2 1/3] lib: include SAFE_CLOCK_ADJTIME() macro Rafael David Tinoco
2019-03-20 21:41                 ` [LTP] [PATCH v2 2/3] lapi/posix_clocks.h: add MAX_CLOCKS definition Rafael David Tinoco
2019-03-20 21:41                 ` [LTP] [PATCH v2 3/3] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-03-20 21:48                   ` Rafael David Tinoco
2019-03-21 13:42                     ` Cyril Hrubis
2019-03-21 13:57                       ` Rafael David Tinoco
2019-03-21 14:05                         ` Cyril Hrubis
2019-03-21 14:10                           ` Cyril Hrubis
2019-03-21 14:17                             ` Rafael David Tinoco
2019-03-21 20:27                             ` [LTP] [PATCH v3 1/4] lib: include SAFE_CLOCK_ADJTIME() macro Rafael David Tinoco
2019-03-21 20:27                               ` [LTP] [PATCH v3 2/4] lib: Add include guard to tst_safe_clocks.h Rafael David Tinoco
2019-03-21 20:27                               ` [LTP] [PATCH v3 3/4] lapi/posix_clocks.h: add MAX_CLOCKS definition Rafael David Tinoco
2019-03-21 20:27                               ` [LTP] [PATCH v3 4/4] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-03-21 20:31                                 ` Rafael David Tinoco
2019-03-22 13:34                                   ` Cyril Hrubis
2019-03-22 13:36                                     ` Rafael David Tinoco
2019-03-22 18:25                                     ` [LTP] [PATCH v4 1/4] lib: include SAFE_CLOCK_ADJTIME() macro Rafael David Tinoco
2019-03-22 18:25                                       ` [LTP] [PATCH v4 2/4] lib: Add include guard to tst_safe_clocks.h Rafael David Tinoco
2019-03-22 18:25                                       ` [LTP] [PATCH v4 3/4] lapi/posix_clocks.h: add MAX_CLOCKS definition Rafael David Tinoco
2019-03-22 18:25                                       ` [LTP] [PATCH v4 4/4] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-03-25 16:24                                       ` [LTP] [PATCH v4 1/4] lib: include SAFE_CLOCK_ADJTIME() macro Cyril Hrubis
2019-03-21 13:54                   ` Cyril Hrubis [this message]
2019-03-21 14:00                     ` [LTP] [PATCH v2 3/3] syscalls/clock_adjtime: create clock_adjtime syscall tests Rafael David Tinoco
2019-03-21 14:06                       ` Cyril Hrubis
2019-03-13 16:09           ` [LTP] [PATCH v3 1/2] lib: include SAFE_CLOCK_ADJTIME() macro Cyril Hrubis
2019-03-13 16:26             ` Rafael David Tinoco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190321135432.GD1252@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox