xref: /OK3568_Linux_fs/kernel/tools/testing/selftests/rcutorture/bin/configinit.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/bash
2*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0+
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun# Usage: configinit.sh config-spec-file results-dir
5*4882a593Smuzhiyun#
6*4882a593Smuzhiyun# Create a .config file from the spec file.  Run from the kernel source tree.
7*4882a593Smuzhiyun# Exits with 0 if all went well, with 1 if all went well but the config
8*4882a593Smuzhiyun# did not match, and some other number for other failures.
9*4882a593Smuzhiyun#
10*4882a593Smuzhiyun# The first argument is the .config specification file, which contains
11*4882a593Smuzhiyun# desired settings, for example, "CONFIG_NO_HZ=y".  For best results,
12*4882a593Smuzhiyun# this should be a full pathname.
13*4882a593Smuzhiyun#
14*4882a593Smuzhiyun# Copyright (C) IBM Corporation, 2013
15*4882a593Smuzhiyun#
16*4882a593Smuzhiyun# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunT=${TMPDIR-/tmp}/configinit.sh.$$
19*4882a593Smuzhiyuntrap 'rm -rf $T' 0
20*4882a593Smuzhiyunmkdir $T
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun# Capture config spec file.
23*4882a593Smuzhiyun
24*4882a593Smuzhiyunc=$1
25*4882a593Smuzhiyunresdir=$2
26*4882a593Smuzhiyun
27*4882a593Smuzhiyunsed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
28*4882a593Smuzhiyunsed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
29*4882a593Smuzhiyungrep '^grep' < $T/u.sh > $T/upd.sh
30*4882a593Smuzhiyunecho "cat - $c" >> $T/upd.sh
31*4882a593Smuzhiyunif test -z "$TORTURE_TRUST_MAKE"
32*4882a593Smuzhiyunthen
33*4882a593Smuzhiyun	make clean > $resdir/Make.clean 2>&1
34*4882a593Smuzhiyunfi
35*4882a593Smuzhiyunmake $TORTURE_KMAKE_ARG $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
36*4882a593Smuzhiyunmv .config .config.sav
37*4882a593Smuzhiyunsh $T/upd.sh < .config.sav > .config
38*4882a593Smuzhiyuncp .config .config.new
39*4882a593Smuzhiyunyes '' | make $TORTURE_KMAKE_ARG oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun# verify new config matches specification.
42*4882a593Smuzhiyunconfigcheck.sh .config $c
43*4882a593Smuzhiyun
44*4882a593Smuzhiyunexit 0
45