Merge tag 'drm-fixes-2019-06-21' of git://anongit.freedesktop.org/drm/drm
[linux-2.6-microblaze.git] / tools / testing / selftests / rcutorture / bin / configinit.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Usage: configinit.sh config-spec-file build-output-dir results-dir
5 #
6 # Create a .config file from the spec file.  Run from the kernel source tree.
7 # Exits with 0 if all went well, with 1 if all went well but the config
8 # did not match, and some other number for other failures.
9 #
10 # The first argument is the .config specification file, which contains
11 # desired settings, for example, "CONFIG_NO_HZ=y".  For best results,
12 # this should be a full pathname.
13 #
14 # The second argument is a optional path to a build output directory,
15 # for example, "O=/tmp/foo".  If this argument is omitted, the .config
16 # file will be generated directly in the current directory.
17 #
18 # Copyright (C) IBM Corporation, 2013
19 #
20 # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
21
22 T=${TMPDIR-/tmp}/configinit.sh.$$
23 trap 'rm -rf $T' 0
24 mkdir $T
25
26 # Capture config spec file.
27
28 c=$1
29 buildloc=$2
30 resdir=$3
31 builddir=
32 if echo $buildloc | grep -q '^O='
33 then
34         builddir=`echo $buildloc | sed -e 's/^O=//'`
35         if test ! -d $builddir
36         then
37                 mkdir $builddir
38         fi
39 else
40         echo Bad build directory: \"$buildloc\"
41         exit 2
42 fi
43
44 sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
45 sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
46 grep '^grep' < $T/u.sh > $T/upd.sh
47 echo "cat - $c" >> $T/upd.sh
48 make mrproper
49 make $buildloc distclean > $resdir/Make.distclean 2>&1
50 make $buildloc $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
51 mv $builddir/.config $builddir/.config.sav
52 sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
53 cp $builddir/.config $builddir/.config.new
54 yes '' | make $buildloc oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
55
56 # verify new config matches specification.
57 configcheck.sh $builddir/.config $c
58
59 exit 0