[LTP] [PATCH] lib/tst_wallclock.c: Add check for unsupported CLOCK_MONOTONIC_RAW

Xiao Yang yangx.jy@cn.fujitsu.com
Fri Apr 5 08:30:48 CEST 2019


CLOCK_MONOTONIC_RAW was introduced since kernel v2.6.28, so we want
TCONF instead of TBROK if CLOCK_MONOTONIC_RAW wasn't supported on
older kernels.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 lib/tst_wallclock.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/tst_wallclock.c b/lib/tst_wallclock.c
index f1c96c0..282d6ad 100644
--- a/lib/tst_wallclock.c
+++ b/lib/tst_wallclock.c
@@ -25,8 +25,14 @@ void tst_wallclock_save(void)
 	if (tst_clock_gettime(CLOCK_REALTIME, &real_begin))
 		tst_brk(TBROK | TERRNO, "tst_clock_gettime() realtime failed");
 
-	if (tst_clock_gettime(CLOCK_MONOTONIC_RAW, &mono_begin))
+	if (tst_clock_gettime(CLOCK_MONOTONIC_RAW, &mono_begin)) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"tst_clock_gettime() didn't support CLOCK_MONOTONIC_RAW");
+		}
+
 		tst_brk(TBROK | TERRNO, "tst_clock_gettime() monotonic failed");
+	}
 
 	clock_saved = 1;
 }
-- 
1.7.11.rc0





More information about the ltp mailing list