From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/3] ltp-aiodio: report posix_memalign errors properly
Date: Mon, 11 Jul 2016 08:35:05 -0400 (EDT) [thread overview]
Message-ID: <1109254790.3643017.1468240505382.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1467903917-16064-1-git-send-email-eguan@redhat.com>
----- Original Message -----
> From: "Eryu Guan" <eguan@redhat.com>
> To: ltp@lists.linux.it
> Sent: Thursday, 7 July, 2016 5:05:15 PM
> Subject: [LTP] [PATCH v2 1/3] ltp-aiodio: report posix_memalign errors properly
>
> From posix_memalign(3) the value of errno is indeterminate after a call
> to posix_memalign(). So TERRNO doesn't work in this case.
> dio_sparse 1 TBROK : dio_sparse.c:75: posix_memalign():
> errno=SUCCESS(0): Success
>
> Report posix_memalign() errors by calling strerror on the return value.
> dio_sparse 1 TBROK : dio_sparse.c:74: posix_memalign(): EINVAL
>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---
> v2:
> - include "test.h" when needed to avoid compile error
>
> testcases/kernel/io/ltp-aiodio/aiodio_append.c | 9 +++++++--
> testcases/kernel/io/ltp-aiodio/aiodio_sparse.c | 7 ++++---
> testcases/kernel/io/ltp-aiodio/dio_append.c | 10 ++++++++--
> testcases/kernel/io/ltp-aiodio/dio_sparse.c | 7 ++++---
> testcases/kernel/io/ltp-aiodio/dio_truncate.c | 17 +++++++++++++----
> 5 files changed, 36 insertions(+), 14 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_append.c
> b/testcases/kernel/io/ltp-aiodio/aiodio_append.c
> index 56e9c09..77df02c 100644
> --- a/testcases/kernel/io/ltp-aiodio/aiodio_append.c
> +++ b/testcases/kernel/io/ltp-aiodio/aiodio_append.c
> @@ -33,6 +33,8 @@
>
> #include <libaio.h>
>
> +#include "test.h"
> +
> #define NUM_CHILDREN 8
>
> char *check_zero(unsigned char *buf, int size)
> @@ -98,6 +100,7 @@ void aiodio_append(char *filename)
> void *bufptr;
> int i;
> int w;
> + int ret;
> struct iocb iocb_array[NUM_AIO];
> struct iocb *iocbs[NUM_AIO];
> off_t offset = 0;
> @@ -115,8 +118,10 @@ void aiodio_append(char *filename)
> io_queue_init(NUM_AIO, &myctx);
>
> for (i = 0; i < NUM_AIO; i++) {
> - if (posix_memalign(&bufptr, 4096, AIO_SIZE)) {
> - perror("cannot malloc aligned memory");
> + ret = posix_memalign(&bufptr, 4096, AIO_SIZE);
> + if (ret) {
> + tst_resm(TBROK, "cannot malloc aligned memory: %s",
> + tst_strerrno(ret));
Just fyi, if you want to safe few characters: we have TRERRNO, that works
as TERRNO, but instead of using value of TEST_ERRNO, it uses TEST_RETURN.
So code above would become:
TEST(posix_memalign(&bufptr, 4096, AIO_SIZE));
if (TEST_RETURN)
tst_resm(TBROK|TRERRNO, "cannot malloc aligned memory");
Regards,
Jan
> return;
> }
> memset(bufptr, 0, AIO_SIZE);
prev parent reply other threads:[~2016-07-11 12:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 15:05 [LTP] [PATCH v2 1/3] ltp-aiodio: report posix_memalign errors properly Eryu Guan
2016-07-07 15:05 ` [LTP] [PATCH v2 2/3] ltp-aiodio/dio_sparse: add offset support Eryu Guan
2016-07-07 15:05 ` [LTP] [PATCH v2 3/3] ltp-aiodio: new dio_sparse tests specifying offset Eryu Guan
2016-07-11 12:35 ` Jan Stancek [this message]
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=1109254790.3643017.1468240505382.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--cc=ltp@lists.linux.it \
/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