[LTP] [PATCH v3 1/2] lib: TST_EXP_FAIL_PTR

Petr Vorel pvorel@suse.cz
Tue Jan 30 13:20:04 CET 2024


Hi Wei, Cyril,


> Hi!
> > +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNOS, ERRNOS_CNT, ...)       \
> > +	do {                                                                   \
> > +		TESTPTR(SCALL);                                                \
> > +		                                                               \
> > +		TST_PASS = 0;                                                  \
> > +		                                                               \
> > +		if (TST_RET_PTR) {                                             \

> Unfortunatelly there are two types of calls, one returns NULL on a
> failure and the second returns (void *)-1, from the top of my head these
> are mmap(), shmat() and possibly other memory related syscalls.

> So I suppose that this macro needs another parameter for the actual
> value that is returned on a failure:

> #define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ERRNOS, ...)
> 	do {
> 		TESTPTR(SCALL);

> 		...

> 		if (TST_RET_PTR == FAILPTR_VAL) {
> 		...

+1

> The hard question is if we want to pass this parameter explicitly from the
> macros used by the tests, i.e. if each test would need to specify a
> FAIL_PTR_VAL or if we want to pass it in the macros, but that would mean
> that the number of macros will explode again and we would have to figure
> out a good names. So maybe it would be easier to pass them from each
> test.

Names could be _NULL and _VOID, but I understand you want to limit number of
macros.

Wei, I guess testcases/kernel/syscalls/realpath/realpath01.c could use
TST_EXP_FAIL_PTR().

Kind regards,
Petr


More information about the ltp mailing list