From 3424fb83c3c6a8059d003a86d6b0d1eb69229fab Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Wed, 14 Feb 2018 10:13:11 +0100 Subject: [PATCH] Script to check that the lists of helpers are in sync Checks src/cc/libbpf.c, docs/kernel-versions.md, src/cc/compat/linux/bpf.h, and src/cc/export/helpers.h. --- .travis.yml | 1 + scripts/check-helpers.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 scripts/check-helpers.sh diff --git a/.travis.yml b/.travis.yml index 736ddad80a5e..dd36669038f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,5 @@ install: - sudo apt-get install -y python-pip - sudo pip install pep8 script: + - ./scripts/check-helpers.sh - find tools/ -type f -name "*.py" | xargs pep8 -r --show-source --ignore=E123,E125,E126,E127,E128,E302 diff --git a/scripts/check-helpers.sh b/scripts/check-helpers.sh new file mode 100755 index 000000000000..9350aedc9e35 --- /dev/null +++ b/scripts/check-helpers.sh @@ -0,0 +1,29 @@ +#!/bin/bash +ret=0 + +grep -oP '(?<={")\w+(?=", "\d\.\d+")' src/cc/libbpf.c | sort > /tmp/libbpf.txt +grep -oP "(?<=BPF_FUNC_)\w+" docs/kernel-versions.md | sort > /tmp/doc.txt +dif=`diff /tmp/libbpf.txt /tmp/doc.txt` +if [ $? -ne 0 ]; then + echo "The lists of helpers in src/cc/libbpf.c and docs/kernel-versions.md differ:" + echo -e "$dif\n" + ((ret++)) +fi + +grep -oP "(?<=^\sFN\()\w+" src/cc/compat/linux/bpf.h | tail -n +2 | sort > /tmp/compat.txt +dif=`diff /tmp/doc.txt /tmp/compat.txt` +if [ $? -ne 0 ]; then + echo "The lists of helpers in docs/kernel-versions.md and src/cc/compat/linux/bpf.h differ:" + echo -e "$dif\n" + ((ret++)) +fi + +grep -oP "(?<=BPF_FUNC_)\w+" src/cc/export/helpers.h | sort -u > /tmp/export.txt +dif=`diff /tmp/compat.txt /tmp/export.txt` +if [ $? -ne 0 ]; then + echo "The lists of helpers in src/cc/compat/linux/bpf.h and src/cc/export/helpers.h differ:" + echo "$dif" + ((ret++)) +fi + +exit $ret