Linux-libre 5.7.5-gnu
[librecmc/linux-libre.git] / tools / testing / selftests / rcutorture / bin / configNR_CPUS.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Extract the number of CPUs expected from the specified Kconfig-file
5 # fragment by checking CONFIG_SMP and CONFIG_NR_CPUS.  If the specified
6 # file gives no clue, base the number on the number of idle CPUs on
7 # the system.
8 #
9 # Usage: configNR_CPUS.sh config-frag
10 #
11 # Copyright (C) IBM Corporation, 2013
12 #
13 # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
14
15 cf=$1
16 if test ! -r $cf
17 then
18         echo Unreadable config fragment $cf 1>&2
19         exit -1
20 fi
21 if grep -q '^CONFIG_SMP=n$' $cf
22 then
23         echo 1
24         exit 0
25 fi
26 if grep -q '^CONFIG_NR_CPUS=' $cf
27 then
28         grep '^CONFIG_NR_CPUS=' $cf | 
29                 sed -e 's/^CONFIG_NR_CPUS=\([0-9]*\).*$/\1/'
30         exit 0
31 fi
32 cpus2use.sh