File: clean-tests.sh

package info (click to toggle)
btrfs-progs 6.2-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,244 kB
  • sloc: ansic: 114,376; sh: 9,576; python: 1,242; makefile: 820
file content (61 lines) | stat: -rwxr-xr-x 1,548 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# remove all intermediate files from tests

LANG=C
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
if [ -z "$TOP" ]; then
	TOP=$(readlink -f "$SCRIPT_DIR/../")
	if [ -f "$TOP/configure.ac" ]; then
		# inside git
		TEST_TOP="$TOP/tests"
		INTERNAL_BIN="$TOP"
	else
		# external, defaults to system binaries
		TOP=$(dirname `type -p btrfs`)
		TEST_TOP="$SCRIPT_DIR"
		INTERNAL_BIN="$TEST_TOP"
	fi
else
	# assume external, TOP set from commandline
	TEST_TOP="$SCRIPT_DIR"
	INTERNAL_BIN="$TEST_TOP"
fi
if ! [ -x "$TOP/btrfs" ]; then
	echo "WARNING: cannot find btrfs in TOP=$TOP"
fi
TEST_DEV=${TEST_DEV:-}
RESULTS="$TEST_TOP/cli-tests-results.txt"
IMAGE="$TEST_TOP/test.img"

source "$TEST_TOP/common"

setup_root_helper

if [ "$BUILD_VERBOSE" = 1 ]; then
	verbose=-print
fi

[ "$BUILD_VERBOSE" = 1 ] && echo "Umount $TEST_MNT"
$SUDO_HELPER umount -R "$TEST_MNT" &>/dev/null

if ! cd "$TEST_TOP"; then
	echo "ERROR: cannot cd to $TEST_TOP"
	exit 1
fi

[ "$BUILD_VERBOSE" = 1 ] && echo "Delete temporary fsck images $TEST_MNT"
find fsck-tests -type f -name '*.restored' $verbose -delete

for dev in $(losetup --noheadings --output NAME,BACK-FILE | grep "$SCRIPT_DIR"); do
	# Accept only /dev/loop0
	# And skip $SCRIPT_DIR/cli-tests/001-test/img1
	if [[ $dev =~ ^/dev/loop ]]; then
		lfile=$(losetup --noheadings --output BACK-FILE "$dev")
		[ "$BUILD_VERBOSE"  = 1 ] &&
			echo "Detach loop device/file $dev ($lfile)"
		$SUDO_HELPER losetup --detach "$dev"
	fi
done

# do not remove, the file could have special permissions set
echo -n > test.img