btrfs-progs: test: fix how to make test files in fsck-tests 013

In my test environment, following error was occurred because the size
of /lib/modules/`uname -r`/* is larger than 1GB.

# make test-fsck
    [TEST]   fsck-tests.sh
    [TEST/fsck]   013-extent-tree-rebuild
failed: cp -aR /lib/modules/4.9.0-rc5/ /test/btrfs-progs/tests/mnt
test failed for case 013-extent-tree-rebuild
Makefile:272: recipe for target 'test-fsck' failed
make: *** [test-fsck] Error 1
#

In this test case, 'generate_dataset small' is enough for making the
test files, so I will use 'generate_dataset' instead of 'cp'.

For this, move 'generate_dataset()' from 'common.convert' to 'common'.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Tsutomu Itoh 2016-11-21 14:10:41 +09:00 committed by David Sterba
parent d8f93ce802
commit b0d8975582
3 changed files with 90 additions and 90 deletions

View File

@ -313,6 +313,95 @@ check_kernel_support()
return 0
}
# how many files to create.
DATASET_SIZE=50
generate_dataset() {
dataset_type="$1"
dirpath=$TEST_MNT/$dataset_type
run_check $SUDO_HELPER mkdir -p "$dirpath"
case $dataset_type in
small)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER dd if=/dev/urandom of="$dirpath/$dataset_type.$num" bs=10K \
count=1 >/dev/null 2>&1
done
;;
hardlink)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num
run_check $SUDO_HELPER ln "$dirpath/$dataset_type.$num" "$dirpath/hlink.$num"
done
;;
fast_symlink)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num
run_check cd "$dirpath" && \
$SUDO_HELPER ln -s "$dataset_type.$num" "$dirpath/slink.$num" && \
cd /
done
;;
brokenlink)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER ln -s "$dirpath/$dataset_type.$num" "$dirpath/blink.$num"
done
;;
perm)
for modes in 777 775 755 750 700 666 664 644 640 600 444 440 400 000 \
1777 1775 1755 1750 1700 1666 1664 1644 1640 1600 1444 1440 1400 1000 \
2777 2775 2755 2750 2700 2666 2664 2644 2640 2600 2444 2440 2400 2000 \
4777 4775 4755 4750 4700 4666 4664 4644 4640 4600 4444 4440 4400 4000; do
if [[ "$modes" == *9* ]] || [[ "$modes" == *8* ]]
then
continue;
else
run_check $SUDO_HELPER touch "$dirpath/$dataset_type.$modes"
run_check $SUDO_HELPER chmod "$modes" "$dirpath/$dataset_type.$modes"
fi
done
;;
sparse)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER dd if=/dev/urandom of="$dirpath/$dataset_type.$num" bs=10K \
count=1 >/dev/null 2>&1
run_check $SUDO_HELPER truncate -s 500K "$dirpath/$dataset_type.$num"
run_check $SUDO_HELPER dd if=/dev/urandom of="$dirpath/$dataset_type.$num" bs=10K \
oflag=append conv=notrunc count=1 >/dev/null 2>&1
run_check $SUDO_HELPER truncate -s 800K "$dirpath/$dataset_type.$num"
done
;;
acls)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER touch "$dirpath/$dataset_type.$num"
run_check $SUDO_HELPER setfacl -m "u:root:x" "$dirpath/$dataset_type.$num"
run_check $SUDO_HELPER setfattr -n user.foo -v "bar$num" "$dirpath/$dataset_type.$num"
done
;;
fifo)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER mkfifo "$dirpath/$dataset_type.$num"
done
;;
slow_symlink)
long_filename=`date +%s | sha256sum | cut -f1 -d'-'`
run_check $SUDO_HELPER touch "$dirpath/$long_filename"
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER ln -s "$dirpath/$long_filename" "$dirpath/slow_slink.$num"
done
;;
esac
}
init_env()
{
TEST_MNT="${TEST_MNT:-$TOP/tests/mnt}"

View File

@ -1,95 +1,6 @@
#!/bin/bash
# helpers for btrfs-convert tests
# how many files to create.
DATASET_SIZE=50
generate_dataset() {
dataset_type="$1"
dirpath=$TEST_MNT/$dataset_type
run_check $SUDO_HELPER mkdir -p "$dirpath"
case $dataset_type in
small)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER dd if=/dev/urandom of="$dirpath/$dataset_type.$num" bs=10K \
count=1 >/dev/null 2>&1
done
;;
hardlink)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num
run_check $SUDO_HELPER ln "$dirpath/$dataset_type.$num" "$dirpath/hlink.$num"
done
;;
fast_symlink)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num
run_check cd "$dirpath" && \
$SUDO_HELPER ln -s "$dataset_type.$num" "$dirpath/slink.$num" && \
cd /
done
;;
brokenlink)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER ln -s "$dirpath/$dataset_type.$num" "$dirpath/blink.$num"
done
;;
perm)
for modes in 777 775 755 750 700 666 664 644 640 600 444 440 400 000 \
1777 1775 1755 1750 1700 1666 1664 1644 1640 1600 1444 1440 1400 1000 \
2777 2775 2755 2750 2700 2666 2664 2644 2640 2600 2444 2440 2400 2000 \
4777 4775 4755 4750 4700 4666 4664 4644 4640 4600 4444 4440 4400 4000; do
if [[ "$modes" == *9* ]] || [[ "$modes" == *8* ]]
then
continue;
else
run_check $SUDO_HELPER touch "$dirpath/$dataset_type.$modes"
run_check $SUDO_HELPER chmod "$modes" "$dirpath/$dataset_type.$modes"
fi
done
;;
sparse)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER dd if=/dev/urandom of="$dirpath/$dataset_type.$num" bs=10K \
count=1 >/dev/null 2>&1
run_check $SUDO_HELPER truncate -s 500K "$dirpath/$dataset_type.$num"
run_check $SUDO_HELPER dd if=/dev/urandom of="$dirpath/$dataset_type.$num" bs=10K \
oflag=append conv=notrunc count=1 >/dev/null 2>&1
run_check $SUDO_HELPER truncate -s 800K "$dirpath/$dataset_type.$num"
done
;;
acls)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER touch "$dirpath/$dataset_type.$num"
run_check $SUDO_HELPER setfacl -m "u:root:x" "$dirpath/$dataset_type.$num"
run_check $SUDO_HELPER setfattr -n user.foo -v "bar$num" "$dirpath/$dataset_type.$num"
done
;;
fifo)
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER mkfifo "$dirpath/$dataset_type.$num"
done
;;
slow_symlink)
long_filename=`date +%s | sha256sum | cut -f1 -d'-'`
run_check $SUDO_HELPER touch "$dirpath/$long_filename"
for num in $(seq 1 "$DATASET_SIZE"); do
run_check $SUDO_HELPER ln -s "$dirpath/$long_filename" "$dirpath/slow_slink.$num"
done
;;
esac
}
populate_fs() {
for dataset_type in 'small' 'hardlink' 'fast_symlink' 'brokenlink' 'perm' 'sparse' 'acls' 'fifo' 'slow_symlink'; do

View File

@ -15,7 +15,7 @@ test_extent_tree_rebuild()
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
run_check_mount_test_dev
run_check $SUDO_HELPER cp -aR /lib/modules/`uname -r`/ $TEST_MNT
generate_dataset small
for i in `seq 1 100`;do
run_check $SUDO_HELPER $TOP/btrfs sub snapshot $TEST_MNT \