Skip to contentSkip to conversation

selfttests: timers ksft_ stubs handling changes

PATCH In review Shuah Khan 3 participants 7 messages Aug 10, 2017 – Aug 11, 2017

Subsystems (3)
lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

cover selfttests: timers ksft_ stubs handling changes

This patch series consists of changes to:

Move ksft_ stubs from individual tests into kselftest_stubs.h and change tests to include it.

Fix posix_timers and freq-step tests to run without ksft_ framework.

This is in preparation to convert timers tests to ksft TAP 13 format.

Question for John Stultz:

The conversion work will be easier without the requirement to be able to build and run these tests without ksft_ framework. So far the stubs are simpler. It is might be necessary to ifdef some code paths to have sane output for both KTEST and !KTEST cases.

Would it be easier to pull in kselftest.h into timers external repo (if one still exists). This is based on the observation that newer timer tests don't support !KTEST case e.g: posix_timers and freq-step.

Please review and let me know how you would like me to proceed with the conversion. I am looking for answer to how important is it to continue to support !KTEST case.

Shuah Khan (3):
selftests: timers: move ksft_ stubs from tests into kselftest_stubs.h
selftests: timers: posix_timers: fix to work without ksft framework
selftests: timers: freq-step: to work without ksft framework

 tools/testing/selftests/timers/adjtick.c           |  9 +--------
 .../testing/selftests/timers/alarmtimer-suspend.c  |  9 +--------
 tools/testing/selftests/timers/change_skew.c       |  9 +--------
 .../testing/selftests/timers/clocksource-switch.c  |  9 +--------
 tools/testing/selftests/timers/freq-step.c         |  4 ++++
 .../testing/selftests/timers/inconsistency-check.c |  9 +--------
 tools/testing/selftests/timers/kselftest_stubs.h   | 23 ++++++++++++++++++++++
 tools/testing/selftests/timers/leap-a-day.c        |  9 +--------
 tools/testing/selftests/timers/leapcrash.c         |  9 +--------
 tools/testing/selftests/timers/mqueue-lat.c        |  9 +--------
 tools/testing/selftests/timers/nanosleep.c         |  9 +--------
 tools/testing/selftests/timers/nsleep-lat.c        |  9 +--------
 tools/testing/selftests/timers/posix_timers.c      |  4 ++++
 tools/testing/selftests/timers/raw_skew.c          |  9 +--------
 tools/testing/selftests/timers/set-2038.c          |  9 +--------
 tools/testing/selftests/timers/set-tai.c           |  9 +--------
 tools/testing/selftests/timers/set-timer-lat.c     |  9 +--------
 tools/testing/selftests/timers/set-tz.c            |  9 +--------
 tools/testing/selftests/timers/skew_consistency.c  |  9 +--------
 tools/testing/selftests/timers/threadtest.c        |  9 +--------
 tools/testing/selftests/timers/valid-adjtimex.c    |  9 +--------
 21 files changed, 49 insertions(+), 144 deletions(-)
 create mode 100644 tools/testing/selftests/timers/kselftest_stubs.h
Signature · 1 line
2.11.0
author
#1 lore raw

PATCH 1/3 selftests: timers: move ksft_ stubs from tests into kselftest_stubs.h

Move ksft_ stubs from individual tests into kselftest_stubs.h and change tests to include it.

This change removes duplicate stubs from individual tests and gets them ready for converting them to Kselftest TAP13 API.

---
 tools/testing/selftests/timers/adjtick.c           |  9 +--------
 .../testing/selftests/timers/alarmtimer-suspend.c  |  9 +--------
 tools/testing/selftests/timers/change_skew.c       |  9 +--------
 .../testing/selftests/timers/clocksource-switch.c  |  9 +--------
 .../testing/selftests/timers/inconsistency-check.c |  9 +--------
 tools/testing/selftests/timers/kselftest_stubs.h   | 22 ++++++++++++++++++++++
 tools/testing/selftests/timers/leap-a-day.c        |  9 +--------
 tools/testing/selftests/timers/leapcrash.c         |  9 +--------
 tools/testing/selftests/timers/mqueue-lat.c        |  9 +--------
 tools/testing/selftests/timers/nanosleep.c         |  9 +--------
 tools/testing/selftests/timers/nsleep-lat.c        |  9 +--------
 tools/testing/selftests/timers/raw_skew.c          |  9 +--------
 tools/testing/selftests/timers/set-2038.c          |  9 +--------
 tools/testing/selftests/timers/set-tai.c           |  9 +--------
 tools/testing/selftests/timers/set-timer-lat.c     |  9 +--------
 tools/testing/selftests/timers/set-tz.c            |  9 +--------
 tools/testing/selftests/timers/skew_consistency.c  |  9 +--------
 tools/testing/selftests/timers/threadtest.c        |  9 +--------
 tools/testing/selftests/timers/valid-adjtimex.c    |  9 +--------
 19 files changed, 40 insertions(+), 144 deletions(-)
 create mode 100644 tools/testing/selftests/timers/kselftest_stubs.h
