public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] acct02: relax ac_btime checks
@ 2019-11-12  9:15 Jan Stancek
  2019-11-12 12:37 ` Petr Vorel
  2019-11-13  9:25 ` Cyril Hrubis
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Stancek @ 2019-11-12  9:15 UTC (permalink / raw)
  To: ltp

ac_btime is calculated back from current time and isn't accurate.
Problems include nanoseconds accumulation (lags behind gettimeofday),
suspend/resume isn't taken into account and any adjtime() (like DST
change) will cause ac_btime to jump as well.

Relax the condition to ~2h around gettimeofday value at start of
the test. That should be enough to cover usual DST time jumps.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/acct/acct02.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index 890568b08774..2f1290fa287f 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -74,7 +74,8 @@ static int verify_acct(void *acc, int elap_time)
 {
 	int sys_time  = UNPACK(ACCT_MEMBER(ac_stime));
 	int user_time = UNPACK(ACCT_MEMBER(ac_stime));
-	int ret = 0, tmp;
+	unsigned int btime_diff;
+	int ret = 0;
 	float tmp2;
 
 	if (strcmp(ACCT_MEMBER(ac_comm), COMMAND)) {
@@ -83,15 +84,13 @@ static int verify_acct(void *acc, int elap_time)
 		ret = 1;
 	}
 
-	if (ACCT_MEMBER(ac_btime) < start_time) {
-		tst_res(TINFO, "ac_btime < %d (%d)", start_time,
-			ACCT_MEMBER(ac_btime));
-		ret = 1;
-	}
+	if (start_time > ACCT_MEMBER(ac_btime))
+		btime_diff = start_time - ACCT_MEMBER(ac_btime);
+	else
+		btime_diff = ACCT_MEMBER(ac_btime) - start_time;
 
-	tmp = ACCT_MEMBER(ac_btime) - start_time;
-	if (tmp > 1) {
-		tst_res(TINFO, "ac_btime - %d > 1 (%d)", start_time, tmp);
+	if (btime_diff > 7200) {
+		tst_res(TINFO, "ac_btime_diff %u", btime_diff);
 		ret = 1;
 	}
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-13 20:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-12  9:15 [LTP] [PATCH] acct02: relax ac_btime checks Jan Stancek
2019-11-12 12:37 ` Petr Vorel
2019-11-12 12:52   ` Jan Stancek
2019-11-12 13:30     ` Petr Vorel
2019-11-13  9:25 ` Cyril Hrubis
2019-11-13 20:08   ` Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox