]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tools/gcc-frr-format: improve test
authorDavid Lamparter <equinox@diac24.net>
Tue, 14 Jul 2020 17:46:55 +0000 (19:46 +0200)
committerDavid Lamparter <equinox@diac24.net>
Fri, 17 Jul 2020 03:54:54 +0000 (05:54 +0200)
Signed-off-by: David Lamparter <equinox@diac24.net>
tools/gcc-plugins/format-test.c
tools/gcc-plugins/format-test.py

index b031ca5ece11e843782e4d2aa5f7323191f81436..fb7e41c7beaa4bca39b9e1b81237acf12693f524 100644 (file)
@@ -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;
index cc6ca6100e57d36fd82329a34f5566f035721b62..df2437d5bcf661590f727e23b3bdbaae63e99cec 100644 (file)
@@ -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()