acct02: relax ac_btime checks
PATCH 1/1 acct02: relax ac_btime checks
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.
--- testcases/kernel/syscalls/acct/acct02.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
testcases/kernel/syscalls/acct/acct02.c +8 -9
@@ -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 ; }
Signature · 1 line
1.8.3.1
PATCH 1/1 acct02: relax ac_btime checks
Hi Jan,
Quoted 9 lines
ac_btimeis calculated back from current time and isn't accurate. Problems include nanoseconds accumulation (lags behind gettimeofday), suspend/resume isn't taken into account and anyadjtime()(like DST change) will causeac_btimeto 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 <[email protected]>
on both 390x and intel.
LGTM, although on in intel I got quite a lot of entries:
acct02.c:202: INFO: Number of accounting file entries tested: 159
Quoted 9 lines
--- testcases/kernel/syscalls/acct/acct02.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)testcases/kernel/syscalls/acct/acct02.c +0
-0
testcases/kernel/syscalls/acct/acct02.c static int verify_acct(void *acc, int elap_time) · line 79
Quoted 7 lines
testcases/kernel/syscalls/acct/acct02.c +2
-1@@ -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;
We could rename tmp2 to tmp (but understand if you don't want to bother with it).
Quoted 9 lines
testcases/kernel/syscalls/acct/acct02.c +0
-4if (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 ;
testcases/kernel/syscalls/acct/acct02.c static int verify_acct(void *acc, int elap_time) · line 92
Quoted 10 lines
testcases/kernel/syscalls/acct/acct02.c +5
-4- } +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 ) {
IMHO It's probably obvious that it's time in seconds without digging in git, so we don't have to bother with a constant definition.
testcases/kernel/syscalls/acct/acct02.c static int verify_acct(void *acc, int elap_time) · line 95
Quoted 3 lines
testcases/kernel/syscalls/acct/acct02.c +1
-0+tst_res (TINFO ,"ac_btime_diff %u" , btime_diff); ret =1 ; }
Kind regards,
Petr
PATCH 1/1 acct02: relax ac_btime checks
----- Original Message -----
Quoted 10 lines
Hi Jan,
Quoted 7 lines
ac_btimeis calculated back from current time and isn't accurate. Problems include nanoseconds accumulation (lags behind gettimeofday), suspend/resume isn't taken into account and anyadjtime()(like DST change) will causeac_btimeto 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.
Quoted 8 lines
Quoted 1 line
Signed-off-by Jan Stancek <[email protected]>Reviewed-by Petr Vorel <[email protected]>Tested-by Petr Vorel <[email protected]>on both 390x and intel.
LGTM, although on in intel I got quite a lot of entries:
acct02.c:202: INFO: Number of accounting file entries tested: 159
That could be normal if there was something running in the background. Do you have full output? What was the ac_comm string in those entries?
PATCH 1/1 acct02: relax ac_btime checks
Hi Jan,
Quoted 13 lines
Quoted 12 lines
Quoted 9 lines
ac_btimeis calculated back from current time and isn't accurate. Problems include nanoseconds accumulation (lags behind gettimeofday), suspend/resume isn't taken into account and anyadjtime()(like DST change) will causeac_btimeto 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 <[email protected]>Reviewed-by Petr Vorel <[email protected]>Tested-by Petr Vorel <[email protected]>on both 390x and intel.
Quoted 6 lines
Quoted 3 lines
LGTM, although on in intel I got quite a lot of entries:
acct02.c:202: INFO: Number of accounting file entries tested: 159
That could be normal if there was something running in the background. Do you have full output? What was the
ac_commstring in those entries?
OK, this is caused only by compiling LTP on background. Thus not relevant to us.
Just if you're curious, sending part of output with 530 entries.
Kind regards,
Petr
tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1215: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:238: INFO: Verifying using 'struct acct_v3' acct02.c:191: INFO: == entry 1 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('cc1') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (256) acct02.c:139: INFO: ac_ppid != 755 (760) acct02.c:191: INFO: == entry 2 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('gcc') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (256) acct02.c:139: INFO: ac_ppid != 755 (759) acct02.c:191: INFO: == entry 3 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (256) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 4 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('grep') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 5 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('cat') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 6 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('mv') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 7 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('sed') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 8 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('rm') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 9 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('grep') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (768) acct02.c:191: INFO: == entry 10 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393) acct02.c:191: INFO: == entry 11 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393)
...
acct02.c:191: INFO: == entry 522 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (1285)
acct02.c:191: INFO: == entry 523 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('cat') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393)
acct02.c:191: INFO: == entry 524 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (1290)
acct02.c:191: INFO: == entry 525 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('sed') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (1292)
acct02.c:191: INFO: == entry 526 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (1290)
acct02.c:191: INFO: == entry 527 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('configure') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393)
acct02.c:191: INFO: == entry 528 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('cat') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393)
acct02.c:191: INFO: == entry 529 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('rm') acct02.c:98: INFO: ac_uid != 0 (1000)
acct02.c:104: INFO: ac_gid != 0 (100)
acct02.c:131: INFO: ac_exitcode != 32768 (0) acct02.c:139: INFO: ac_ppid != 755 (393)
acct02.c:191: INFO: == entry 530 ==
acct02.c:202: INFO: Number of accounting file entries tested: 530 acct02.c:208: PASS: acct() wrote correct file contents!
Summary:
passed 1 failed 0 skipped 0
warnings 0
PATCH 1/1 acct02: relax ac_btime checks
In reply to Jan StancekHi!
Looks good, acked as well.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 acct02: relax ac_btime checks
----- Original Message -----
Quoted 2 lines
Hi!
Looks good, acked as well.
Pushed.