btrfs-progs: tests/common: Don't call INSTRUMENT on mount command

[BUG]
With INSTRUMENT=valgrind set, some fsck tests will fail, e.g. fsck/013:
  ====== RUN CHECK mount -t btrfs -o loop /home/adam/btrfs/btrfs-progs/tests//test.img /home/adam/btrfs/btrfs-progs/tests//mnt
  ==114106==
  ==114106== Warning: Can't execute setuid/setgid/setcap executable: /usr/bin/mount
  ==114106== Possible workaround: remove --trace-children=yes, if in effect
  ==114106==
  valgrind: /usr/bin/mount: Permission denied
  failed: mount -t btrfs -o loop /home/adam/btrfs/btrfs-progs/tests//test.img /home/adam/btrfs/btrfs-progs/tests//mnt
  test failed for case 013-extent-tree-rebuild

[CAUSE]
Just as stated by valgrind itself, it can't handle program with
setuid/setgid/setcap.

Thankfully in our case it's mount and we don't really care about it at
all.

[FIX]
Although we could use complex skip pattern to skip mount in valgrind, we
don't really want to run valgrind on mount or sudo command anyway.

So here we do extra check if we're running mount command. And if that's
the case, just skip $INSTRUMENT command.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo 2020-03-24 18:53:10 +08:00 committed by David Sterba
parent 3a2d040070
commit e711c843df
1 changed files with 7 additions and 1 deletions

View File

@ -154,7 +154,13 @@ run_check()
set -- "${@:1:$(($ins-1))}" $spec "${@: $ins}"
echo "====== RUN CHECK $@" >> "$RESULTS" 2>&1
if [[ $TEST_LOG =~ tty ]]; then echo "CMD: $@" > /dev/tty; fi
if [ "$1" = 'root_helper' ]; then
# If the command is `root_helper` or mount/umount, don't call INSTRUMENT
# as most profiling tool like valgrind can't handle setuid/setgid/setcap
# which mount normally has.
# And since mount/umount is only called with run_check(), we don't need
# to do the same check on other run_*() functions.
if [ "$1" = 'root_helper' -o "$1" = 'mount' -o "$1" = 'umount' ]; then
"$@" >> "$RESULTS" 2>&1 || _fail "failed: $@"
else
$INSTRUMENT "$@" >> "$RESULTS" 2>&1 || _fail "failed: $@"