[LTP] [PATCH v1] Test statx() with flag AT_NO_AUTOMOUNT.

Cyril Hrubis
2018-10-05T13:04:15Z

Hi!
> >> + pid = SAFE_FORK();
> >> + if (!pid) {
> >> + setpgrp();
> >
> > Why do you do this?
>
> * Parent is getting the autofs notification message only by setting
> the process group ID of the child process to it's process ID.

Ah, right, I remember that now, kernel checks that the process is in a
different process group before it attempts to send the event. Maybe we
should include the comment I had in the example code here so that it's
clear why it's needed.

> >> + TEST(statx(AT_FDCWD, MNTPOINT,
> >> + (automount) ? 0 : AT_NO_AUTOMOUNT,
> >> + 0, &file_info)
> >> + );
> >> +
> >> + if (TST_RET == -1) {
> >> + /* 1 -> statx() fail*/
> >> + value = 1;
> >> + SAFE_WRITE(1, ev_fd, &value, sizeof(value));
> >> +
> >> + exit(1);
> >> + }
> >> +
> >> + /* 2 -> statx() pass*/
> >> + value = 2;
> >> + SAFE_WRITE(1, ev_fd, &value, sizeof(value));
> >
> > There is no need to propagate anything from the child process, if you
> > call tst_res(TPASS, ...) in the child process the result will be
> > propagated automatically to the parent. So there is no need for the
> > eventfd at all.
>
> * Parent won't get any autofs request from child if,
> ** statx fails
> ** statx with AT_NO_AUTOMOUNT flag
>
> We tried using event_fd() in order to identify between these two
> scenarios and read from pipe only if statx passed.
> Breaking the test from the child if statx fails is not affecting the
> parent.

You can still do tst_brk(TBROK | TERRNO, "statx() failed"); in the child
which will propagate to the parent and fail the test eventually. The
only difference that this will happen once the parent test process
exists after it prints PASS message since the select timeouted as we
didn't get any notification.

So the output will looks like:
PASS: statx() succeeded
PASS: Got notification without AT_NO_AUTOMOUNT
BROK: statx() failed: EIVAL
PASS: Didn't get notification with AT_NO_AUTOMOUNT
BROK: Reported by child (3243)

and the exit value will non-zero since the test have been failed by the
child process.

--
Cyril Hrubis
chrubis@suse.cz