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 <shuahkh@xxxxxxxxxxxxxxx> --- 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 <shuahkh@xxxxxxxxxxxxxxx> + * 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html