On Thu, 2024-01-11 at 11:23 -0800, Dan Williams wrote:
> Vishal Verma wrote:
> > The daxctl-create.sh test had some hard-coded assumptions about what dax
> > device it expects to find, and what region number it will be under. This
> > usually worked when the unit test environment only had efi_fake_mem
> > devices as the sources of hmem memory. With CXL however, the region
> > numbering namespace is shared with CXL regions, often pushing the
> > efi_fake_mem region to something other than 'region0'.
> > 
> > Remove any region and device number assumptions from this test so it
> > works regardless of how regions get enumerated.
> > 
> > Cc: Joao Martins <[email protected]>
> > Cc: Dan Williams <[email protected]>
> > Signed-off-by: Vishal Verma <[email protected]>
> > ---
> >  test/daxctl-create.sh | 62 
> > +++++++++++++++++++++++++++++----------------------
> >  1 file changed, 35 insertions(+), 27 deletions(-)
> > 
> > diff --git a/test/daxctl-create.sh b/test/daxctl-create.sh
> > index d319a39..a5df6f2 100755
> > --- a/test/daxctl-create.sh
> > +++ b/test/daxctl-create.sh
> > @@ -29,14 +29,20 @@ find_testdev()
> >         fi
> >  
> >         # find a victim region provided by dax_hmem
> > -       testpath=$("$DAXCTL" list -r 0 | jq -er '.[0].path | .//""')
> > +       region_json="$("$DAXCTL" list -R)"
> > +       testpath=$(jq -er '.[0].path | .//""' <<< "$region_json")
> 
> This fixes the case where the first dax-region may not be region-id 0,
> but would it also fail if the first region is not the "hmem" region?
> 
> I wonder if the above and the next line can be fixed with a jq select()
> like?
> 
>     select(.path | contains("hmem"))

Oh yep this whole simplified by just doing this directly:

  region_id="$("$DAXCTL" list -R | jq -r '.[] | select(.path | 
contains("hmem")) | .id')"

Thanks - will send v2.

> 
> >         if [[ ! "$testpath" == *"hmem"* ]]; then
> >                 printf "Unable to find a victim region\n"
> >                 exit "$rc"
> >         fi
> > +       region_id=$(jq -er '.[0].id | .//""' <<< "$region_json")
> > +       if [[ ! "$region_id" ]]; then
> > +               printf "Unable to determine victim region id\n"
> > +               exit "$rc"
> > +       fi
> >  

Reply via email to