ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Teo Couprie Diaz <teo.coupriediaz@arm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/brk: add direct syscall tst_variant
Date: Tue, 6 Dec 2022 15:04:21 +0100	[thread overview]
Message-ID: <20221206140421.GB21839@pevik> (raw)
In-Reply-To: <20221206122604.212528-1-teo.coupriediaz@arm.com>

Hi Teo,

> Direct usage of brk is discouraged in favor of using malloc. Also, brk was
> removed from POSIX in POSIX.1-2001.
> In particular, the Musl libc's brk always returns -ENOMEM which causes
> the LTP tests to exit prematurely. Invoking the syscall directly allows
> them to properly validate brk behavior. Add a new test variant handling if
> the libc wrappers are not implemented and testing the direct syscall.

> Use tst_syscall() and handle the failure cases ourselves, as
> we don't depend on the libc to do it anymore.

> The patch also works around the dependency on sbrk to get the current break
> as it has the same issues. Instead, call tst_syscall(__NR_brk, 0) which
> always returns the current break.

> Update brk01 to use void* to unify it with brk02.
That brought warnings, see below.

...
> +++ b/testcases/kernel/syscalls/brk/brk02.c
> @@ -14,24 +14,51 @@
>  #include <unistd.h>
>  #include <sys/mman.h>
>  #include "tst_test.h"
> +#include "lapi/syscalls.h"
> +
> +inline void *brk_variants(void *addr)
> +{
> +	void *brk_addr;
> +	if (tst_variant) {
> +		brk_addr = (void *)tst_syscall(__NR_brk, addr);
> +	} else {
> +		brk_addr = (void *)brk(addr);

NOTE using pointer for brk() is problematic, there are complains:

brk02.c: In function ‘brk_variants’:
brk02.c:26:28: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
   26 |                 brk_addr = (void *)brk(addr);
         |                            ^

Not sure how to fix this. Problem is in both C files, on several places.

There are also code style problems (you can see it when running make check in
testcases/kernel/syscalls/brk/), but that's a minor detail.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-12-06 14:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 12:26 [LTP] [PATCH] syscalls/brk: add direct syscall tst_variant Teo Couprie Diaz
2022-12-06 14:04 ` Petr Vorel [this message]
2022-12-06 14:45   ` Teo Couprie Diaz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221206140421.GB21839@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=teo.coupriediaz@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).