File: check_api.sh

package info (click to toggle)
wolfssl 5.8.4-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 117,604 kB
  • sloc: ansic: 1,584,954; asm: 481,206; sh: 11,586; cs: 6,596; xml: 3,878; perl: 3,291; makefile: 2,058; ada: 1,891; javascript: 748; python: 636; cpp: 131; ruby: 118; objc: 80; tcl: 73
file content (43 lines) | stat: -rwxr-xr-x 1,257 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh

ls ./dox_comments/header_files/ |
while read h_file; do
    grep -h --null -o 'WOLFSSL_API(\n|\s|[^;])*;' ./dox_comments/header_files/$h_file |
    tr '\n' ' ' |
    sed 's/\\n//g' |
    sed 's/ \+/ /g' |
    sed 's/\x00/\n/g' > dox_api.txt

    find ../ -not -path '../doc/*' -name $h_file |
    while read -r h_file_path; do
        echo "Checking: $h_file_path"
        grep -h --null -o 'WOLFSSL_API(\n|\s|[^;])*;' "$h_file_path" |
        sed 's/#.*/ /g' |
        tr '\n' ' ' |
        sed 's/\\n//g' |
        sed 's/ \+/ /g' |
        sed 's/\x00/\n/g' > wolf_api.txt

        api_count="$(wc -l < dox_api.txt)"
        match_count="$(grep -Ff dox_api.txt wolf_api.txt | wc -l)"
        if [ "$api_count" != "$match_count" ]; then
            echo "Mismatch"
            echo "Dox_api: $api_count"
            echo "Matched_api: $match_count"
            echo "Header file: $h_file"
            echo "Check API: "
            sort dox_api.txt -o dox_api.txt
            sort wolf_api.txt -o wolf_api.txt
            comm -23 dox_api.txt wolf_api.txt
            exit 1
        else
            echo "$h_file is all good"
            break
        fi
    done || exit 1
    echo 'Next...\n'

done || exit 1

rm dox_api.txt
rm wolf_api.txt