Skip to content

Commit

Permalink
scripts: avoid check-helpers.sh's writes to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
pchaigno committed Feb 17, 2018
1 parent 6c81f9d commit c5f48e0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/check-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/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`
libbpf=$(grep -oP '(?<={")\w+(?=", "\d\.\d+")' src/cc/libbpf.c | sort)
doc=$(grep -oP "(?<=BPF_FUNC_)\w+" docs/kernel-versions.md | sort)
dif=$(diff <(echo "$doc") <(echo "$libbpf"))
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`
compat=$(grep -oP "(?<=^\sFN\()\w+" src/cc/compat/linux/bpf.h | tail -n +2 | sort)
dif=$(diff <(echo "$doc") <(echo "$compat"))
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`
export=$(grep -oP "(?<=BPF_FUNC_)\w+" src/cc/export/helpers.h | sort -u)
dif=$(diff <(echo "$compat") <(echo "$export"))
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"
Expand Down

0 comments on commit c5f48e0

Please sign in to comment.