From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/openat2: New tests
Date: Mon, 2 Mar 2020 09:46:51 +0100 [thread overview]
Message-ID: <20200302084651.GA4736@rei.lan> (raw)
In-Reply-To: <20200302063714.claovt5uyi7gxf2o@vireshk-i7>
Hi!
> > > +static void run(unsigned int n)
> > > +{
> > > + int fd;
> > > + struct stat file_stat;
> > > + struct tcase *tc = &tcases[n];
> > > + struct open_how how = {
> > > + .flags = tc->flags | O_CREAT,
> > > + .mode = tc->mode,
> > > + .resolve = tc->resolve
> > > + };
> >
> > This structure should be allocated tst_buffers, see capget01.c for
> > example.
>
> This changed few things.
>
> I am getting a build warning now (same happen if I build bpf stuff as
> well). I don't understand why this warning comes though.
>
> openat202.c:69:1: warning: missing initializer for field 'caps' of 'struct tst_test' [-Wmissing-field-initializers]
> };
> ^
> In file included from openat202.c:7:0:
> ../../../../include/tst_test.h:236:18: note: 'caps' declared here
> struct tst_cap *caps;
The compiler is confused by different styles of initialization
apparently.
> Also for the failure test where larger size was passed, the error
> reported now is EFAULT as kernel can't access out of bound dynamically
> allocated memory (instead of stack one earlier). In order to get
> E2BIG, I need to add some hacks (allocate more memory and write
> non-zero value to excess memory) and I don't think that would be worth
> it, so my test will expect EFAULT now.
Hmm, I guess that it makes sense to add the pointer to how to the tcase
structure and allocate exact size for the E2BIG case. That should work
fine, right?
> > > + TEST(fd = openat2(*tc->dfd, tc->pathname, &how, sizeof(how)));
> > > + if (fd == -1) {
> > > + tst_res(TFAIL | TTERRNO, "openat2() failed (%d)", n);
> > > + return;
> > > + }
> > > +
> > > + SAFE_FSTAT(fd, &file_stat);
> > > +
> > > + if (file_stat.st_size == 0)
> > > + tst_res(TPASS, "openat2() passed (%d)", n);
> > > + else
> > > + tst_res(TFAIL, "fstat() didn't work as expected (%d)", n);
> >
> > So this is very basic test that just checks that openat() can open a
> > file and we would need a few more for each of the newly introduced
> > RESOLVE_* flags.
>
> Hmm, this file is already testing openat2() with all different type of
> resolve flags. What kind of further tests are you suggesting here ?
Well do not test that the flags actually works, right?
So for example for RESOLVE_BENATH we need to pass paths with ".." or
symlinks pointing upwards in the filesystem and expect openat2() to
fail. And the same for the rest of the flags.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2020-03-02 8:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 10:50 [LTP] [PATCH] syscalls/openat2: New tests Viresh Kumar
2020-02-28 13:22 ` Cyril Hrubis
2020-03-02 6:37 ` Viresh Kumar
2020-03-02 7:31 ` Petr Vorel
2020-03-02 8:46 ` Cyril Hrubis [this message]
2020-03-02 9:07 ` Viresh Kumar
2020-03-02 9:36 ` Cyril Hrubis
2020-03-02 10:02 ` Viresh Kumar
2020-03-02 10:16 ` Cyril Hrubis
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=20200302084651.GA4736@rei.lan \
--to=chrubis@suse.cz \
--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