[LTP] [PATCH v8 4/4] Extend ioctl02 to test termio and termios

iob ybonatakis@suse.com
Thu Oct 26 08:34:58 CEST 2023


Petr Vorel <pvorel@suse.cz> writes:

> Hi Marius
>
> ...
>> -	if (termio.c_iflag != (BRKINT | IGNPAR | INPCK | ISTRIP
>> -		 | ICRNL | IUCLC | IXON | IXANY | IXOFF)) {
>> -		tst_res(TFAIL, "iflag has incorrect value. %o",
>> -			 termio.c_iflag);
>> -		flag++;
>
>> +#define CMP_ATTR(tcexp, tcval, attr) \
>> +	do { \
>> +		if ((tcval).attr != (tcexp).attr) { \
>> +			tst_res(TINFO, #attr " has incorrect value %o", \
>> +				(tcval).attr); \
>> +			flag++; \
>> +		} \
>> +	} while (0)
>> +
>> +#define CECK_CONTROL_CHARS(tcval) \
Was this meant to named as CHECK_CONTROL_CHARS?


>> +	for (i = 0; i < NCC; i++) { \
>> +		if (i == VEOL2) { \
>> +			if (!(tcval).c_cc[i]) { \
>> +				continue; \
>> +			} else { \
>> +				tst_res(TFAIL, "control char %d has " \
>> +					 "incorrect value %d", i, (tcval).c_cc[i]); \
>> +				flag++; \
>> +				continue; \
>> +			} \
>> +		} \
>> +		if ((tcval).c_cc[i] != CSTART) { \
>> +			tst_res(TFAIL, "control char %d has incorrect " \
>> +				 "value %d.", i, (tcval).c_cc[i]); \
>> +			flag++; \
>> +		} \
>>  	}
>
> Could be this written as a function? Or what is the benefit of it?  Because
> readability suffers. (We prefer avoid macros, tst_test_macros.h is the exception
> due using kernel syscalls, but readability also suffers).
>
> I know you mentioned C++ in cover letter, but please no C++ :).
>
> Kind regards,
> Petr


-- 
Sent with my mu4e


More information about the ltp mailing list