[LTP] [RFC PATCH 0/1] brk: use direct syscalls

Teo Couprie Diaz teo.coupriediaz@arm.com
Wed Nov 30 13:49:08 CET 2022


On 28/11/2022 19:30, Petr Vorel wrote:

>> Hello LTP maintainers,
>> This patch slightly reworks the brk01 and brk02 tests to use direct
>> syscalls with tst_syscall rather than calling through the libc.
>> While running LTP on a musl-based distribution, we noticed that the brk
>> tests were failing. It turns out that Musl prevents the use of brk
>> with their wrapper: it always returns an error.
>> This isn't too egregious as using brk is deprecated in favor of malloc
>> and it isn't part of POSIX anymore since POSIX.1-2001, but it _is_
>> different from glibc's beavior, which allows using it.
>> This patch allows proper testing of brk's functionality, independent of
>> libc specifics, and thus allows the tests to pass on Musl-based
>> distributions like Alpine.
>> Do you think this is a correct approach for LTP ?
>>  From what I could see there are a few tests that use tst_syscall directly
>> and it doesn't affect the logic much for brk.
> LGTM.
Thanks for having a look !
>
> I wonder if it makes sense to add .test_variants [1] for glibc and uclibc,
> e.g. for brk01():
>
> void verify_brk(void)
> {
> 	if (tst_variant) {
> 		tst_res(TINFO, "Testing sbrk()");
> 		cur_brk = (uintptr_t)sbrk(0);
> 	} else {
> 		tst_res(TINFO, "Testing __NR_brk");
> 		cur_brk = (void *)tst_syscall(__NR_brk, 0);
> 	}
>
> }

I guess I can see how it could be useful, but LTP already has tests for 
sbrk: should there really be testing for sbrk in the brk tests ?

I will send another reply down the thread regarding the rest of the 
discussion !

Best regards,
Téo

>
> struct tst_test test = {
> 	...
> #ifdef __GLIBC__
> 	.test_variants = 2,
> #else
> 	.test_variants = 1,
> #endif
> 	...
>
> Not sure if it should be testeed also on android, i.e:
> #if defined(__GLIBC__) || defined(__ANDROID__)
>
> Kind regards,
> Petr
>
> [1] https://github.com/linux-test-project/ltp/wiki/C-Test-API#130-testing-similar-syscalls-in-one-test
>
>> Green build:
>> https://github.com/Teo-CD/ltp/actions/runs/3563193507
>> This was discovered in the context of the Morello project[0].
>> [0]: https://www.morello-project.org/
>> Teo Couprie Diaz (1):
>>    syscalls/brk: use direct syscall
>>   testcases/kernel/syscalls/brk/brk01.c | 15 ++++++---------
>>   testcases/kernel/syscalls/brk/brk02.c | 14 ++++++--------
>>   2 files changed, 12 insertions(+), 17 deletions(-)


More information about the ltp mailing list