xfs/040: use compare-libxfs in xfsprogs
[xfstests-dev.git] / tools / mvtest
1 #!/bin/sh
2
3 # Renumber a test
4 dir="$(dirname "$0")"
5
6 if [ -z "$1" ] || [ "$1" = "--help" ]; then
7         echo "Usage: $0 path_to_test new_path_to_test"
8         exit 1
9 fi
10
11 src="$1"
12 dest="$2"
13
14 die() {
15         echo "$@"
16         exit 1
17 }
18
19 append() {
20         out="$1"
21         shift
22         echo "$@" >> "${out}"
23 }
24
25 test "${src}" != "${dest}" || die "Test \"${src}\" is the same as dest."
26 test -e "tests/${src}" || die "Test \"${src}\" does not exist."
27 test ! -e "tests/${dest}" || die "Test \"${src}\" already exists."
28
29 sid="$(basename "${src}")"
30 did="$(basename "${dest}")"
31
32 sgroup="$(basename "$(dirname "tests/${src}")")"
33 dgroup="$(basename "$(dirname "tests/${dest}")")"
34
35 sgroupfile="tests/${sgroup}/group"
36 dgroupfile="tests/${dgroup}/group"
37
38 git mv "tests/${src}" "tests/${dest}"
39 git mv "tests/${src}.out" "tests/${dest}.out"
40 sed -e "s/^# FS[[:space:]]*QA.*Test.*[0-9]\+$/# FS QA Test No. ${did}/g" -i "tests/${dest}"
41 sed -e "s/^QA output created by ${sid}$/QA output created by ${did}/g" -i "tests/${dest}.out"
42 sed -e "s/test-${sid}/test-${did}/g" -i "tests/${dest}.out"
43
44 grpline="$(grep "^${sid} " "${sgroupfile}")"
45 newgrpline="$(echo "${grpline}" | sed -e "s/^${sid} /${did} /g")"
46
47 sed -e "/^${sid} .*$/d" -i "${sgroupfile}"
48 cp "${dgroupfile}" "${dgroupfile}.new"
49 append "${dgroupfile}.new" "${newgrpline}"
50 "${dir}/sort-group" "${dgroupfile}.new"
51 mv "${dgroupfile}.new" "${dgroupfile}"
52
53 echo "Moved \"${src}\" to \"${dest}\"."
54
55 exit 0