-
Notifications
You must be signed in to change notification settings - Fork 318
/
check_kernel.sh
executable file
·70 lines (59 loc) · 1.77 KB
/
check_kernel.sh
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
#!/bin/bash
set -e
KERNEL_TYPES="/tmp/mainline_types.h"
IIOH="./iio.h"
CHANNELC="./channel.c"
if [ ! -f ${IIOH} ] ; then
echo can not find ${IIOH}
exit 1
fi
if [ ! -f ${CHANNELC} ] ; then
echo can not find ${CHANNELC}
exit 1
fi
rm -f ${KERNEL_TYPES}
wget -O ${KERNEL_TYPES} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/iio/types.h
ret=0
for enum in iio_chan_type iio_modifier
do
echo looking for ${enum}
rm -f /tmp/kernel_${enum} /tmp/libiio_${enum}
sed "0,/${enum}/d" ${KERNEL_TYPES} | sed -n '/}/q;p' > /tmp/kernel_${enum}
sed "0,/^enum.*${enum}/d" ${IIOH} | sed -n '/}/q;p' | grep -v IIO_CHAN_TYPE_UNKNOWN > /tmp/libiio_${enum}
echo Differences in ${enum}
# diff exit status of 1 means a difference, not an error
set +e
diff -u /tmp/libiio_${enum} /tmp/kernel_${enum}
count=$(diff -u /tmp/libiio_${enum} /tmp/kernel_${enum} | wc -l)
set -e
if [ "$count" -ne "0" ] ; then
ret=1
echo difference between upstream kernel types.h and iio.h in ${enum}
else
echo none
fi
done
for enum in iio_chan_type_name_spec modifier_names
do
sed "0,/^static.*${enum}/d" ${CHANNELC} | sed -n '/}/q;p' | \
grep -v IIO_CHAN_TYPE_UNKNOWN > /tmp/libiio_${enum}
done
while IFS="" read -r p ; do
key=$(echo ${p//[[:space:],]/})
count=$(grep "\[$key\]" /tmp/libiio_iio_chan_type_name_spec | wc -l)
if [ "$count" -eq "0" ] ; then
echo "$key missing from channel.c iio_chan_type_name_spec"
ret=1
fi
done < /tmp/libiio_iio_chan_type
echo
sed -i '/IIO_NO_MOD/d' /tmp/libiio_iio_modifier
while IFS="" read -r p ; do
key=$(echo "${p//[[:space:],]/}")
count=$(grep "\[$key\]" /tmp/libiio_modifier_names | wc -l)
if [ "$count" -eq "0" ] ; then
echo "$key missing from channel.c modifier_names"
ret=1
fi
done < /tmp/libiio_iio_modifier
exit $ret