generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tools / mvtest
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle.  All Rights Reserved.
4 #
5 # Move a test and update the golden output file.
6
7 dir="$(dirname "$0")"
8
9 if [ -z "$1" ] || [ "$1" = "--help" ]; then
10         echo "Usage: $0 path_to_test new_path_to_test"
11         exit 1
12 fi
13
14 src="$1"
15 dest="$2"
16
17 die() {
18         echo "$@"
19         exit 1
20 }
21
22 append() {
23         out="$1"
24         shift
25         echo "$@" >> "${out}"
26 }
27
28 test "${src}" != "${dest}" || die "Test \"${src}\" is the same as dest."
29 test -e "tests/${src}" || die "Test \"${src}\" does not exist."
30 test ! -e "tests/${dest}" || die "Test \"${src}\" already exists."
31
32 sid="$(basename "${src}")"
33 did="$(basename "${dest}")"
34
35 git mv "tests/${src}" "tests/${dest}"
36 git mv "tests/${src}.out" "tests/${dest}.out"
37 sed -e "s/^# FS[[:space:]]*QA.*Test.*[0-9]\+$/# FS QA Test No. ${did}/g" -i "tests/${dest}"
38 sed -e "s/^QA output created by ${sid}$/QA output created by ${did}/g" -i "tests/${dest}.out"
39 sed -e "s/test-${sid}/test-${did}/g" -i "tests/${dest}.out"
40
41 echo "Moved \"${src}\" to \"${dest}\"."
42
43 exit 0