Skip to content

Commit

Permalink
CI: Check Python enums are in sync with latest kernel
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jan 27, 2025
1 parent af56648 commit 17bc457
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions CI/azure/check_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ KERNEL_MODIFIER="/tmp/modifier.c"
IIOH="./include/iio/iio.h"
CHANNELC="./channel.c"
CHANNELC_SHARP="./bindings/csharp/Channel.cs"
IIO_PY="./bindings/python/iio.py"

if [ ! -f ${IIOH} ] ; then
echo can not find ${IIOH}
Expand All @@ -22,6 +23,11 @@ if [ ! -f ${CHANNELC_SHARP} ] ; then
exit 1
fi

if [ ! -f ${IIO_PY} ] ; then
echo can not find ${IIO_PY}
exit 1
fi

rm -f ${KERNEL_TYPES} ${KERNEL_MODIFIER}
wget -O ${KERNEL_TYPES} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/iio/types.h
wget -O ${KERNEL_MODIFIER} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/drivers/iio/industrialio-core.c
Expand Down Expand Up @@ -118,5 +124,29 @@ do
fi
done

echo Checking Python bindings

python_enums=("ChannelType" "ChannelModifier" "EventType" "EventDirection")

for i in {0..3}
do
echo "looking for ${python_enums[i]}"
sed "0,/^class ${python_enums[i]}/d" ${IIO_PY} | \
sed '0,/^$/d' | sed -n '/^$/q;p'| sed -e 's/^[ \t]*//' -e 's/ .*//' | \
grep -v IIO_CHAN_TYPE_UNKNOWN > "/tmp/libiio_py_${python_enums[i]}"

echo "Differences in ${python_enums[i]}"
set +e
diff -u -w "/tmp/libiio_py_${python_enums[i]}" "/tmp/kernel_${iio_groups[i]}"
count=$(diff -u -w "/tmp/libiio_py_${python_enums[i]}" "/tmp/kernel_${iio_groups[i]}" | wc -l)
set -e
if [ "$count" -ne "0" ] ; then
ret=1
echo "difference between upstream kernel types.h and iio.py in ${python_enums[i]}"
else
echo none
fi
done

rm -f /tmp/kernel_modifier /tmp/libiio_iio_modifier /tmp/libiio_iio_chan_type ${KERNEL_TYPES} ${KERNEL_MODIFIER}
exit $ret

0 comments on commit 17bc457

Please sign in to comment.