Debian Codegraph @

test/virttest.sh

raw symbols SCIP
1 #!/bin/bash
2 #
3 # Copyright (C) 2017 - 2022, Stephan Mueller <[email protected]>
4 #
5 # License: see LICENSE file in root directory
6 #
7 # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
9 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
10 # WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
11 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
12 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
13 # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
14 # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
15 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
16 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
17 # USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
18 # DAMAGE.
19 #
20
21 DIRNAME="$(dirname "$0")"
22 . "$DIRNAME/libtest.sh"
23
24 ###################################################################
25 # Test configuration - may be changed
26 ###################################################################
27
28 # The KERNEL_BASE points to the directory where the linux kernel sources
29 # are located. These kernel sources must be properly configured as
30 # documented in https://github.com/vincentbernat/eudyptula-boot
31 #
32 # If needed, the kernel is automatically compiled and installed
33 # for use by eudyptula-boot.
34 #
35 # Note, this must be an absolute path name
36 KERNEL_BASE=$1
37 if [ -z "$KERNEL_BASE" -a -h "./kernel-sources" ]
38 then
39 KERNEL_BASE="$(readlink ./kernel-sources)"
40 else
41 echo_deact "Linux kernel sources directory not found - skipping eudyptula-boot tests"
42 exit 0
43 fi
44
45 # TESTKERNELS specifies the kernel versions (i.e. Linux kernel
46 # source code directories) to be used and tested
47 TESTKERNELS="linux-5.12 linux-5.9 linux-5.8 linux-5.1 linux-4.20 linux-4.17 linux-4.13 linux-4.12 linux-4.10 linux-4.7 linux-4.5 linux-4.4.86 linux-4.3.6"
48
49 ###################################################################
50 # General variables - do not change
51 ###################################################################
52
53 # We need to provide an absolute path name
54 if [ x"${a:0:1}" = x"/" ]
55 then
56 SCRIPT="$DIRNAME/test-invocation.sh"
57 else
58 SCRIPT="$(pwd)/$DIRNAME/test-invocation.sh"
59 fi
60 EUDYPTULA="${EUDYPTULA:-"${HOME}/bin/eudyptula-boot"}"
61
62 ###################################################################
63 # Code - do not change
64 ###################################################################
65 execvirt()
66 {
67 local script=$1
68 local kernel_ver=$2
69
70 local depmod=0
71 local kernel_src="${KERNEL_BASE}/${kernel_ver}"
72 local kernel_build="${KERNEL_BASE}/build/${kernel_ver}"
73 local kernel_binary=""
74 local moddir=""
75
76 echo "Testing Linux kernel version $kernel_ver in directory $KERNEL_BASE"
77
78 if [ ! -d "$kernel_src" ]
79 then
80 echo "No kernel source directory found"
81 exit 1
82 fi
83 cd $kernel_src
84
85 if [ ! -f .config ]
86 then
87 echo "No configured kernel found in $(pwd)"
88 exit 1
89 fi
90 if ! grep -q "CONFIG_9P_FS=y" .config
91 then
92 echo "No virtme compliant kernel config found"
93 exit 1
94 fi
95
96 # Build and install fully configured kernel
97 if [ ! -d ${kernel_build} ]
98 then
99 make -j2
100 make modules_install install INSTALL_MOD_PATH=${kernel_build} INSTALL_PATH=${kernel_build}
101 depmod=1
102 fi
103
104 # get latest modules directory
105 moddir=${kernel_build}/lib/modules
106 local version=$(ls -t ${moddir} | head -n1)
107 moddir=${moddir}/$version
108 if [ ! -d "$moddir" ]
109 then
110 echo "No directory $moddir"
111 exit 1
112 fi
113
114 kernel_binary=${kernel_build}/vmlinuz-$version
115 if [ ! -f $kernel_binary ]
116 then
117 echo "Kernel binary $kernel_binary not found"
118 exit 1
119 fi
120
121 if [ $depmod -ne 0 ]
122 then
123 depmod -b ${kernel_build} $version
124 fi
125
126 $EUDYPTULA --kernel $kernel_binary $script
127 if [ $? -ne 0 ]
128 then
129 local ret=$?
130 echo_fail "Test for kernel version $kernel_ver failed"
131 exit $ret
132 fi
133 }
134
135 if [ ! -x $EUDYPTULA ]
136 then
137 echo_deact "$EUDYPTULA not found"
138 exit 0
139 fi
140
141 for i in ${TESTKERNELS}
142 do
143 execvirt $SCRIPT $i
144 done