[LTP] [RFC PATCH 2/2] testcaes/lib: Add shell loader

Martin Doucha mdoucha@suse.cz
Thu Jul 25 18:01:36 CEST 2024


On 25. 07. 24 13:02, Petr Vorel wrote:
> Hi Martin, Cyril,
> 
>>> +mounted=$(grep $TST_MNTPOINT /proc/mounts)
> 
>> This check might produce false positive for example when another LTP shell
>> script runs in parallel in another temp directory. I'd recommend using
>> $(realpath ...) to disambiguate the mountpoints.
> 
> FYI this is just a test, not a library script.
> 
> Also maybe just prepend it with $PWD/ would be enough:
> 
> mounted=$(grep $PWD/$TST_MNTPOINT /proc/mounts)
> 
> (Not to require yet another binary. It's ok to have it here, because developers
> have coreutils, but in case it's in the tst_test.sh or its dependencies some
> minimal systems might have problem - busybox based embedded systems realpath is
> configurable via CONFIG_REALPATH=y. It would help if we specify shell library
> dependencies).

The test could still get confused by leftover mounts from other tests or 
failed runs of itself. That'll be annoying to deal with when you try to 
modify something in the shell loader.

I've checked what happens if you mount a filesystem on a mountpoint path 
that contains symlinks and in that case, /proc/mounts will report the 
real path. So $(realpath $TST_MNTPOINT) is what you need to search for. 
Grep might get confused by special characters in the path, though. 
Another problem is that /proc/mounts converts spaces to octal codes to 
prevent column parsing issues.

-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic



More information about the ltp mailing list