2017-08-10 23:53:32

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 0/3] 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

--
2.11.0


2017-08-10 23:53:31

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 2/3] selftests: timers: posix_timers: fix to work without ksft framework

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

Signed-off-by: Shuah Khan <[email protected]>
---
tools/testing/selftests/timers/posix_timers.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c
index 15cf56d32155..c6dc92c2dc12 100644
--- a/tools/testing/selftests/timers/posix_timers.c
+++ b/tools/testing/selftests/timers/posix_timers.c
@@ -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
--
2.11.0

2017-08-10 23:53:30

by Shuah Khan

[permalink] [raw]
Subject: [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.

Signed-off-by: Shuah Khan <[email protected]>
---
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

diff --git a/tools/testing/selftests/timers/adjtick.c b/tools/testing/selftests/timers/adjtick.c
index 9887fd538fec..a37e558bf919 100644
--- a/tools/testing/selftests/timers/adjtick.c
+++ b/tools/testing/selftests/timers/adjtick.c
@@ -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
diff --git a/tools/testing/selftests/timers/alarmtimer-suspend.c b/tools/testing/selftests/timers/alarmtimer-suspend.c
index 2b361b830395..e105beb757e0 100644
--- a/tools/testing/selftests/timers/alarmtimer-suspend.c
+++ b/tools/testing/selftests/timers/alarmtimer-suspend.c
@@ -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
diff --git a/tools/testing/selftests/timers/change_skew.c b/tools/testing/selftests/timers/change_skew.c
index cb1968977c04..1075f5f67ab7 100644
--- a/tools/testing/selftests/timers/change_skew.c
+++ b/tools/testing/selftests/timers/change_skew.c
@@ -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
diff --git a/tools/testing/selftests/timers/clocksource-switch.c b/tools/testing/selftests/timers/clocksource-switch.c
index 5ff165373f8b..65bac2e53370 100644
--- a/tools/testing/selftests/timers/clocksource-switch.c
+++ b/tools/testing/selftests/timers/clocksource-switch.c
@@ -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


diff --git a/tools/testing/selftests/timers/inconsistency-check.c b/tools/testing/selftests/timers/inconsistency-check.c
index 74c60e8759a0..db33d56f65e7 100644
--- a/tools/testing/selftests/timers/inconsistency-check.c
+++ b/tools/testing/selftests/timers/inconsistency-check.c
@@ -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
diff --git a/tools/testing/selftests/timers/kselftest_stubs.h b/tools/testing/selftests/timers/kselftest_stubs.h
new file mode 100644
index 000000000000..9d2490f3932f
--- /dev/null
+++ b/tools/testing/selftests/timers/kselftest_stubs.h
@@ -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 */
diff --git a/tools/testing/selftests/timers/leap-a-day.c b/tools/testing/selftests/timers/leap-a-day.c
index fb46ad6ac92c..5d51e9a21543 100644
--- a/tools/testing/selftests/timers/leap-a-day.c
+++ b/tools/testing/selftests/timers/leap-a-day.c
@@ -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
diff --git a/tools/testing/selftests/timers/leapcrash.c b/tools/testing/selftests/timers/leapcrash.c
index a1071bdbdeb7..fa455dccd5e6 100644
--- a/tools/testing/selftests/timers/leapcrash.c
+++ b/tools/testing/selftests/timers/leapcrash.c
@@ -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


diff --git a/tools/testing/selftests/timers/mqueue-lat.c b/tools/testing/selftests/timers/mqueue-lat.c
index a2a3924d0b41..907a40b14cfb 100644
--- a/tools/testing/selftests/timers/mqueue-lat.c
+++ b/tools/testing/selftests/timers/mqueue-lat.c
@@ -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
diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c
index ff942ff7c9b3..ad58e07e3721 100644
--- a/tools/testing/selftests/timers/nanosleep.c
+++ b/tools/testing/selftests/timers/nanosleep.c
@@ -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
diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/selftests/timers/nsleep-lat.c
index 2d7898fda0f1..f61f9e9965ef 100644
--- a/tools/testing/selftests/timers/nsleep-lat.c
+++ b/tools/testing/selftests/timers/nsleep-lat.c
@@ -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
diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
index 30906bfd9c1b..5689e3527eca 100644
--- a/tools/testing/selftests/timers/raw_skew.c
+++ b/tools/testing/selftests/timers/raw_skew.c
@@ -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


diff --git a/tools/testing/selftests/timers/set-2038.c b/tools/testing/selftests/timers/set-2038.c
index c8a7e14446b1..22628309f5f0 100644
--- a/tools/testing/selftests/timers/set-2038.c
+++ b/tools/testing/selftests/timers/set-2038.c
@@ -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
diff --git a/tools/testing/selftests/timers/set-tai.c b/tools/testing/selftests/timers/set-tai.c
index dc88dbc8831f..3c6114a02f22 100644
--- a/tools/testing/selftests/timers/set-tai.c
+++ b/tools/testing/selftests/timers/set-tai.c
@@ -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)
diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
index 4fc98c5b0899..a0cabee22cb1 100644
--- a/tools/testing/selftests/timers/set-timer-lat.c
+++ b/tools/testing/selftests/timers/set-timer-lat.c
@@ -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
diff --git a/tools/testing/selftests/timers/set-tz.c b/tools/testing/selftests/timers/set-tz.c
index f4184928b16b..76137139870c 100644
--- a/tools/testing/selftests/timers/set-tz.c
+++ b/tools/testing/selftests/timers/set-tz.c
@@ -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)
diff --git a/tools/testing/selftests/timers/skew_consistency.c b/tools/testing/selftests/timers/skew_consistency.c
index 2a996e072259..301ef86a2e16 100644
--- a/tools/testing/selftests/timers/skew_consistency.c
+++ b/tools/testing/selftests/timers/skew_consistency.c
@@ -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
diff --git a/tools/testing/selftests/timers/threadtest.c b/tools/testing/selftests/timers/threadtest.c
index e632e116f05e..9b3529b795ac 100644
--- a/tools/testing/selftests/timers/threadtest.c
+++ b/tools/testing/selftests/timers/threadtest.c
@@ -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


