smatch_data/kernel.unreachable.ignore: add BUG(), WARN_ON() and others
[smatch.git] / smatch_scripts / test_generic.sh
blob5707d7c6ae70bacd0d0435a302c8bbff67f033b7
1 #!/bin/bash
3 NR_CPU=$(cat /proc/cpuinfo | grep ^processor | wc -l)
4 TARGET=""
5 WLOG="smatch_warns.txt"
6 LOG="smatch_compile.warns"
7 function usage {
8 echo
9 echo "Usage: $0 [smatch options]"
10 echo "Compiles the kernel with -j${NR_CPU}"
11 echo " available options:"
12 echo " --endian : enable endianess check"
13 echo " --target {TARGET} : specify build target, default: $TARGET"
14 echo " --log {FILE} : Output compile log to file, default is: $LOG"
15 echo " --wlog {FILE} : Output warnigs to file, default is: $WLOG"
16 echo " --help : Show this usage"
17 exit 1
21 while true ; do
22 if [[ "$1" == "--endian" ]] ; then
23 ENDIAN="CF=-D__CHECK_ENDIAN__"
24 shift
25 elif [[ "$1" == "--target" ]] ; then
26 shift
27 TARGET="$1"
28 shift
29 elif [[ "$1" == "--log" ]] ; then
30 shift
31 LOG="$1"
32 shift
33 elif [[ "$1" == "--wlog" ]] ; then
34 shift
35 WLOG="$1"
36 shift
37 elif [[ "$1" == "--help" ]] ; then
38 usage
39 else
40 break
42 done
44 SCRIPT_DIR=$(dirname $0)
45 if [ -e $SCRIPT_DIR/../smatch ] ; then
46 cp $SCRIPT_DIR/../smatch $SCRIPT_DIR/../bak.smatch
47 CMD=$SCRIPT_DIR/../bak.smatch
48 elif which smatch | grep smatch > /dev/null ; then
49 CMD=smatch
50 else
51 echo "Smatch binary not found."
52 exit 1
55 if [[ ! -z $ARCH ]]; then
56 KERNEL_ARCH="ARCH=$ARCH"
58 if [[ ! -z $CROSS_COMPILE ]] ; then
59 KERNEL_CROSS_COMPILE="CROSS_COMPILE=$CROSS_COMPILE"
62 make $KERNEL_ARCH $KERNEL_CROSS_COMPILE clean
63 find -name \*.c.smatch -exec rm \{\} \;
64 make $KERNEL_ARCH $KERNEL_CROSS_COMPILE -j${NR_CPU} $ENDIAN -k CHECK="$CMD --file-output $*" \
65 C=1 $TARGET 2>&1 | tee $LOG
66 find -name \*.c.smatch -exec cat \{\} \; -exec rm \{\} \; > $WLOG
68 echo "Done. The warnings are saved to $WLOG"