[LTP] [PATCH COMMITTED] settimeofday01: make sure tv_usec < USEC_PER_SEC
Jan Stancek
jstancek@redhat.com
Thu Aug 9 10:35:44 CEST 2018
Kernel checks for this and reports EINVAL, which causes
test to rarely fail:
if (!timeval_valid(&user_tv))
return -EINVAL;
Fixes: 9ba1051fbe29 ("settimeofday01: fix for linux kernel >= 4.2")
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/settimeofday/settimeofday01.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/testcases/kernel/syscalls/settimeofday/settimeofday01.c b/testcases/kernel/syscalls/settimeofday/settimeofday01.c
index c68fb37eb0f7..7388c3231aaa 100644
--- a/testcases/kernel/syscalls/settimeofday/settimeofday01.c
+++ b/testcases/kernel/syscalls/settimeofday/settimeofday01.c
@@ -64,6 +64,7 @@
#define VAL_SEC 100
#define VAL_MSEC 100
#define ACCEPTABLE_DELTA 500 /* in milli-seconds */
+#define USEC_PER_SEC 1000000L
char *TCID = "settimeofday01";
int TST_TOTAL = 1;
@@ -92,6 +93,8 @@ int main(int argc, char **argv)
gettimeofday(&tp, NULL);
tp.tv_sec += VAL_SEC;
tp.tv_usec += VAL_MSEC;
+ if (tp.tv_usec >= USEC_PER_SEC)
+ tp.tv_usec = VAL_MSEC;
TEST(settimeofday(&tp, NULL));
if (TEST_RETURN == -1) {
--
1.8.3.1
More information about the ltp
mailing list