check_api.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. ls ./dox_comments/header_files/ |
  3. while read h_file; do
  4. grep -h --null -o 'WOLFSSL_API(\n|\s|[^;])*;' ./dox_comments/header_files/$h_file |
  5. tr '\n' ' ' |
  6. sed 's/\\n//g' |
  7. sed 's/ \+/ /g' |
  8. sed 's/\x00/\n/g' > dox_api.txt
  9. find ../ -not -path '../doc/*' -name $h_file |
  10. while read -r h_file_path; do
  11. echo "Checking: $h_file_path"
  12. grep -h --null -o 'WOLFSSL_API(\n|\s|[^;])*;' "$h_file_path" |
  13. sed 's/#.*/ /g' |
  14. tr '\n' ' ' |
  15. sed 's/\\n//g' |
  16. sed 's/ \+/ /g' |
  17. sed 's/\x00/\n/g' > wolf_api.txt
  18. api_count="$(wc -l < dox_api.txt)"
  19. match_count="$(grep -Ff dox_api.txt wolf_api.txt | wc -l)"
  20. if [ "$api_count" != "$match_count" ]; then
  21. echo "Mistmatch"
  22. echo "Dox_api: $api_count"
  23. echo "Matched_api: $match_count"
  24. echo "Header file: $h_file"
  25. echo "Check API: "
  26. sort dox_api.txt -o dox_api.txt
  27. sort wolf_api.txt -o wolf_api.txt
  28. comm -23 dox_api.txt wolf_api.txt
  29. exit 1
  30. else
  31. echo "$h_file is all good"
  32. break
  33. fi
  34. done || exit 1
  35. echo 'Next...\n'
  36. done || exit 1
  37. rm dox_api.txt
  38. rm wolf_api.txt