tools/testing/selftests/timers/adjtick.c +1 -8
index 9887fd538fec..a37e558bf919 100644
@@ -26,14 +26,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define CLOCK_MONOTONIC_RAW	4
tools/testing/selftests/timers/alarmtimer-suspend.c +1 -8
index 2b361b830395..e105beb757e0 100644
@@ -31,14 +31,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define CLOCK_REALTIME			0
tools/testing/selftests/timers/change_skew.c +1 -8
index cb1968977c04..1075f5f67ab7 100644
@@ -31,14 +31,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000LL
tools/testing/selftests/timers/clocksource-switch.c +1 -8
index 5ff165373f8b..65bac2e53370 100644
@@ -37,14 +37,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 
tools/testing/selftests/timers/inconsistency-check.c +1 -8
index 74c60e8759a0..db33d56f65e7 100644
@@ -31,14 +31,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define CALLS_PER_LOOP 64
tools/testing/selftests/timers/kselftest_stubs.h new file +22 -0
new file mode 100644
index 000000000000..9d2490f3932f
@@ -0,0 +1,22 @@
+/*
+ * kselftest_stubs.h:	kselftest framework stubs
+ *
+ * Copyright (c) 2017 Shuah Khan <[email protected]>
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * This file is released under the GPLv2.
+ *
+ * This is stub file for ksft_* API to continue to build timer tests
+ * without Kselftest framework.
+ */
+#ifndef __KSELFTEST_STUBS_H
+#define __KSELFTEST_STUBS_H
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+static inline int ksft_exit_pass(void) { exit(0); }
+static inline int ksft_exit_fail(void) { exit(1); }
+
+#endif /* __KSELFTEST__STUBS_H */
tools/testing/selftests/timers/leap-a-day.c +1 -8
index fb46ad6ac92c..5d51e9a21543 100644
@@ -51,14 +51,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000ULL
tools/testing/selftests/timers/leapcrash.c +1 -8
index a1071bdbdeb7..fa455dccd5e6 100644
@@ -25,14 +25,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 
tools/testing/selftests/timers/mqueue-lat.c +1 -8
index a2a3924d0b41..907a40b14cfb 100644
@@ -32,14 +32,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000ULL
tools/testing/selftests/timers/nanosleep.c +1 -8
index ff942ff7c9b3..ad58e07e3721 100644
@@ -30,14 +30,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000ULL
tools/testing/selftests/timers/nsleep-lat.c +1 -8
index 2d7898fda0f1..f61f9e9965ef 100644
@@ -27,14 +27,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000ULL
tools/testing/selftests/timers/raw_skew.c +1 -8
index 30906bfd9c1b..5689e3527eca 100644
@@ -28,14 +28,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 
tools/testing/selftests/timers/set-2038.c +1 -8
index c8a7e14446b1..22628309f5f0 100644
@@ -30,14 +30,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000LL
tools/testing/selftests/timers/set-tai.c +1 -8
index dc88dbc8831f..3c6114a02f22 100644
@@ -26,14 +26,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 int set_tai(int offset)
tools/testing/selftests/timers/set-timer-lat.c +1 -8
index 4fc98c5b0899..a0cabee22cb1 100644
@@ -30,14 +30,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define CLOCK_REALTIME			0
tools/testing/selftests/timers/set-tz.c +1 -8
index f4184928b16b..76137139870c 100644
@@ -26,14 +26,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 int set_tz(int min, int dst)
tools/testing/selftests/timers/skew_consistency.c +1 -8
index 2a996e072259..301ef86a2e16 100644
@@ -38,14 +38,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000LL
tools/testing/selftests/timers/threadtest.c +1 -8
index e632e116f05e..9b3529b795ac 100644
@@ -24,14 +24,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 
tools/testing/selftests/timers/valid-adjtimex.c +1 -8
index 60fe3c569bd9..78a43e40f6ef 100644
@@ -35,14 +35,7 @@
 #ifdef KTEST
 #include "../kselftest.h"
 #else
-static inline int ksft_exit_pass(void)
-{
-	exit(0);
-}
-static inline int ksft_exit_fail(void)
-{
-	exit(1);
-}
+#include "kselftest_stubs.h"
 #endif
 
 #define NSEC_PER_SEC 1000000000LL
Signature · 1 line
2.11.0
author
#2 lore raw

PATCH 2/3 selftests: timers: posix_timers: fix to work without ksft framework

In reply to Shuah Khan

Fix to build and run without ksft framework like the other timers tests.

---
 tools/testing/selftests/timers/posix_timers.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/testing/selftests/timers/posix_timers.c +4 -0
index 15cf56d32155..c6dc92c2dc12 100644
@@ -15,7 +15,11 @@
 #include <time.h>
 #include <pthread.h>
 
+#ifdef KTEST
 #include "../kselftest.h"
+#else
+#include "kselftest_stubs.h"
+#endif
 
 #define DELAY 2
 #define USECS_PER_SEC 1000000
Signature · 1 line
2.11.0
author
#3 lore raw

PATCH 3/3 selftests: timers: freq-step: to work without ksft framework

In reply to Shuah Khan

