[LTP] [PATCH] syscalls/clock_settime03: Fix testcases have been waiting, timeout failure

zhanglianjie zhanglianjie@uniontech.com
Thu Mar 10 13:47:35 CET 2022


Hi,

On 2022/3/9 21:25, Cyril Hrubis wrote:
> Hi!
>> If the system enables auto-synchronization time configuration,
>> this test case will wait until the timeout. Therefore,
>> the automatic synchronization time configuration of the system needs to be turned off in the setup phase.
>>
>> message:
>> tst_test.c:1457: TINFO: Timeout per run is 0h 05m 00s
>> clock_settime03.c:35: TINFO: Testing variant: syscall with old kernel spec
>> tst_test.c:1506: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
>> tst_test.c:1507: TBROK: Test killed! (timeout?)
>>
>> Signed-off-by: zhanglianjie <zhanglianjie@uniontech.com>
>>
>> diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime03.c b/testcases/kernel/syscalls/clock_settime/clock_settime03.c
>> index f196a257c..e783f1d3f 100644
>> --- a/testcases/kernel/syscalls/clock_settime/clock_settime03.c
>> +++ b/testcases/kernel/syscalls/clock_settime/clock_settime03.c
>> @@ -14,9 +14,11 @@
>>
>>   #define TIMER_DELTA	3
>>   #define ALLOWED_DELTA	(50 * 1000) /* 50 ms */
>> +#define BUFF_SIZE PATH_MAX
>>
>>   static struct tst_ts start, end;
>>   static struct tst_its its;
>> +static char cmd[BUFF_SIZE];
>>
>>   static struct time64_variants variants[] = {
>>   #if (__NR_clock_settime != __LTP__NR_INVALID_SYSCALL)
>> @@ -31,6 +33,7 @@ static struct time64_variants variants[] = {
>>   static void setup(void)
>>   {
>>   	struct time64_variants *tv = &variants[tst_variant];
>> +	int ret;
>>
>>   	tst_res(TINFO, "Testing variant: %s", tv->desc);
>>   	start.type = end.type = its.type = tv->ts_type;
>> @@ -40,6 +43,11 @@ static void setup(void)
>>   	    sizeof(start.ts.kern_old_ts.tv_sec) == 4) {
>>   		tst_brk(TCONF, "Not Y2038 safe to run test");
>>   	}
>> +
>> +	snprintf(cmd, sizeof(cmd), "timedatectl set-ntp false");
> 
> There is no reason to print the command into a temporary buffer.
> 
>> +	ret = tst_system(cmd);
>> +	if (ret)
>> +		tst_brk(TBROK | TST_ERR, "failed to timedatectl set-ntp");
> 
> And this is certainly wrong too.
> 
> - The TST_ERR is not correct flag to be passed to tst_brk().
> 
> - The test must continue even if the timedatectl is not present on the
>    system, otherwise the test will be broken on systems without systemd
> 
> So at least we shouldn't exit the test if the tst_system() returned
> command-not-found.
Thank you for your review, I have already submitted V2.

> 
>>   }
>>
>>   static void run(void)
>> @@ -109,4 +117,8 @@ static struct tst_test test = {
>>   	.setup = setup,
>>   	.needs_root = 1,
>>   	.restore_wallclock = 1,
>> +	.needs_cmds = (const char *[]) {
>> +		"timedatectl",
>> +		NULL
>> +	},
> 
> And this is wrong too, again the test should be able to run on systems
> without systemd.
> 
>>   };
>> --
>> 2.20.1
>>
>>
>>
>>
>> -- 
>> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

-- 
Kind regards,
Lianjie




More information about the ltp mailing list