[v5,1/2] devtools: add check on symbol maps format

Message ID 20231115104259.3045847-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v5,1/2] devtools: add check on symbol maps format |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

David Marchand Nov. 15, 2023, 10:42 a.m. UTC
  Add a check on symbol maps format.
This will be required by a next commit.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since v4:
- rebased,
- handled next abi version in the check,

Changes since v3:
- fixed Alpine build (same issue with { in awk expression than commit
  e1ab26df4862 ("buildtools: fix build with busybox")),

Changes since v2:
- fixed FreeBSD build by replacing (|pattern) with (pattern)?,

Changes since v1:
- moved this check in a separate patch,
- fixed ethdev map file,

---
 devtools/check-symbol-maps.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
  

Patch

diff --git a/devtools/check-symbol-maps.sh b/devtools/check-symbol-maps.sh
index 8c116bfa9c..ba2f892f56 100755
--- a/devtools/check-symbol-maps.sh
+++ b/devtools/check-symbol-maps.sh
@@ -74,4 +74,27 @@  if [ -n "$empty_maps" ] ; then
     ret=1
 fi
 
+find_bad_format_maps ()
+{
+    abi_version=$(cut -d'.' -f 1 ABI_VERSION)
+    next_abi_version=$((abi_version + 1))
+    for map in $@ ; do
+        cat $map | awk '
+            /^(DPDK_('$abi_version'|'$next_abi_version')|EXPERIMENTAL|INTERNAL) \{$/ { next; } # start of a section
+            /^}( DPDK_'$abi_version')?;$/ { next; } # end of a section
+            /^$/ { next; } # empty line
+            /^\t(global:|local: \*;)$/ { next; } # qualifiers
+            /^\t[a-zA-Z_0-9]*;( # WINDOWS_NO_EXPORT)?$/ { next; } # symbols
+            /^\t# added in [0-9]*\.[0-9]*$/ { next; } # version comments
+            { print $0; }' || echo $map
+    done
+}
+
+bad_format_maps=$(find_bad_format_maps $@)
+if [ -n "$bad_format_maps" ] ; then
+    echo "Found badly formatted maps:"
+    echo "$bad_format_maps"
+    ret=1
+fi
+
 exit $ret