[v2,5/5,pre-commit] Use --valid with xmllint

Message ID 20260826212209.925066-6-tdevries@suse.de
State New
Headers
Series xml linting |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom de Vries Aug. 26, 2026, 9:22 p.m. UTC
  Use --valid with xmllint, but only for files that are currently clean.
---
 gdb/contrib/xmllint.sh | 69 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 67 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gdb/contrib/xmllint.sh b/gdb/contrib/xmllint.sh
index 748e096bbef..76e6d3a033e 100755
--- a/gdb/contrib/xmllint.sh
+++ b/gdb/contrib/xmllint.sh
@@ -32,6 +32,7 @@  tmp=$(mktemp)
 
 check_basic=""
 check_includes=""
+check_valid=""
 for f in "$@"; do
     case $f in
         gdb/testsuite/gdb.xml/tdesc-bogus.xml)
@@ -48,9 +49,63 @@  for f in "$@"; do
             # - gdb.xml/loop.xml (XInclude error: loop.xml)
 	    check_basic="$check_basic $f"
 	    ;;
-	*)
+	gdb/features/aarch64-core.xml \
+	    | gdb/features/aarch64-fpmr.xml \
+	    | gdb/features/aarch64-fpu.xml \
+	    | gdb/features/alpha-core.xml \
+	    | gdb/features/alpha.xml \
+	    | gdb/features/arc/v1-aux.xml \
+	    | gdb/features/arc/v1-core.xml \
+	    | gdb/features/arc/v2-aux.xml \
+	    | gdb/features/arc/v2-core.xml \
+	    | gdb/features/cskyv2-linux.xml \
+	    | gdb/features/i386/32bit-linux.xml \
+	    | gdb/features/i386/64bit-avx512.xml \
+	    | gdb/features/or1k-core.xml \
+	    | gdb/features/or1k-linux.xml \
+	    | gdb/features/or1k.xml \
+	    | gdb/features/rs6000/powerpc-403gc.xml \
+	    | gdb/features/rs6000/powerpc-403.xml \
+	    | gdb/features/rs6000/powerpc-405.xml \
+	    | gdb/features/rs6000/powerpc-505.xml \
+	    | gdb/features/rs6000/powerpc-601.xml \
+	    | gdb/features/rs6000/powerpc-602.xml \
+	    | gdb/features/rs6000/powerpc-603.xml \
+	    | gdb/features/rs6000/powerpc-604.xml \
+	    | gdb/features/rs6000/powerpc-750.xml \
+	    | gdb/features/rs6000/powerpc-860.xml \
+	    | gdb/features/rx.xml \
+	    | gdb/features/s390-gs-linux64.xml \
+	    | gdb/features/s390-te-linux64.xml \
+	    | gdb/features/s390-tevx-linux64.xml \
+	    | gdb/features/s390-vx-linux64.xml \
+	    | gdb/features/s390x-gs-linux64.xml \
+	    | gdb/features/s390x-te-linux64.xml \
+	    | gdb/features/s390x-tevx-linux64.xml \
+	    | gdb/features/s390x-vx-linux64.xml \
+	    | gdb/syscalls/freebsd.xml \
+	    | gdb/syscalls/netbsd.xml \
+	    | gdb/testsuite/gdb.xml/inc-2.xml \
+	    | gdb/testsuite/gdb.xml/inc-body.xml \
+	    | gdb/testsuite/gdb.xml/includes.xml \
+	    | gdb/testsuite/gdb.xml/maint_print_struct.xml \
+	    | gdb/testsuite/gdb.xml/maint-xml-dump-02.xml \
+	    | gdb/testsuite/gdb.xml/maint-xml-dump-03.xml \
+	    | gdb/testsuite/gdb.xml/single-reg.xml \
+	    | gdb/testsuite/gdb.xml/tdesc-unknown.xml \
+	    | gdb/testsuite/gdb.xml/trivial.xml \
+	    | gdb/syscalls/apply-defaults.xsl \
+	    | gdb/features/print-osabi.xsl \
+	    | gdb/features/number-regs.xsl \
+	    | gdb/features/gdbserver-regs.xsl \
+	    | gdb/features/sort-regs.xsl \
+	    | gdb/doc/stack_frame.svg)
+	    # Files that are not clean with --valid.
 	    check_includes="$check_includes $f"
 	    ;;
+	*)
+	    check_valid="$check_valid $f"
+	    ;;
     esac
 done
 
@@ -71,7 +126,17 @@  if [ "$check_includes" != "" ]; then
 	    2>&1; st2=$?
 fi
 
-if [ $st1 -eq 0 ] && [ $st2 -eq 0 ]; then
+st3=0
+if [ "$check_valid" != "" ]; then
+    # Provide the --path parts to let xmllint find the .dtd files.
+    xmllint --noout --xinclude --path gdb/syscalls --path gdb/features \
+	    --valid \
+	    $check_valid \
+	    >> "$tmp" \
+	    2>&1; st3=$?
+fi
+
+if [ $st1 -eq 0 ] && [ $st2 -eq 0 ] && [ $st3 -eq 0 ]; then
     st=0
 else
     st=1