Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / tools / testing / selftests / rcutorture / bin / kvm-build.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Build a kvm-ready Linux kernel from the tree in the current directory.
5 #
6 # Usage: kvm-build.sh config-template resdir
7 #
8 # Copyright (C) IBM Corporation, 2011
9 #
10 # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
11
12 config_template=${1}
13 if test -z "$config_template" -o ! -f "$config_template" -o ! -r "$config_template"
14 then
15         echo "kvm-build.sh :$config_template: Not a readable file"
16         exit 1
17 fi
18 resdir=${2}
19
20 T=${TMPDIR-/tmp}/test-linux.sh.$$
21 trap 'rm -rf $T' 0
22 mkdir $T
23
24 cp ${config_template} $T/config
25 cat << ___EOF___ >> $T/config
26 CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
27 CONFIG_VIRTIO_PCI=y
28 CONFIG_VIRTIO_CONSOLE=y
29 ___EOF___
30
31 configinit.sh $T/config $resdir
32 retval=$?
33 if test $retval -gt 1
34 then
35         exit 2
36 fi
37 ncpus=`cpus2use.sh`
38 make -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
39 retval=$?
40 if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
41 then
42         echo Kernel build error
43         egrep "Stop|Error|error:|warning:" < $resdir/Make.out
44         echo Run aborted.
45         exit 3
46 fi