mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2025-01-22 19:53:22 +08:00
btrfs-progs: tests: use _mktemp_local for temporary files
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
caa57c1689
commit
7d06a7e561
@ -13,9 +13,7 @@ prepare_test_dev
|
||||
run_check_mkfs_test_dev
|
||||
run_check_mount_test_dev
|
||||
|
||||
run_check truncate -s 0 img2
|
||||
run_check truncate -s 1G img2
|
||||
chmod a+w img2
|
||||
_mktemp_local img2 1G
|
||||
|
||||
# create second mount with btrfs, create a file in the target mount path, the
|
||||
# mount must hide that
|
||||
|
@ -16,8 +16,7 @@ run_check_mount_test_dev
|
||||
run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/file" bs=4k count=16
|
||||
run_check_umount_test_dev
|
||||
|
||||
touch restored_image
|
||||
chmod a+w restored_image
|
||||
_mktemp_local restored_image
|
||||
run_check $SUDO_HELPER "$TOP/btrfs-image" "$TEST_DEV" "restored_image"
|
||||
|
||||
# use prepare_test_dev() to wipe all existing data on $TEST_DEV
|
||||
|
@ -10,8 +10,7 @@ setup_root_helper
|
||||
|
||||
file="img"
|
||||
# Allocate an initial 1G file for testing.
|
||||
truncate -s0 "$file"
|
||||
truncate -s1g "$file"
|
||||
_mktemp_local "$file" 1g
|
||||
|
||||
dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file")
|
||||
|
||||
|
@ -29,8 +29,7 @@ for i in 1 2 3; do
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent2 subv-snap2_$i
|
||||
done
|
||||
|
||||
truncate -s0 "$here"/send-stream.img
|
||||
chmod a+w "$here"/send-stream.img
|
||||
_mktemp_local "$here/send-stream.img"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$here"/send-stream.img \
|
||||
-c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
|
||||
|
||||
|
@ -27,8 +27,7 @@ test_full_empty_stream() {
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
||||
|
||||
truncate -s0 "$str"
|
||||
chmod a+w "$str"
|
||||
_mktemp_local "$str"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$str" subv1-snap
|
||||
|
||||
cd "$here" || _fail "cannot chdir back to test directory"
|
||||
@ -58,8 +57,7 @@ test_full_simple_stream() {
|
||||
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
||||
|
||||
truncate -s0 "$str"
|
||||
chmod a+w "$str"
|
||||
_mktemp_local "$str"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$str" subv1-snap
|
||||
|
||||
cd "$here" || _fail "cannot chdir back to test directory"
|
||||
@ -88,8 +86,8 @@ test_incr_empty_stream() {
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap
|
||||
|
||||
truncate -s0 "$fstr" "$istr"
|
||||
chmod a+w "$fstr" "$istr"
|
||||
_mktemp_local "$fstr"
|
||||
_mktemp_local "$istr"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$fstr" subv1-snap
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -p subv1-snap -f "$istr" subv2-snap
|
||||
|
||||
@ -128,8 +126,8 @@ test_incr_simple_stream() {
|
||||
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap
|
||||
|
||||
truncate -s0 "$fstr" "$istr"
|
||||
chmod a+w "$fstr" "$istr"
|
||||
_mktemp_local "$fstr"
|
||||
_mktemp_local "$istr"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$fstr" subv1-snap
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -p subv1-snap -f "$istr" subv2-snap
|
||||
|
||||
|
@ -18,8 +18,9 @@ touch "$TEST_MNT/|5gp!"
|
||||
|
||||
run_check_umount_test_dev
|
||||
|
||||
run_check touch img img.restored img.dump
|
||||
run_check chmod a+w img img.restored img.dump
|
||||
_mktemp_local img
|
||||
_mktemp_local img.restored
|
||||
_mktemp_local img.dump
|
||||
run_check $SUDO_HELPER "$TOP/btrfs-image" -ss "$TEST_DEV" img
|
||||
run_check $SUDO_HELPER "$TOP/btrfs-image" -r img img.restored
|
||||
run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree img.restored > img.dump
|
||||
|
@ -14,10 +14,8 @@ check_prereq mkfs.btrfs
|
||||
|
||||
setup_root_helper
|
||||
|
||||
rm -f dev1 dev2
|
||||
run_check truncate -s 1G dev1
|
||||
run_check truncate -s 1G dev2
|
||||
chmod a+w dev1 dev2
|
||||
_mktemp_local dev1 1G
|
||||
_mktemp_local dev2 1G
|
||||
|
||||
loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show dev1)
|
||||
loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show dev2)
|
||||
@ -35,8 +33,7 @@ echo "some data" | $SUDO_HELPER tee "$TEST_MNT/ddis/file" > /dev/null
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \
|
||||
"$TEST_MNT/ddis" "$TEST_MNT/ddis/snap"
|
||||
|
||||
run_check truncate -s 0 send.data
|
||||
chmod a+w send.data
|
||||
_mktemp_local send.data
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f send.data "$TEST_MNT/ddis/snap"
|
||||
|
||||
# The following receive used to fail because it incorrectly determined the mount
|
||||
|
@ -6,10 +6,8 @@ source "$TEST_TOP/common"
|
||||
check_prereq mkfs.btrfs
|
||||
check_prereq btrfs
|
||||
|
||||
IMAGE=$(mktemp -u btrfs-progs-image.XXXXXX)
|
||||
_mktemp_local img 3g
|
||||
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f img
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show img
|
||||
|
||||
run_check truncate -s3g "$IMAGE"
|
||||
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$IMAGE"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show "$IMAGE"
|
||||
|
||||
rm -f "$IMAGE"
|
||||
rm -f img
|
||||
|
@ -20,9 +20,7 @@ done
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r "$TEST_MNT/subv1" "$TEST_MNT/snap1"
|
||||
|
||||
stream="stream$RANDOM.out"
|
||||
rm -f -- "$stream"
|
||||
touch -- "$stream"
|
||||
chmod a+rw -- "$stream"
|
||||
_mktemp_local "$stream"
|
||||
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
|
||||
# Output to file must be slow
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$stream" "$TEST_MNT/snap1" &
|
||||
|
@ -21,8 +21,8 @@ for i in `seq 10`; do
|
||||
done
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r "$TEST_MNT/src/subvol1" "$TEST_MNT/src/snap2"
|
||||
|
||||
touch send1.stream send2.stream
|
||||
chmod a+w send1.stream send2.stream
|
||||
_mktemp_local send1.stream
|
||||
_mktemp_local send2.stream
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f send1.stream "$TEST_MNT/src/snap1"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f send2.stream -p "$TEST_MNT/src/snap1" "$TEST_MNT/src/snap2"
|
||||
|
||||
|
@ -34,9 +34,9 @@ if run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume show "$TEST_MNT/snap1" |
|
||||
grep -q "WARNING.*received_uuid"; then
|
||||
_fail "unexpected warning"
|
||||
fi
|
||||
|
||||
run_check $SUDO_HELPER mkdir "$TEST_MNT/recv"
|
||||
touch send.stream
|
||||
chmod a+w send.stream
|
||||
_mktemp_local send.stream
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f send.stream "$TEST_MNT/snap1"
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" receive -f send.stream -m "$TEST_MNT" "$TEST_MNT/recv"
|
||||
if run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume show "$TEST_MNT/recv/snap1" |
|
||||
|
@ -31,8 +31,7 @@ send_one() {
|
||||
run_check_mount_test_dev "-o" "compress-force=$algorithm"
|
||||
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
|
||||
|
||||
trucate -s0 "$file"
|
||||
chmod a+w "$file"
|
||||
_mktemp_local "$file"
|
||||
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$subv"
|
||||
run_check $SUDO_HELPER dd if=/dev/zero of="$subv/file1" bs=1M count=1
|
||||
|
@ -28,8 +28,7 @@ failed link source" "$TEST_MNT/subv1/file
|
||||
failed link target"
|
||||
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r "$TEST_MNT/subv1" "$TEST_MNT/snap1"
|
||||
touch send.stream
|
||||
chmod a+w send.stream
|
||||
_mktemp_local send.stream
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" send -f send.stream "$TEST_MNT/snap1"
|
||||
|
||||
run_check_stdout "$TOP/btrfs" receive --dump -f send.stream |
|
||||
|
@ -18,9 +18,7 @@ dmname=\
|
||||
btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA$rand
|
||||
dmdev="/dev/mapper/$dmname"
|
||||
|
||||
run_check truncate -s0 img
|
||||
chmod a+w img
|
||||
run_check truncate -s2g img
|
||||
_mktemp_local img 2g
|
||||
|
||||
loopdev=`run_check_stdout $SUDO_HELPER losetup --find --show img`
|
||||
run_check $SUDO_HELPER dmsetup create "$dmname" --table "0 1048576 linear $loopdev 0"
|
||||
|
@ -12,8 +12,7 @@ check_prereq mkfs.btrfs
|
||||
|
||||
setup_root_helper
|
||||
|
||||
run_check truncate -s0 img
|
||||
chmod a+w img
|
||||
_mktemp_local img
|
||||
cp partition-1g-1g img
|
||||
run_check truncate -s2g img
|
||||
|
||||
@ -28,5 +27,4 @@ done
|
||||
|
||||
# cleanup
|
||||
run_check $SUDO_HELPER losetup -d "$loopdev"
|
||||
run_check truncate -s0 img
|
||||
rm img
|
||||
|
@ -54,8 +54,7 @@ fi
|
||||
meta_dev_offset=0
|
||||
total_data_dev_size=$(($meta_dev_offset + $meta_dev_size + $data_dev_size))
|
||||
|
||||
run_check truncate -s0 img
|
||||
chmod a+w img
|
||||
_mktemp_local img
|
||||
run_check truncate -s"$(($total_data_dev_size * $sector_size))" img
|
||||
|
||||
dm_backing_dev=`run_check_stdout $SUDO_HELPER losetup --find --show img`
|
||||
|
Loading…
Reference in New Issue
Block a user