From 9170a7655d7baf2ac37811082618955f02b66729 Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Mon, 1 Feb 2021 14:46:03 +0100
Subject: [PATCH] [tests] add non-regression test for macro with % in cpp extra
 args

also avoid accidental `*/` in FILTER command
---
 tests/syntax/cpp-command.c                   | 12 ++++++++++-
 tests/syntax/oracle/cpp-command.5.res.oracle | 21 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 tests/syntax/oracle/cpp-command.5.res.oracle

diff --git a/tests/syntax/cpp-command.c b/tests/syntax/cpp-command.c
index b508b543b6b..4a533887e76 100644
--- a/tests/syntax/cpp-command.c
+++ b/tests/syntax/cpp-command.c
@@ -1,8 +1,18 @@
 /* run.config*
-   FILTER: sed "s:/[^ ]*/cpp-command\.[^ ]*\.i:TMPDIR/FILE.i:g; s:$PWD/::; s: -m32::"
+   FILTER: sed "s:/[^ ]*[/]cpp-command\.[^ ]*\.i:TMPDIR/FILE.i:g; s:$PWD/::; s: -m32::"
    OPT: -machdep x86_32 -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "echo [\$(basename '%1') \$(basename '%1') \$(basename '%i') \$(basename '%input')] ['%2' '%2' '%o' '%output'] ['%args']"
    OPT: -machdep x86_32 -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "echo %%1 = \$(basename '%1') %%2 = '%2' %%args = '%args'"
    OPT: -machdep x86_32 -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "printf \"%s\n\" \"using \\% has no effect : \$(basename \"\%input\")\""
    OPT: -machdep x86_32 -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "echo %var is not an interpreted placeholder"
    OPT: -machdep x86_32 -no-autoload-plugins -print-cpp-commands
+   OPT: -cpp-extra-args-per-file=@PTEST_FILE@:"-DPF=\\\"cp%02d_3f\\\"" -no-autoload-plugins @PTEST_FILE@ -print
    */
+
+#include <stdio.h>
+void printer(int i, float f) {
+  printf(PF, i, f);
+}
+
+int main() {
+  printer(1, 1.0);
+}
diff --git a/tests/syntax/oracle/cpp-command.5.res.oracle b/tests/syntax/oracle/cpp-command.5.res.oracle
new file mode 100644
index 00000000000..72e8b677b25
--- /dev/null
+++ b/tests/syntax/oracle/cpp-command.5.res.oracle
@@ -0,0 +1,21 @@
+[kernel] Parsing tests/syntax/cpp-command.c (with preprocessing)
+/* Generated by Frama-C */
+#include "errno.h"
+#include "stdarg.h"
+#include "stddef.h"
+#include "stdio.h"
+void printer(int i, float f)
+{
+  printf("cp%02d_3f",i,(double)f);
+  return;
+}
+
+int main(void)
+{
+  int __retres;
+  printer(1,(float)1.0);
+  __retres = 0;
+  return __retres;
+}
+
+
-- 
GitLab