-
Notifications
You must be signed in to change notification settings - Fork 2
/
x-checks
executable file
·94 lines (76 loc) · 2.93 KB
/
x-checks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
#
# Run various static checkers on one specific commit
# * sparse
# * smatch
# # checkpatch
if [ "$#" -gt 1 ]; then
echo "Usage: x checks <commit sha1>"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
if [ "$#" -gt 0 ]; then
SHA1=$1
else
SHA1="HEAD"
fi
REPORT_FILE=$(mktemp)
numb_of_cpus
NUMB_OF_CPUS=$REPLY
function do_one {
SHA1=$1
REPORT_FILE=$2
PDIR=$(mktemp -d)
git worktree add $PDIR $SHA1
echo "Redirecting the output to $REPORT_FILE"
pushd $PDIR &>> $REPORT_FILE
VER=$( less $KCONFIG | head -n 3 | tail -n 1 )
echo $VER &>> $REPORT_FILE
echo "========================================" &>> $REPORT_FILE
x checkpatch HEAD $PDIR &>> $REPORT_FILE
echo "===== ALL MOD COMPILE (subdir) =========" &>> $REPORT_FILE
make allmodconfig &>> $REPORT_FILE
make -s -j $NUMB_OF_CPUS drivers/infiniband/ drivers/net/ethernet/mellanox/ &>> $REPORT_FILE
echo "===== ALL YES COMPILE (subdir) =========" &>> $REPORT_FILE
make allyesconfig &>> $REPORT_FILE
make -s -j $NUMB_OF_CPUS drivers/infiniband/ drivers/net/ethernet/mellanox/ &>> $REPORT_FILE
echo "===== ALL NO COMPILE (subdir) =========" &>> $REPORT_FILE
make allnoconfig &>> $REPORT_FILE
make -s -j $NUMB_OF_CPUS drivers/infiniband/ drivers/net/ethernet/mellanox/ &>> $REPORT_FILE
make clean -j $NUMB_OF_CPUS &>> /dev/null
cp $KCONFIG .config &>> $REPORT_FILE
make olddefconfig &>> $REPORT_FILE
echo "===== FULL COMPILE =========" &>> $REPORT_FILE
make -s -j $NUMB_OF_CPUS &>> $REPORT_FILE
# Checkers runs with allyes in clean env
make clean -j $NUMB_OF_CPUS &>> /dev/null
make allyesconfig &>> /dev/null
# CLOSED, too many warnings
#echo "===== SUB COMPILE =========" &>> $REPORT_FILE
#make -s -j $NUMB_OF_CPUS W=1 drivers/infiniband/ drivers/net/ethernet/mellanox/ &>> $REPORT_FILE
echo "===== SMATCH =========" &>> $REPORT_FILE
make -s -j $NUMB_OF_CPUS CHECK="$SMATCH -p=kernel" C=1 drivers/infiniband/ drivers/net/ethernet/mellanox/ &>> $REPORT_FILE
make clean -j $NUMB_OF_CPUS &>> /dev/null
make allyesconfig &>> /dev/null
echo "===== SPARSE =========" &>> $REPORT_FILE
make -s -j $NUMB_OF_CPUS CHECK="$SPARSE" C=2 drivers/infiniband/ drivers/net/ethernet/mellanox/ &>> $REPORT_FILE
popd &>> $REPORT_FILE
# TODO: separate checkpatch errors, sparse, smatch
NUMB_OF_ERRORS=$(awk -F": " '{print $1}' $REPORT_FILE | grep ":" | sort | uniq |wc -l)
LAST_NUMB_OF_ERRORS=$(head -1 $CHECKS_LOG | awk '{print $1}')
DELTA=$((NUMB_OF_ERRORS-LAST_NUMB_OF_ERRORS))
if [ "$DELTA" -gt "0" ]; then
DELTA="+$DELTA";
fi
echo "There are $NUMB_OF_ERRORS errors/warnings, delta: $DELTA."
tac $CHECKS_LOG > $PDIR/x-checks.tac
echo "$NUMB_OF_ERRORS $DELTA $(git log --abbrev=12 -1 --format='%h "%s"')" >> $PDIR/x-checks.tac
tac $PDIR/x-checks.tac > $CHECKS_LOG
mkdir -p $X_LOGS/ci
cp -f $REPORT_FILE $X_LOGS/ci/$(git log --abbrev=12 -1 --format='%h')
rm -rf $PDIR
git worktree prune
}
do_one $SHA1 $REPORT_FILE