From e711c843df87f7793f2a95ba438c26e2e4d487c0 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Tue, 24 Mar 2020 18:53:10 +0800 Subject: [PATCH] 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 Signed-off-by: David Sterba --- tests/common | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/common b/tests/common index e04ceeb6..71661e95 100644 --- a/tests/common +++ b/tests/common @@ -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: $@"