1*387f9dfdSAndroid Build Coastguard Worker#!/bin/bash 2*387f9dfdSAndroid Build Coastguard Workerret=0 3*387f9dfdSAndroid Build Coastguard Worker 4*387f9dfdSAndroid Build Coastguard Workerlibbpf=$(grep -oP '(?<={")\w+(?=", "\d\.\d+")' src/cc/libbpf.c | sort) 5*387f9dfdSAndroid Build Coastguard Workerdoc=$(grep -oP "(?<=BPF_FUNC_)\w+" docs/kernel-versions.md | sort) 6*387f9dfdSAndroid Build Coastguard Workerdif=$(diff <(echo "$doc") <(echo "$libbpf")) 7*387f9dfdSAndroid Build Coastguard Workerif [ $? -ne 0 ]; then 8*387f9dfdSAndroid Build Coastguard Worker echo "The lists of helpers in src/cc/libbpf.c and docs/kernel-versions.md differ:" 9*387f9dfdSAndroid Build Coastguard Worker echo -e "$dif\n" 10*387f9dfdSAndroid Build Coastguard Worker ((ret++)) 11*387f9dfdSAndroid Build Coastguard Workerfi 12*387f9dfdSAndroid Build Coastguard Worker 13*387f9dfdSAndroid Build Coastguard Workercompat=$(grep -oP "(?<=^\sFN\()\w+" src/cc/compat/linux/bpf.h | tail -n +2 | sort) 14*387f9dfdSAndroid Build Coastguard Workerdif=$(diff <(echo "$doc") <(echo "$compat")) 15*387f9dfdSAndroid Build Coastguard Workerif [ $? -ne 0 ]; then 16*387f9dfdSAndroid Build Coastguard Worker echo "The lists of helpers in docs/kernel-versions.md and src/cc/compat/linux/bpf.h differ:" 17*387f9dfdSAndroid Build Coastguard Worker echo -e "$dif\n" 18*387f9dfdSAndroid Build Coastguard Worker ((ret++)) 19*387f9dfdSAndroid Build Coastguard Workerfi 20*387f9dfdSAndroid Build Coastguard Worker 21*387f9dfdSAndroid Build Coastguard Workervirtual=$(grep -oP "(?<=^\sFN\()\w+" src/cc/compat/linux/virtual_bpf.h | tail -n +2 | sort -u) 22*387f9dfdSAndroid Build Coastguard Workerdif=$(diff <(echo "$compat") <(echo "$virtual")) 23*387f9dfdSAndroid Build Coastguard Workerif [ $? -ne 0 ]; then 24*387f9dfdSAndroid Build Coastguard Worker echo "The lists of helpers in src/cc/compat/linux/bpf.h and src/cc/compat/linux/virtual_bpf.h differ:" 25*387f9dfdSAndroid Build Coastguard Worker echo "$dif" 26*387f9dfdSAndroid Build Coastguard Worker ((ret++)) 27*387f9dfdSAndroid Build Coastguard Workerfi 28*387f9dfdSAndroid Build Coastguard Worker 29*387f9dfdSAndroid Build Coastguard Workerexport=$(grep -oP "(?<=BPF_FUNC_)\w+" src/cc/export/helpers.h | sort -u) 30*387f9dfdSAndroid Build Coastguard Workerdif=$(diff <(echo "$compat") <(echo "$export")) 31*387f9dfdSAndroid Build Coastguard Workerif [ $? -ne 0 ]; then 32*387f9dfdSAndroid Build Coastguard Worker echo "The lists of helpers in src/cc/compat/linux/bpf.h and src/cc/export/helpers.h differ:" 33*387f9dfdSAndroid Build Coastguard Worker echo "$dif" 34*387f9dfdSAndroid Build Coastguard Worker ((ret++)) 35*387f9dfdSAndroid Build Coastguard Workerfi 36*387f9dfdSAndroid Build Coastguard Worker 37*387f9dfdSAndroid Build Coastguard Workerexit $ret 38