forked from rapido-linux/rapido
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fstests_local_autorun.sh
executable file
·86 lines (67 loc) · 2.3 KB
/
fstests_local_autorun.sh
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
#!/bin/bash
#
# Copyright (C) SUSE LINUX GmbH 2016, all rights reserved.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) version 3.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
if [ ! -f /vm_autorun.env ]; then
echo "Error: autorun scripts must be run from within an initramfs VM"
exit 1
fi
. /vm_autorun.env
set -x
# path to xfstests within the initramfs
XFSTESTS_DIR="/fstests"
hostname_fqn="`cat /proc/sys/kernel/hostname`" || _fatal "hostname unavailable"
hostname_short="${hostname_fqn%%.*}"
filesystem="xfs"
# need hosts file for hostname -s
cat > /etc/hosts <<EOF
127.0.0.1 $hostname_fqn $hostname_short
EOF
# enable debugfs
cat /proc/mounts | grep debugfs &> /dev/null
if [ $? -ne 0 ]; then
mount -t debugfs debugfs /sys/kernel/debug/
fi
cat /proc/mounts | grep configfs &> /dev/null
if [ $? -ne 0 ]; then
mount -t configfs configfs /sys/kernel/config/
fi
modprobe zram num_devices="2" || _fatal "failed to load zram module"
echo "1G" > /sys/block/zram0/disksize || _fatal "failed to set zram disksize"
echo "1G" > /sys/block/zram1/disksize || _fatal "failed to set zram disksize"
mkfs.${filesystem} /dev/zram0 || _fatal "mkfs failed"
mkfs.${filesystem} /dev/zram1 || _fatal "mkfs failed"
for i in $DYN_DEBUG_MODULES; do
echo "module $i +pf" > /sys/kernel/debug/dynamic_debug/control || _fatal
done
for i in $DYN_DEBUG_FILES; do
echo "file $i +pf" > /sys/kernel/debug/dynamic_debug/control || _fatal
done
mkdir -p /mnt/test
mkdir -p /mnt/scratch
mount -t $filesystem /dev/zram0 /mnt/test || _fatal
mount -t $filesystem /dev/zram1 /mnt/scratch || _fatal
if [ -d ${XFSTESTS_DIR} ]; then
cat > ${XFSTESTS_DIR}/configs/`hostname -s`.config << EOF
MODULAR=0
TEST_DIR=/mnt/test
TEST_DEV=/dev/zram0
SCRATCH_MNT=/mnt/scratch
SCRATCH_DEV=/dev/zram1
EOF
fi
set +x
echo "$filesystem filesystem mounted at /mnt/test and /mnt/scratch"
if [ -n "$FSTESTS_AUTORUN_CMD" ]; then
cd ${XFSTESTS_DIR} || _fatal
eval "$FSTESTS_AUTORUN_CMD"
fi