-
Notifications
You must be signed in to change notification settings - Fork 202
/
ocfs2test
executable file
·92 lines (67 loc) · 2.56 KB
/
ocfs2test
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# - test
shopt -s nullglob
. $LKP_SRC/lib/fs_ext.sh
. $LKP_SRC/lib/debug.sh
. $LKP_SRC/lib/reproduce-log.sh
. $LKP_SRC/lib/upload.sh
## test on a single node currently.
OCFS2TEST_HOME="/home/ocfs2test"
check_add_user()
{
[[ "x$1" != "x" ]] || return
grep -q "$1" /etc/passwd && return
useradd -m -d "/home/$1" -s /bin/bash "$1" || die "create user $1 failed."
}
setup_test_env()
{
# "ocfs2test" user is required in ocfs2 test, thus check if such user
# has already been added. If not, add "ocfs2test" user.
check_add_user "ocfs2test"
[[ -d $BENCHMARK_ROOT/ocfs2test/ocfs2 ]] || die "can not find ocfs2 dir"
cp -r $BENCHMARK_ROOT/ocfs2test/ocfs2 $OCFS2TEST_HOME
# the -k parameter is required in ocfs2test,
# but only testcase buildkernel needs linux-kernel.tar.gz
# since we have kernel build already, so ignore buildkernel testcase,
# and fake an empty linux-kernel.tar.gz for other testcases can be running.
mkdir -p linux-kernel
tar -zcvf $OCFS2TEST_HOME/linux-kernel.tar.gz linux-kernel
[[ -f $BENCHMARK_ROOT/ocfs2test/reflink ]] || die "can not find reflink file"
ln -sf $BENCHMARK_ROOT/ocfs2test/reflink /usr/local/bin/reflink
timing=$(ls $BENCHMARK_ROOT/ocfs2test/timing-*.tar.gz)
[[ -f $timing ]] || die "can not find timing*.tar.gz file"
pip install $timing
# add /sbin to PATH for some ocfs2 command.
echo "PATH=$PATH:/sbin" >> $OCFS2TEST_HOME/.bashrc
su - ocfs2test -c "source .bashrc"
# add "ocfs2test" user into sudo list
echo "ocfs2test ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# due to the type of disk is not limited.
# here we have to consider getting SSD or HDD partitions.
# get SSD partitions firstly, if not get, and then get the HDD partitions.
# if both SSD and HDD partitions are not exsit, exit error.
if [[ -n "$ssd_partitions" ]]; then
partition=${ssd_partitions%% *}
else
[[ -n "$hdd_partitions" ]] || die "SSD and HDD partitions are not exist."
partition=${hdd_partitions%% *}
fi
partition=$(realpath $partition | head -n 1)
chmod 755 $partition
[[ -d /mnt/ocfs2 ]] || mkdir -p /mnt/ocfs2
umount /mnt/ocfs2 2>/dev/null
return 0
}
single_node_test()
{
local test_dir="$LKP_SRC/pkg/ocfs2test-addon/tests"
while read -r test_name
do
su - ocfs2test -c "$OCFS2TEST_HOME/ocfs2/bin/single_run-WIP.sh -k $OCFS2TEST_HOME/linux-kernel.tar.gz \
-m /mnt/ocfs2 -l $OCFS2TEST_HOME/ocfs2log -t $test_name -d $partition"
done < $test_dir/$test
find $OCFS2TEST_HOME/ocfs2log -name single_run.log -type f | xargs cat
}
setup_test_env
start_o2cb || die "add single cluster to /etc/ocfs2/cluster.conf failed."
single_node_test