Merge pull request #17 from luis-henrix/pr_hardcoded_lib_paths
[ddiss/rapido.git] / fstests_local_autorun.sh
1 #!/bin/bash
2 #
3 # Copyright (C) SUSE LINUX GmbH 2016, all rights reserved.
4 #
5 # This library is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published
7 # by the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) version 3.
9 #
10 # This library is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
13 # License for more details.
14
15 if [ ! -f /vm_autorun.env ]; then
16         echo "Error: autorun scripts must be run from within an initramfs VM"
17         exit 1
18 fi
19
20 . /vm_autorun.env
21
22 set -x
23
24 # path to xfstests within the initramfs
25 XFSTESTS_DIR="/fstests"
26
27 hostname_fqn="`cat /proc/sys/kernel/hostname`" || _fatal "hostname unavailable"
28 hostname_short="${hostname_fqn%%.*}"
29 filesystem="xfs"
30
31 # need hosts file for hostname -s
32 cat > /etc/hosts <<EOF
33 127.0.0.1       $hostname_fqn   $hostname_short
34 EOF
35
36
37 # enable debugfs
38 cat /proc/mounts | grep debugfs &> /dev/null
39 if [ $? -ne 0 ]; then
40         mount -t debugfs debugfs /sys/kernel/debug/
41 fi
42
43 cat /proc/mounts | grep configfs &> /dev/null
44 if [ $? -ne 0 ]; then
45         mount -t configfs configfs /sys/kernel/config/
46 fi
47
48 modprobe zram num_devices="2" || _fatal "failed to load zram module"
49
50 echo "1G" > /sys/block/zram0/disksize || _fatal "failed to set zram disksize"
51 echo "1G" > /sys/block/zram1/disksize || _fatal "failed to set zram disksize"
52
53 mkfs.${filesystem} /dev/zram0 || _fatal "mkfs failed"
54 mkfs.${filesystem} /dev/zram1 || _fatal "mkfs failed"
55
56 for i in $DYN_DEBUG_MODULES; do
57         echo "module $i +pf" > /sys/kernel/debug/dynamic_debug/control || _fatal
58 done
59 for i in $DYN_DEBUG_FILES; do
60         echo "file $i +pf" > /sys/kernel/debug/dynamic_debug/control || _fatal
61 done
62
63 mkdir -p /mnt/test
64 mkdir -p /mnt/scratch
65
66 mount -t $filesystem /dev/zram0 /mnt/test || _fatal
67 mount -t $filesystem /dev/zram1 /mnt/scratch || _fatal
68
69 if [ -d ${XFSTESTS_DIR} ]; then
70         cat > ${XFSTESTS_DIR}/configs/`hostname -s`.config << EOF
71 MODULAR=0
72 TEST_DIR=/mnt/test
73 TEST_DEV=/dev/zram0
74 SCRATCH_MNT=/mnt/scratch
75 SCRATCH_DEV=/dev/zram1
76 EOF
77 fi
78
79 set +x
80
81 echo "$filesystem filesystem mounted at /mnt/test and /mnt/scratch"
82
83 if [ -n "$FSTESTS_AUTORUN_CMD" ]; then
84         cd ${XFSTESTS_DIR} || _fatal
85         eval "$FSTESTS_AUTORUN_CMD"
86 fi