diff --git a/tools/testing/selftests/timers/valid-adjtimex.c b/tools/testing/selftests/timers/valid-adjtimex.c
index 60fe3c569bd9..78a43e40f6ef 100644
--- a/tools/testing/selftests/timers/valid-adjtimex.c
+++ b/tools/testing/selftests/timers/valid-adjtimex.c
@@ -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
--
2.11.0

2017-08-10 23:53:29

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 3/3] selftests: timers: freq-step: to work without ksft framework

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

Signed-off-by: Shuah Khan <[email protected]>
---
tools/testing/selftests/timers/freq-step.c | 4 ++++
tools/testing/selftests/timers/kselftest_stubs.h | 1 +
2 files changed, 5 insertions(+)

diff --git a/tools/testing/selftests/timers/freq-step.c b/tools/testing/selftests/timers/freq-step.c
index 22312eb4c941..a0438eb655c4 100644
--- a/tools/testing/selftests/timers/freq-step.c
+++ b/tools/testing/selftests/timers/freq-step.c
@@ -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
diff --git a/tools/testing/selftests/timers/kselftest_stubs.h b/tools/testing/selftests/timers/kselftest_stubs.h
index 9d2490f3932f..62e3cd36b17d 100644
--- a/tools/testing/selftests/timers/kselftest_stubs.h
+++ b/tools/testing/selftests/timers/kselftest_stubs.h
@@ -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 */
--
2.11.0

2017-08-11 00:10:59

by John Stultz

[permalink] [raw]
Subject: Re: [PATCH 0/3] selfttests: timers ksft_ stubs handling changes

On Thu, Aug 10, 2017 at 4:53 PM, Shuah Khan <[email protected]> wrote:
> 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.

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

2017-08-11 00:51:15

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 0/3] selfttests: timers ksft_ stubs handling changes

On 08/10/2017 06:10 PM, John Stultz wrote:
> On Thu, Aug 10, 2017 at 4:53 PM, Shuah Khan <[email protected]> wrote:
>> 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.
>
> 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.

>
> 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

2017-08-11 00:57:45

by John Stultz

[permalink] [raw]
Subject: Re: [PATCH 0/3] selfttests: timers ksft_ stubs handling changes

On Thu, Aug 10, 2017 at 5:51 PM, Shuah Khan <[email protected]> wrote:
> On 08/10/2017 06:10 PM, John Stultz wrote:
>> On Thu, Aug 10, 2017 at 4:53 PM, Shuah Khan <[email protected]> wrote:
>>> 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.
>>
>> 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