[LTP] [PATCH v3] syscalls/fcntl36: add tests for OFD locks
Xiong Zhou
xzhou@redhat.com
Wed Aug 23 06:15:58 CEST 2017
On Tue, Aug 22, 2017 at 04:23:57PM +0200, Cyril Hrubis wrote:
> Hi!
> > runtest/syscalls | 2 +
> > testcases/kernel/syscalls/fcntl/Makefile | 3 +
> > testcases/kernel/syscalls/fcntl/fcntl36.c | 386 ++++++++++++++++++++++++++++++
>
> Don't forget about .gitignore entry as well.
Ha, now i found the right one, :)
>
> ...
>
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
...
> > + SAFE_READ(1, fd, buf, pa->length);
> > +
> > + /* Verifying data read */
> > + for (i = 0; i < pa->length; i++) {
> > +
> > + if (buf[i] < 1 || buf[i] > 254) {
> > +
> > + tst_res(TFAIL, "Unexpected data "
> > + "offset %ld value %d",
> > + pa->offset + i, buf[i]);
> > + break;
> > + }
> > +
> > + long tmp = pa->length / 2;
>
> We can simplify this with:
> int j = i / (pa->length/2);
>
> if (buf[i] != buf[j]) {
> ...
> }
After checking, this is not what I meant to check here about
this data verifying.
We could read 4k data that first half 2k of it have the same
value and the another half 2k have a different value.
>
> > + if ((i < tmp && buf[i] != buf[0]) ||
> > + (i >= tmp && buf[i] != buf[tmp])) {
> > +
> > + tst_res(TFAIL, "Unexpected data "
> > + "offset %ld value %d",
> > + pa->offset + i, buf[i]);
> > + break;
> > + }
> > + }
> > +
...
> > + if (tst_fill_file(fname, 1, write_size, thread_cnt)) {
> > + tst_brk(TBROK, "Failed to create tst file");
> > + }
>
> No need for the curly braces around single line statement here.
I thought it's safer for a macro. Now it's one line function in
the macro, not hurting to remove the braces.
Thanks for reviewing!
Xiong
More information about the ltp
mailing list