summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2020-07-14 19:46:55 +0200
committerDavid Lamparter <equinox@diac24.net>2020-07-17 05:54:54 +0200
commit555cc1001d40113829c016894507a7ded9faba7e (patch)
treea8393152926212ba4ad538a87470cb6cabcefbed
parent05675eb32fdaaefb20a1e66a7517467227506857 (diff)
tools/gcc-frr-format: improve test
Signed-off-by: David Lamparter <equinox@diac24.net>
-rw-r--r--tools/gcc-plugins/format-test.c6
-rw-r--r--tools/gcc-plugins/format-test.py8
2 files changed, 12 insertions, 2 deletions
diff --git a/tools/gcc-plugins/format-test.c b/tools/gcc-plugins/format-test.c
index b031ca5ece..fb7e41c7be 100644
--- a/tools/gcc-plugins/format-test.c
+++ b/tools/gcc-plugins/format-test.c
@@ -82,6 +82,12 @@ int test(unsigned long long ay)
testfn("%Ld", v_pid_t); // WARN
testfn("%Ld", v_uint64_t); // NOWARN
+ /* retain-typeinfo patch */
+ testfn("%zu", (size_t)v_pid_t); // NOWARN (need retain-typeinfo patch)
+ testfn("%lu", (size_t)v_pid_t); // WARN (need retain-typeinfo patch)
+ testfn("%Lu", (uint64_t)v_pid_t); // NOWARN (need retain-typeinfo patch)
+ testfn("%lu", (uint64_t)v_pid_t); // WARN (need retain-typeinfo patch)
+
testfn("%pI4", &v_long); // WARN
in_addr_t v_in_addr_t;
diff --git a/tools/gcc-plugins/format-test.py b/tools/gcc-plugins/format-test.py
index cc6ca6100e..df2437d5bc 100644
--- a/tools/gcc-plugins/format-test.py
+++ b/tools/gcc-plugins/format-test.py
@@ -10,6 +10,10 @@ for k in list(os.environ.keys()):
if k.startswith('LC_'):
os.environ.pop(k)
+if len(sys.argv) < 2:
+ sys.stderr.write('start as format-test.py gcc-123.45 [-options ...]\n')
+ sys.exit(1)
+
c_re = re.compile(r'//\s+(NO)?WARN')
expect = {}
lines = {}
@@ -25,9 +29,9 @@ with open('format-test.c', 'r') as fd:
else:
expect[lno] = 'nowarn'
-cmd = shlex.split('gcc -Wall -Wextra -Wno-unused -fplugin=./frr-format.so -fno-diagnostics-show-caret -c -o format-test.o format-test.c')
+cmd = shlex.split('-Wall -Wextra -Wno-unused -fplugin=./frr-format.so -fno-diagnostics-show-caret -c -o format-test.o format-test.c')
-gcc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+gcc = subprocess.Popen(sys.argv[1:] + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sout, serr = gcc.communicate()
gcc.wait()