xref: /openbmc/linux/tools/testing/selftests/rcutorture/bin/configcheck.sh (revision e65e175b07bef5974045cc42238de99057669ca7)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Usage: configcheck.sh .config .config-template
5#
6# Copyright (C) IBM Corporation, 2011
7#
8# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
9
10T="`mktemp -d ${TMPDIR-/tmp}/configcheck.sh.XXXXXX`"
11trap 'rm -rf $T' 0
12
13cat $1 > $T/.config
14
15cat $2 | sed -e 's/\(.*\)=n/# \1 is not set/' -e 's/^#CHECK#//' |
16grep -v '^CONFIG_INITRAMFS_SOURCE' |
17awk	'
18{
19		print "if grep -q \"" $0 "\" < '"$T/.config"'";
20		print "then";
21		print "\t:";
22		print "else";
23		if ($1 == "#") {
24			print "\tif grep -q \"" $2 "\" < '"$T/.config"'";
25			print "\tthen";
26			print "\t\tif test \"$firsttime\" = \"\""
27			print "\t\tthen"
28			print "\t\t\tfirsttime=1"
29			print "\t\tfi"
30			print "\t\techo \":" $2 ": improperly set\"";
31			print "\telse";
32			print "\t\t:";
33			print "\tfi";
34		} else {
35			print "\tif test \"$firsttime\" = \"\""
36			print "\tthen"
37			print "\t\tfirsttime=1"
38			print "\tfi"
39			print "\techo \":" $0 ": improperly set\"";
40		}
41		print "fi";
42	}' | sh
43