From b0e84174a085db91799855d31800ee09386e333e Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Tue, 30 Mar 2021 16:23:18 +0200 Subject: [PATCH] [tests] add test for JCDB subdir --- tests/jcdb/oracle/subdir.err | 0 tests/jcdb/oracle/subdir.res | 1 + tests/jcdb/subdir.c | 13 +++++++++++++ tests/jcdb/subdir.json | 6 ++++++ tests/jcdb/subdir1/header.h | 1 + tests/jcdb/subdir2/included.h | 3 +++ 6 files changed, 24 insertions(+) create mode 100644 tests/jcdb/oracle/subdir.err create mode 100644 tests/jcdb/oracle/subdir.res create mode 100644 tests/jcdb/subdir.c create mode 100644 tests/jcdb/subdir.json create mode 100644 tests/jcdb/subdir1/header.h create mode 100644 tests/jcdb/subdir2/included.h diff --git a/tests/jcdb/oracle/subdir.err b/tests/jcdb/oracle/subdir.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/jcdb/oracle/subdir.res b/tests/jcdb/oracle/subdir.res new file mode 100644 index 00000000000..db55f314d60 --- /dev/null +++ b/tests/jcdb/oracle/subdir.res @@ -0,0 +1 @@ +[kernel] Parsing PWD/../subdir.c (with preprocessing) diff --git a/tests/jcdb/subdir.c b/tests/jcdb/subdir.c new file mode 100644 index 00000000000..1729358186a --- /dev/null +++ b/tests/jcdb/subdir.c @@ -0,0 +1,13 @@ +/* run.config + NOFRAMAC: + EXECNOW: LOG subdir.res LOG subdir.err (cd @PTEST_DIR@/subdir1 && @frama-c@ -add-symbolic-path $PWD/..:PWD/.. -json-compilation-database ../subdir.json ../subdir.c) > @PTEST_RESULT@/subdir.res 2> @PTEST_RESULT@/subdir.err +*/ + +// this test must be run with PWD in subdir1 +#include "subdir1/header.h" +#include "included.h" // in subdir2, via '-Isubdir2' in subdir.json +#include "__fc_builtin.h" // to check that Frama-C's libc is correctly included + +int main() { + return ONE + TWO; +} diff --git a/tests/jcdb/subdir.json b/tests/jcdb/subdir.json new file mode 100644 index 00000000000..4748ff19e65 --- /dev/null +++ b/tests/jcdb/subdir.json @@ -0,0 +1,6 @@ +[ + { "directory": ".", + "command": "g++ -Isubdir2", + "file": "subdir.c" + } +] diff --git a/tests/jcdb/subdir1/header.h b/tests/jcdb/subdir1/header.h new file mode 100644 index 00000000000..f01809a81bd --- /dev/null +++ b/tests/jcdb/subdir1/header.h @@ -0,0 +1 @@ +#define ONE 1 diff --git a/tests/jcdb/subdir2/included.h b/tests/jcdb/subdir2/included.h new file mode 100644 index 00000000000..80ba189555e --- /dev/null +++ b/tests/jcdb/subdir2/included.h @@ -0,0 +1,3 @@ +// to be included by subdir.c + +#define TWO 2 -- GitLab