[LTP] [PATCH 2/4] syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality

Matthew Bobrowski mbobrowski@mbobrowski.org
Fri Apr 19 10:37:45 CEST 2019


On Tue, Apr 16, 2019 at 05:23:14PM +0300, Amir Goldstein wrote:
> On Tue, Apr 16, 2019 at 4:41 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> >
> > Hi!
> > > Newly defined test file to validate the fanotify FAN_REPORT_FID
> > > functionality.
> > >
> > > Signed-off-by: Matthew Bobrowski <mbobrowski@mbobrowski.org>
> > > Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> > > ---
> > >  testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
> > >  testcases/kernel/syscalls/fanotify/fanotify.h   |  19 +-
> > >  testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++
> >
> > This is missing the runtest entry in runtest/syscalls so that the test
> > is picked up by the testrunner.
> >
> > And the same bug slipped in during review for fanotify12 so I've
> > commited a fix that adds it there.
> >
> > ...
> >

My apologies, this was a simple oversight. I've gone ahead and updated it
accordingly.

> > > +static void do_test(unsigned int number)
> > > +{
> > > +     unsigned int i;
> > > +     int len, fds[ARRAY_SIZE(objects)];
> > > +
> > > +     struct file_handle *event_file_handle;
> > > +     struct fanotify_event_metadata *metadata;
> > > +     struct fanotify_event_info_fid *event_fid;
> > > +     struct test_case_t *tc = &test_cases[number];
> > > +     struct fanotify_mark_type *mark = &tc->mark;
> > > +
> > > +     tst_res(TINFO,
> > > +             "Test #%d: FAN_REPORT_FID with mark flag: %s",
> > > +             number, mark->name);
> > > +
> > > +     /* Gets the filesystem fsid and file handle for each object */
> > > +     get_object_stats(tc);
> >
> > Is there a reason why are are not calling this function once in the test
> > setup? It will be called for every test iteration when the test is
> > passed the -i option...
> >
> 
> I think that's an oversight. It could be called once during setup.

Indeed. I've changed this so that the function is now only called once from
within do_setup(). There was one code snippet (added below) that I had to move
out from get_object_stats() as there's a setup dependency for each test case.

--
event_set[i].expected_mask = tc->mask;
if (!objects[i].is_dir)
        event_set[i].expected_mask &= ~FAN_ONDIR;
--

I've added this snippet within setup_marks() as we're already iterating over
the objects array and passing in a task_struct_t object, which means we could
also setup the expected mask for each expected event there. Unless anyone
objects?

-- 
Matthew Bobrowski


More information about the ltp mailing list