Skip to content

Commit

Permalink
kernel kernel's headers against libiio headers in CI
Browse files Browse the repository at this point in the history
As discussed in #392 and #396, this adds a small shell script which
downloads the kernel's iio header file, and checks channel types and
channel modifiers to make sure we aren't falling behind.

This will be checked once per Travis-CI build, and takes about 0.5 seconds.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Mar 30, 2020
1 parent 67d3c05 commit da9af0e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CI/travis/before_install_linux
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ handle_default() {
sudo apt-get -qq update
sudo apt-get install -y cmake graphviz libaio-dev libavahi-client-dev \
libavahi-common-dev libusb-1.0-0-dev libxml2-dev rpm tar \
bzip2 gzip flex bison git python-pip
bzip2 gzip flex bison git python-pip wget
if [ -n "${GH_DOC_TOKEN}" ] ; then
sudo apt-get install -y doxygen
fi
Expand Down
70 changes: 70 additions & 0 deletions CI/travis/check_kernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
5 changes: 5 additions & 0 deletions CI/travis/make_linux
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi
. CI/travis/lib.sh

handle_default() {
# make sure we are up to date
if [ "$LDIST" = "DO_NOT_DEPLOY" ] ; then
./CI/travis/check_kernel.sh
fi

mkdir -p build
cd build

Expand Down

0 comments on commit da9af0e

Please sign in to comment.