Skip to content
Permalink
Browse files

Instrument xattr tests with kmemleak detection.

  • Loading branch information...
PaulZ-98 committed Sep 26, 2019
1 parent b048293 commit c41322f2a1c5b58cac2e71616f4cca281ee13368
@@ -66,4 +66,6 @@ for arg in ${args[*]}; do
delete_xattr $TESTDIR/myfile.$$ passwd
done

check_mem_leaks

log_pass "Create/read/write of xattrs works"
@@ -60,3 +60,6 @@ for arg in ${args[*]}; do

log_pass "A read of a non-existent xattr fails"
done

check_mem_leaks

@@ -73,4 +73,6 @@ else
log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cp /etc/passwd ."
fi

check_mem_leaks

log_pass "read/write xattr on a file with no permissions fails"
@@ -117,5 +117,5 @@ else

log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
fi

check_mem_leaks
log_pass "Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."
@@ -74,5 +74,5 @@ delete_xattr $TESTDIR/myfile.$$ passwd
# verify it's still there on the clone
verify_xattr $TESTDIR/clone/myfile.$$ passwd /etc/passwd
delete_xattr $TESTDIR/clone/myfile.$$ passwd

check_mem_leaks
log_pass "read/write/create/delete xattr on a clone filesystem"
@@ -59,5 +59,5 @@ log_must zfs snapshot $TESTPOOL/$TESTFS@snap

# check for the xattr on the snapshot
verify_xattr $TESTDIR/.zfs/snapshot/snap/myfile.$$ passwd /etc/passwd

check_mem_leaks
log_pass "read xattr on a snapshot"
@@ -86,5 +86,5 @@ else
fi

log_must diff $TEST_BASE_DIR/output.$$ $TEST_BASE_DIR/expected_output.$$

check_mem_leaks
log_pass "create/write xattr on a snapshot fails"
@@ -80,5 +80,5 @@ fi

# verify we can't list ../
log_mustnot eval "runat $TESTDIR/myfile.$$ ls ../ > /dev/null 2>&1"

check_mem_leaks
log_pass "special . and .. dirs work as expected for xattrs"
@@ -62,5 +62,5 @@ log_mustnot runat $TESTDIR/myfile.$$ ln -s /etc/passwd foo

# Try to create a hard link from the xattr namespace to the default namespace
log_mustnot runat $TESTDIR/myfile.$$ ln /etc/passwd foo

check_mem_leaks
log_pass "links between xattr and normal file namespace fail"
@@ -66,5 +66,5 @@ log_mustnot runat $TESTDIR/myfile.$$ mknod block b 888 888
log_mustnot runat $TESTDIR/myfile.$$ mknod char c

log_mustnot runat $TESTDIR/myfile.$$ mknod fifo p

check_mem_leaks
log_pass "mkdir, mknod fail"
@@ -234,5 +234,5 @@ else
log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
log_must rm $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
fi

check_mem_leaks
log_assert "Basic applications work with xattrs: cpio cp find mv pax tar"
@@ -106,4 +106,6 @@ NEW_FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS)
log_fail "The new filesystem size $NEW_FS_SIZE was less \
than or equal to the old filesystem size $FS_SIZE."

check_mem_leaks

log_pass "xattr file sizes count towards normal disk usage"
@@ -100,5 +100,5 @@ else
log_mustnot eval "runat $TESTDIR/new.$$ cat passwd > /dev/null 2>&1"
fi
create_xattr $TESTDIR/new.$$ passwd /etc/passwd

check_mem_leaks
log_pass "The noxattr mount option functions as expected"
@@ -134,4 +134,24 @@ function create_expected_output { # expected_output_file contents_of_the_outpu
do
log_must eval "echo $line >> $FILE"
done
}
}

function check_mem_leaks {
log_note "Checking for leaks"
if $(sudo -E test -e "$KMEMLEAK_FILE"); then
# Scan must be run twice to ensure all leaks are detected.
sudo -E sh -c "echo scan >$KMEMLEAK_FILE"
sudo -E sh -c "echo scan >$KMEMLEAK_FILE"
sudo -E cat $KMEMLEAK_FILE >$KMEMLEAK_LOG

if [ -s "$KMEMLEAK_LOG" ]; then
echo "Kmemleak detected see $KMEMLEAK_LOG"
[ $RESULT -eq 0 ] && RESULT=2
log_fail "Leaks were detected"
else
log_note "Kmemleak detected no leaks"
echo "Kmemleak detected no leaks" >$KMEMLEAK_LOG
fi
fi
}

0 comments on commit c41322f

Please sign in to comment.
You can’t perform that action at this time.