[LTP] [PATCH v2] Rewrite process_vm_readv03.c test with new LTP API

Cyril Hrubis chrubis@suse.cz
Wed Feb 9 13:29:52 CET 2022


Hi!
> > > -static void gen_random_arr(int *arr, int arr_sz)
> > > +static void create_data_size(int *arr, int arr_sz, int buffsize)
> > >  {
> > >       long bufsz_left, bufsz_single;
> > >       int i;
> > >
> > > -     bufsz_left = bufsz;
> > > +     bufsz_left = buffsize;
> > >       for (i = 0; i < arr_sz - 1; i++) {
> > > -             bufsz_single = rand() % (bufsz_left / 2) + 1;
> > > +             bufsz_single = rand() % ((bufsz_left / 2) + 1);
> >
> > It was correct before you added the parenthesis, the + 1 was there to
> > make sure we do not end up with an empty buffer if rand() returned
> > multiple of bufsz_left/2.
> 
> I think that was to avoid the case you described below (modulo by zero),
> zero iov_len appears allowed, so it may be interesting to let it be tested too.
> (if bufsize and nriovecs allow such combination as you pointed out)

The iovec can work with zero len buffers just fine, I would add a
special handling for when the buffer is allocated though.

Also the changes of getting zero size buffer is very low unless we have
a case where the bufsize is close to nriovec. So I would really be for
adding a table with different combinations of bufsize, local_iovec,
remote_iovec and let the test loop over that.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list