From 385da6ac2b60e2c8ee24183e0010fb030cfb4bcb Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Fri, 5 Apr 2024 17:27:59 +0200
Subject: [PATCH] [tests] add test case for builtin macro censorship

---
 tests/misc/custom_machdep.c                   |  6 ++++-
 ...res.oracle => custom_machdep.0.res.oracle} |  0
 tests/misc/oracle/custom_machdep.1.res.oracle | 25 +++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 rename tests/misc/oracle/{custom_machdep.res.oracle => custom_machdep.0.res.oracle} (100%)
 create mode 100644 tests/misc/oracle/custom_machdep.1.res.oracle

diff --git a/tests/misc/custom_machdep.c b/tests/misc/custom_machdep.c
index 1152d590191..632c92e190e 100644
--- a/tests/misc/custom_machdep.c
+++ b/tests/misc/custom_machdep.c
@@ -1,5 +1,9 @@
 /* run.config*
- OPT: -machdep %{dep:@PTEST_DIR@/@PTEST_NAME@.yaml} -print
+ MACRO: machdep %{dep:@PTEST_DIR@/@PTEST_NAME@.yaml}
+ OPT: -machdep @machdep@ -print
+ COMMENT: we can't only use -D, as the __fc_machdep.h define takes precedence
+ COMMENT: with -U, our cmdline definition is used in the code
+ OPT: -machdep @machdep@ -cpp-extra-args="-UCUSTOM_MACHDEP -DCUSTOM_MACHDEP=42" -print
 */
 // most of the following includes are not directly used, but they test if
 // the custom machdep has defined the necessary constants
diff --git a/tests/misc/oracle/custom_machdep.res.oracle b/tests/misc/oracle/custom_machdep.0.res.oracle
similarity index 100%
rename from tests/misc/oracle/custom_machdep.res.oracle
rename to tests/misc/oracle/custom_machdep.0.res.oracle
diff --git a/tests/misc/oracle/custom_machdep.1.res.oracle b/tests/misc/oracle/custom_machdep.1.res.oracle
new file mode 100644
index 00000000000..ed9c8ba5180
--- /dev/null
+++ b/tests/misc/oracle/custom_machdep.1.res.oracle
@@ -0,0 +1,25 @@
+[kernel] Parsing custom_machdep.c (with preprocessing)
+/* Generated by Frama-C */
+#include "ctype.h"
+#include "errno.h"
+#include "inttypes.h"
+#include "locale.h"
+#include "math.h"
+#include "signal.h"
+#include "stdarg.h"
+#include "stddef.h"
+#include "stdint.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+#include "strings.h"
+#include "time.h"
+#include "wchar.h"
+int main(void)
+{
+  int __retres;
+  __retres = 8388607 - 42;
+  return __retres;
+}
+
+
-- 
GitLab