xref: /linux/tools/testing/selftests/rcutorture/bin/configcheck.sh (revision be239684b18e1cdcafcf8c7face4a2f562c745ad)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Usage: configcheck.sh .config .config-template
5#
6# Non-empty output if errors detected.
7#
8# Copyright (C) IBM Corporation, 2011
9#
10# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
11
12T="`mktemp -d ${TMPDIR-/tmp}/configcheck.sh.XXXXXX`"
13trap 'rm -rf $T' 0
14
15# function test_kconfig_enabled ( Kconfig-var=val )
16function test_kconfig_enabled () {
17	if ! grep -q "^$1$" $T/.config
18	then
19		echo :$1: improperly set
20		return 1
21	fi
22	return 0
23}
24
25# function test_kconfig_disabled ( Kconfig-var )
26function test_kconfig_disabled () {
27	if grep -q "^$1=n$" $T/.config
28	then
29		return 0
30	fi
31	if grep -q "^$1=" $T/.config
32	then
33		echo :$1=n: improperly set
34		return 1
35	fi
36	return 0
37}
38
39sed -e 's/"//g' < $1 > $T/.config
40sed -e 's/^#CHECK#//' < $2 > $T/ConfigFragment
41grep '^CONFIG_.*=n$' $T/ConfigFragment |
42	sed -e 's/^/test_kconfig_disabled /' -e 's/=n$//' > $T/kconfig-n.sh
43. $T/kconfig-n.sh
44grep -v '^CONFIG_.*=n$' $T/ConfigFragment | grep '^CONFIG_' |
45	sed -e 's/^/test_kconfig_enabled /' > $T/kconfig-not-n.sh
46. $T/kconfig-not-n.sh
47