[PATCH] libosmocore[master]: NOT FOR MERGE: check whether new jenkins value_string check ...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Mar 1 14:09:58 UTC 2017


Review at  https://gerrit.osmocom.org/1943

NOT FOR MERGE: check whether new jenkins value_string check works

Change-Id: I3c84c17b9e4dc89f8ee0837c93dbb66a85e89f58
---
M contrib/jenkins.sh
A contrib/verify_value_string_arrays_are_terminated.py
2 files changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/1943/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 108a73a..656f02f 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -2,6 +2,8 @@
 
 set -ex
 
+./contrib/verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
+
 autoreconf --install --force
 ./configure --enable-static --enable-sanitize
 $MAKE $PARALLEL_MAKE check \
diff --git a/contrib/verify_value_string_arrays_are_terminated.py b/contrib/verify_value_string_arrays_are_terminated.py
new file mode 100755
index 0000000..51c0bd4
--- /dev/null
+++ b/contrib/verify_value_string_arrays_are_terminated.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# vim: expandtab tabstop=2 shiftwidth=2 nocin
+
+'''
+Usage:
+  verify_value_string_arrays_are_terminated.py PATH [PATH [...]]
+
+e.g.
+libosmocore/contrib/verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
+'''
+
+import re
+import sys
+
+ws = r'\s*' + '\n' + r'*\s*'
+
+value_string_array_re = re.compile(
+  r'((\bstruct\s+value_string\b[^{;]*?)' + ws + '=[^{;]*{[^;]*}\s*;)',
+  re.MULTILINE | re.DOTALL)
+
+members = r'(\.(value|str)' + ws + '=' + ws + ')?'
+terminator_re = re.compile('{' + ws + members + '(0|NULL)' + ws + ','
+                               + ws + members + '(0|NULL)' + ws + '}')
+errors_found = 0
+
+for f in sys.argv[1:]:
+  arrays = value_string_array_re.findall(open(f).read())
+  for array_def, name in arrays:
+    if not terminator_re.search(array_def):
+      print('ERROR: file contains unterminated value_string %r: %r'
+            % (name, f))
+      errors_found += 1
+
+sys.exit(errors_found)

-- 
To view, visit https://gerrit.osmocom.org/1943
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c84c17b9e4dc89f8ee0837c93dbb66a85e89f58
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list