[PATCH v1] Testing HDIO_GETGEO Output Mismatch Error

Eugene Syromiatnikov esyr at redhat.com
Tue Mar 31 02:25:34 UTC 2020


On Mon, Mar 30, 2020 at 01:44:06PM +0530, Bran S wrote:
> On Sun, 29 Mar 2020 at 02:22, Bran S <archsbran at gmail.com> wrote:
> >
> > On Sat, 28 Mar 2020 at 20:55, Eugene Syromiatnikov <esyr at redhat.com> wrote:
> > >
> > > On Fri, Mar 27, 2020 at 05:10:22PM +0530, Bran S wrote:
> > > > The output that is written into `tests/hdio_getgeo-success.dir/out` is
> > > > what we want right ?
> > >
> > > "out" file contains the (filtered) strace output, "exp" contains the expected
> > > output (judging by the way your test is written).
> > >
> > > > How can I correct the expected output in `tests/hdio_getgeo-success.dir/out` ?
> > >
> > > It's up to the test author to figure out what is to be corrected if the
> > > strace's output doesn't meet the expected one; it can be both ways
> > > (it's one of the reasons to write the tests: to check whether the
> > > tested program behaves the expected way, and tests are an embodiment
> > > of these expectations).
> >
> > And is this mismatch bound to happen in a success injection test?

> > I ask so because the output in EXP is written by the actually running
> > strace and the output into OUT is written according to the decoder,
> > right ?

No, as I said, it's the other way around.

> > Please clarify this a little bit on how these two (EXP and OUT) are
> > getting different outputs.

One ("exp") is produced by by the tests's I/O routines, the other ("log",
the default value of the $LOG variable, as set in the sourced init.sh script)
is produced by strace's I/O routines,

> > The `grep -v` line writes output into OUT.
> > I am not clear on how that works.

grep[1] filters the input files (in this case, the standard input)
in accordance with the provided command line parameters; in this
specific case it outputs the lines, parts of which that do not ("-v" option)
match the regular expression[2] "^ioctl([012][,<]".

> > And what needs to be corrected ? Is there some problem with the test
> > code or the hdio.c decoder code ?
> 
> To solve the problem do I need to make some changes in the decoder ?
> or is there something wrong with the written test.

Since it is expected that a valid structure is to be returned[3][4][5]
(and, consequently, decoded and printed by strace) on successful
syscall return, it is seems rather odd to print a mere pointer as expected
output.

[1] http://man7.org/linux/man-pages/man1/grep.1.html
[2] http://man7.org/linux/man-pages/man7/regex.7.html
[3] http://man7.org/linux/man-pages/man4/sd.4.html
[4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/block/ioctl.c#n684
[5] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/block/ioctl.c#n497



More information about the Strace-devel mailing list