| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright (C) 2016-2026 Red Hat, Inc. All rights reserved. |
| 4 |
# |
| 5 |
# Author: Fabio M. Di Nitto <[email protected]> |
| 6 |
# |
| 7 |
# This software licensed under GPL-2.0+ |
| 8 |
# |
| 9 |
|
| 10 |
srcdir="$1"/libnozzle/tests |
| 11 |
builddir="$2"/libnozzle/tests |
| 12 |
|
| 13 |
headerapicalls="$(grep nozzle_ "$srcdir"/../libnozzle.h | grep -v "^ \*" | grep -v ^struct | grep -v "^[[:space:]]" | grep -v typedef | sed -e 's/(.*//g' -e 's/^const //g' -e 's/\*//g' | awk '{print $2}')" |
| 14 |
|
| 15 |
# The PowerPC64 ELFv1 ABI defines the address of a function as that of a |
| 16 |
# function descriptor defined in .opd, a data (D) section. Other ABIs |
| 17 |
# use the entry address of the function itself in the text (T) section. |
| 18 |
# Filter additional symbols exported by ln(1) on Solaris. |
| 19 |
exportedapicalls="$(nm -B -D "$builddir"/../.libs/libnozzle.so | grep ' [DT] ' | awk '{if ($3 != "_edata" && $3 != "_GLOBAL_OFFSET_TABLE_" && $3 != "_PROCEDURE_LINKAGE_TABLE_") {print $3}}' | sed -e 's#@@LIBNOZZLE##g')" |
| 20 |
#exportedapicalls="$(nm -B -D "$builddir"/../.libs/libnozzle.so | grep ' [DT] ' | awk '{print $3}' | sed -e 's#@@LIBNOZZLE##g')" |
| 21 |
|
| 22 |
echo "Checking for exported symbols NOT available in header file" |
| 23 |
|
| 24 |
for i in $exportedapicalls; do |
| 25 |
found=0 |
| 26 |
for x in $headerapicalls; do |
| 27 |
if [ "$x" = "$i" ]; then |
| 28 |
found=1 |
| 29 |
break; |
| 30 |
fi |
| 31 |
done |
| 32 |
if [ "$found" = 0 ]; then |
| 33 |
echo "Symbol $i not found in header file" |
| 34 |
exit 1 |
| 35 |
fi |
| 36 |
done |
| 37 |
|
| 38 |
echo "Checking for symbols in header file NOT exported by binary lib" |
| 39 |
|
| 40 |
for i in $headerapicalls; do |
| 41 |
found=0 |
| 42 |
for x in $exportedapicalls; do |
| 43 |
if [ "$x" = "$i" ]; then |
| 44 |
found=1 |
| 45 |
break; |
| 46 |
fi |
| 47 |
done |
| 48 |
if [ "$found" = 0 ]; then |
| 49 |
echo "Symbol $i not found in binary lib" |
| 50 |
exit 1 |
| 51 |
fi |
| 52 |
done |
| 53 |
|
| 54 |
echo "Checking for tests with memcheck exceptions" |
| 55 |
|
| 56 |
for i in $(grep -l is_memcheck "$srcdir"/*.c | grep -v test-common); do |
| 57 |
echo "WARNING: $(basename $i) - has memcheck exception enabled" |
| 58 |
done |
| 59 |
|
| 60 |
echo "Checking for tests with helgrind exceptions" |
| 61 |
|
| 62 |
for i in $(grep -l is_helgrind "$srcdir"/*.c | grep -v test-common); do |
| 63 |
echo "WARNING: $(basename $i) has helgrind exception enabled" |
| 64 |
done |
| 65 |
|
| 66 |
echo "Checking for api test coverage" |
| 67 |
|
| 68 |
numapicalls=0 |
| 69 |
found=0 |
| 70 |
missing=0 |
| 71 |
|
| 72 |
for i in $headerapicalls; do |
| 73 |
[ "$i" = nozzle_reset_mtu ] && i=nozzle_set_mtu # tested together |
| 74 |
[ "$i" = nozzle_reset_mac ] && i=nozzle_set_mac # tested together |
| 75 |
numapicalls=$((numapicalls + 1)) |
| 76 |
if [ -f $srcdir/api_${i}.c ]; then |
| 77 |
found=$((found + 1)) |
| 78 |
else |
| 79 |
missing=$((missing + 1)) |
| 80 |
echo "MISSING: $i" |
| 81 |
fi |
| 82 |
done |
| 83 |
|
| 84 |
echo "Summary" |
| 85 |
echo "-------" |
| 86 |
echo "Found : $found" |
| 87 |
echo "Missing : $missing" |
| 88 |
echo "Total : $numapicalls" |
| 89 |
which bc > /dev/null 2>&1 && { |
| 90 |
coverage=$(echo "scale=3; $found / $numapicalls * 100" | bc -l) |
| 91 |
echo "Coverage: $coverage%" |
| 92 |
} |
| 93 |
exit 0 |
| 94 |
|
| 95 |
exit 0 |