[LTP] [PATCH v2 02/10] syscalls/ioctl:add common c file for loop ioctl

Yang Xu xuyang2018.jy@cn.fujitsu.com
Mon Apr 20 04:23:48 CEST 2020


Hi Cyril


> Hi!
>> +/*
>> + * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
>> + * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> + */
>> +#define TST_NO_DEFAULT_MAIN
>> +#include "ioctl_loop_support.h"
>> +#include "tst_test.h"
>> +
>> +void check_sys_value(char *path, int setvalue)
>> +{
>> +	int getvalue;
>> +
>> +	SAFE_FILE_SCANF(path, "%d", &getvalue);
>> +	if (setvalue == getvalue)
>> +		tst_res(TPASS, "%s value is %d", path, setvalue);
>> +	else
>> +		tst_res(TFAIL, "%s value expected %d got %d", path, setvalue, getvalue);
>> +}
>> +
>> +void check_sys_string(char *path, char *setmessage)
>> +{
>> +	char getmessage[1024];
>> +
>> +	SAFE_FILE_SCANF(path, "%s", getmessage);
>> +	if (strcmp(setmessage, getmessage))
>> +		tst_res(TFAIL, "%s expected %s got %s", path, setmessage, getmessage);
>> +	else
>> +		tst_res(TPASS, "%s string is %s", path, getmessage);
>> +}
> 
> In the end I've renamed and moved these functions into the test library
> because the functionality is generic enough and I doubt that these
> tests would be the only one using it.
That's great.  I remember prctl cases use this function. Also, in some 
cap cases, it needs bitwise operators(I only know prctl08.c). Maybe we 
can add TST_ASSERT_BITWISE?
> 




More information about the ltp mailing list