Fix to build and run without ksft framework like the other timers tests.

---
 tools/testing/selftests/timers/freq-step.c       | 4 ++++
 tools/testing/selftests/timers/kselftest_stubs.h | 1 +
 2 files changed, 5 insertions(+)
tools/testing/selftests/timers/freq-step.c +4 -0
index 22312eb4c941..a0438eb655c4 100644
@@ -23,7 +23,11 @@
 #include <time.h>
 #include <unistd.h>
 
+#ifdef KTEST
 #include "../kselftest.h"
+#else
+#include "kselftest_stubs.h"
+#endif
 
 #define SAMPLES 100
 #define SAMPLE_READINGS 10
tools/testing/selftests/timers/kselftest_stubs.h +1 -0
index 9d2490f3932f..62e3cd36b17d 100644
@@ -18,5 +18,6 @@
 
 static inline int ksft_exit_pass(void) { exit(0); }
 static inline int ksft_exit_fail(void) { exit(1); }
+static inline int ksft_exit_skip(const char *msg, ...) { exit(4); }
 
 #endif /* __KSELFTEST__STUBS_H */
Signature · 1 line
2.11.0
#4 lore raw
In reply to Shuah Khan
Quoted 16 lines · Shuah Khan

This patch series consists of changes to:

Move ksft_ stubs from individual tests into kselftest_stubs.h and change tests to include it.

Fix posix_timers and freq-step tests to run without ksft_ framework.

This is in preparation to convert timers tests to ksft TAP 13 format.

Question for John Stultz:

The conversion work will be easier without the requirement to be able to build and run these tests without ksft_ framework. So far the stubs are simpler. It is might be necessary to ifdef some code paths to have sane output for both KTEST and !KTEST cases.

Quoted 7 lines

Would it be easier to pull in kselftest.h into timers external repo (if one still exists). This is based on the observation that newer timer tests don't support !KTEST case e.g: posix_timers and freq-step.

Please review and let me know how you would like me to proceed with the conversion. I am looking for answer to how important is it to continue to support !KTEST case.

Yea. I'm thinking at this point I'm fine with dropping the attempt to keep kselftest and my external timekeeping tests in sync.

Though something that might be nice however is having some place that keeps tarball releases of kselftest around? As it would make pulling tests onto a target machine a bit easier. Does that already exist?

thanks
-john

maintainer
#5 lore raw
Quoted 21 lines · John Stultz
Quoted 20 lines · Shuah Khan

This patch series consists of changes to:

Move ksft_ stubs from individual tests into kselftest_stubs.h and change tests to include it.

Fix posix_timers and freq-step tests to run without ksft_ framework.

This is in preparation to convert timers tests to ksft TAP 13 format.

Question for John Stultz:

The conversion work will be easier without the requirement to be able to build and run these tests without ksft_ framework. So far the stubs are simpler. It is might be necessary to ifdef some code paths to have sane output for both KTEST and !KTEST cases.

Would it be easier to pull in kselftest.h into timers external repo (if one still exists). This is based on the observation that newer timer tests don't support !KTEST case e.g: posix_timers and freq-step.

Quoted 6 lines
Quoted 3 lines

Please review and let me know how you would like me to proceed with the conversion. I am looking for answer to how important is it to continue to support !KTEST case.

Yea. I'm thinking at this point I'm fine with dropping the attempt to keep kselftest and my external timekeeping tests in sync.

Would you like me to clean !KTEST support or leave it the way it is. It sounds like, I will drop these patches anyway.

Quoted 5 lines

Though something that might be nice however is having some place that keeps tarball releases of kselftest around? As it would make pulling tests onto a target machine a bit easier. Does that already exist?

There is an install script tools/testing/selftests/gen_kselftest_tar.sh for generating tar-ball for compiled tests at the moment. There is none for source package.

thanks,
-- Shuah

#6 lore raw
Quoted 26 lines · Shuah Khan
Quoted 25 lines · John Stultz
Quoted 23 lines · Shuah Khan

This patch series consists of changes to:

Move ksft_ stubs from individual tests into kselftest_stubs.h and change tests to include it.

Fix posix_timers and freq-step tests to run without ksft_ framework.

This is in preparation to convert timers tests to ksft TAP 13 format.

Question for John Stultz:

The conversion work will be easier without the requirement to be able to build and run these tests without ksft_ framework. So far the stubs are simpler. It is might be necessary to ifdef some code paths to have sane output for both KTEST and !KTEST cases.

Would it be easier to pull in kselftest.h into timers external repo (if one still exists). This is based on the observation that newer timer tests don't support !KTEST case e.g: posix_timers and freq-step.

Please review and let me know how you would like me to proceed with the conversion. I am looking for answer to how important is it to continue to support !KTEST case.

Quoted 5 lines
Quoted 2 lines

Yea. I'm thinking at this point I'm fine with dropping the attempt to keep kselftest and my external timekeeping tests in sync.

Would you like me to clean !KTEST support or leave it the way it is. It sounds like, I will drop these patches anyway.

Yea. I think its ok to drop !KTEST.

thanks
-john