From f2373ba7ca2221971ca310d7c58a8fd07e5ee1d6 Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Tue, 21 Mar 2023 12:07:43 +0100
Subject: [PATCH] [tests] avoid leaving generated files in CWD

Notably __fc_machdep.h in result dir, that could be picked up by other
tests in the same session...
---
 tests/libc/runtime.c  | 4 ++--
 tests/libc/runtime.sh | 7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100755 tests/libc/runtime.sh

diff --git a/tests/libc/runtime.c b/tests/libc/runtime.c
index 4ddb32fbb5c..25588a82e04 100644
--- a/tests/libc/runtime.c
+++ b/tests/libc/runtime.c
@@ -1,7 +1,7 @@
 /* run.config*
    COMMENT: tests that the runtime can compile without errors (for PathCrawler, E-ACSL, ...)
-   CMD: @frama-c@ -print-machdep-header > __fc_machdep.h && gcc -I. -D__FC_MACHDEP_X86_64 @FRAMAC_SHARE@/libc/__fc_runtime.c -Wno-attributes -std=c99 -Wall -Wwrite-strings -o @DEV_NULL@
-   OPT:
+   CMD: FRAMAC='@frama-c@' %{dep:@PTEST_DIR@/runtime.sh}
+   OPT: %{dep:@FRAMAC_SHARE@/libc/__fc_runtime.c}
  */
 
 int main() {
diff --git a/tests/libc/runtime.sh b/tests/libc/runtime.sh
new file mode 100755
index 00000000000..aee0cf3d823
--- /dev/null
+++ b/tests/libc/runtime.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -e
+if test -z "$FRAMAC"; then echo "variable FRAMAC must be set"; exit 1; fi
+TMPDIR=$(mktemp -d fc_test_libc_XXXXXXXX)
+$FRAMAC -print-machdep-header > $TMPDIR/__fc_machdep.h
+gcc -I$TMPDIR -D__FC_MACHDEP_X86_64 $@ -Wno-attributes -std=c99 -Wall -Wwrite-strings -o /dev/null
+rm -fr $TMPDIR
-- 
GitLab