From 78fd892240d8c9ec47513c7e932298614491693b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bobot?= <francois.bobot@cea.fr> Date: Tue, 29 Sep 2020 14:20:28 +0200 Subject: [PATCH] [Ptests] Add filters for stdout --- ptests/ptests.ml | 10 +++++- tests/syntax/char_is_unsigned.i | 2 +- tests/syntax/cpp-command.c | 2 +- tests/syntax/oracle/anon_enum_libc.res.oracle | 32 ++++++++++++++++--- tests/syntax/oracle/cpp-command.0.res.oracle | 2 +- tests/syntax/oracle/cpp-command.1.res.oracle | 2 +- .../multiple_decls_contracts.0.res.oracle | 2 +- .../multiple_decls_contracts.1.res.oracle | 2 +- .../multiple_decls_contracts.2.res.oracle | 2 +- 9 files changed, 43 insertions(+), 13 deletions(-) diff --git a/ptests/ptests.ml b/ptests/ptests.ml index d7df845274c..9b953021d99 100644 --- a/ptests/ptests.ml +++ b/ptests/ptests.ml @@ -1081,6 +1081,12 @@ let command_string ~result_fmt ~oracle_fmt command = * in * Some (exec_name ^ params) * in *) + let filter_stdout_begin,filter_stdout_end = match command.filter with + | None -> "","" + | Some filter -> + "(pipe-stdout ", + Format.sprintf "(system %S))" filter + in let command_string = basic_command_string command in (* let command_string = match filter with * | None -> command_string @@ -1114,7 +1120,7 @@ let command_string ~result_fmt ~oracle_fmt command = "(rule\n \ (targets %S %S %a)\n \ (deps %a %S (package frama-c)%a (universe))\n \ - (action (with-stderr-to %S (with-stdout-to %S (with-accepted-exit-codes (or 0 1 125) (system %S)))))\n\ + (action (with-stderr-to %S (with-stdout-to %S %s(with-accepted-exit-codes (or 0 1 125) (system %S))%s)))\n\ )@." errlog res @@ -1124,7 +1130,9 @@ let command_string ~result_fmt ~oracle_fmt command = Fmt.(list (package_as_deps (quote plugin_as_package))) command.plugins errlog res + filter_stdout_begin command_string + filter_stdout_end ; Format.fprintf result_fmt "(rule\n \ diff --git a/tests/syntax/char_is_unsigned.i b/tests/syntax/char_is_unsigned.i index ac18c46cdf4..0eb4739fe41 100644 --- a/tests/syntax/char_is_unsigned.i +++ b/tests/syntax/char_is_unsigned.i @@ -1,6 +1,6 @@ /* run.config CMXS: machdep_char_unsigned - OPT:-print -load-module machdep_char_unsigned -machdep unsigned_char -then -constfold -rte + OPT:-print -load-module %{dep:machdep_char_unsigned.cmxs} -machdep unsigned_char -then -constfold -rte */ char t[10]; diff --git a/tests/syntax/cpp-command.c b/tests/syntax/cpp-command.c index e3f75a6e3fc..a5302bd1287 100644 --- a/tests/syntax/cpp-command.c +++ b/tests/syntax/cpp-command.c @@ -1,5 +1,5 @@ /* run.config* - FILTER: sed 's:/\(tmp\|var\|build\)/[^ ]*\.i:/tmp/FILE.i:g' + FILTER: sed -e 's:/\(tmp\|var\|build\)/[^ ]*\.i:/tmp/FILE.i:g' -e 's:-I.*share/frama-c/share/libc:-I LIBC:g' OPT: -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "echo [\$(basename '%1') \$(basename '%1') \$(basename '%i') \$(basename '%input')] ['%2' '%2' '%o' '%output'] ['%args']" OPT: -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "echo %%1 = \$(basename '%1') %%2 = '%2' %%args = '%args'" OPT: -no-autoload-plugins -cpp-frama-c-compliant -cpp-command "printf \"%s\" \"using \\% has no effect : \$(basename \"\%input\")\"" diff --git a/tests/syntax/oracle/anon_enum_libc.res.oracle b/tests/syntax/oracle/anon_enum_libc.res.oracle index 08fb3a9bdcb..32aba9aeb34 100644 --- a/tests/syntax/oracle/anon_enum_libc.res.oracle +++ b/tests/syntax/oracle/anon_enum_libc.res.oracle @@ -1,6 +1,28 @@ [kernel] Parsing anon_enum_libc.c (with preprocessing) -[kernel] User Error: failed to run: gcc -E -C -I. -I/home/bobot/Sources/frama-c/_build/install/default/share/frama-c/share/libc -D__FRAMAC__ -D__FC_MACHDEP_X86_32 -I tests/syntax -dD -nostdinc -m32 -o '/tmp/anon_enum_libc.c98bd8a.i' '/home/bobot/Sources/frama-c/_build/default/tests/syntax/result/anon_enum_libc.c' - See chapter "Preparing the Sources" in the Frama-C user manual for more details. -[kernel] User Error: stopping on file "anon_enum_libc.c" that has errors. Add '-kernel-msg-key pp' - for preprocessing command. -[kernel] Frama-C aborted: invalid user input. +[kernel] Parsing anon_enum_libc.tmp.c (with preprocessing) +/* Generated by Frama-C */ +#include "PTESTS_DIR/anon_enum_libc.h" +struct __anonstruct_s1_1 { + int x ; + float y ; +}; +enum __anonenum_2 { + BLA = 4, + BLI = 12 +}; +struct __anonstruct_s1_1 s1; +int f(void) +{ + int __retres; + __retres = BLA + s1.x; + return __retres; +} + +int g(void) +{ + int __retres; + __retres = (int)((unsigned long)FOO + s2.t); + return __retres; +} + + diff --git a/tests/syntax/oracle/cpp-command.0.res.oracle b/tests/syntax/oracle/cpp-command.0.res.oracle index 55dc2642deb..f9d70e8e442 100644 --- a/tests/syntax/oracle/cpp-command.0.res.oracle +++ b/tests/syntax/oracle/cpp-command.0.res.oracle @@ -1,2 +1,2 @@ [kernel] Parsing cpp-command.c (with preprocessing) -[cpp-command.c cpp-command.c cpp-command.c cpp-command.c] [/tmp/cpp-command.cd485c4.i /tmp/cpp-command.cd485c4.i /tmp/cpp-command.cd485c4.i /tmp/cpp-command.cd485c4.i] [ -I/home/bobot/Sources/frama-c/_build/install/default/share/frama-c/share/libc -D__FRAMAC__ -D__FC_MACHDEP_X86_32 -dD -nostdinc -m32] +[cpp-command.c cpp-command.c cpp-command.c cpp-command.c] [/tmp/FILE.i /tmp/FILE.i /tmp/FILE.i /tmp/FILE.i] [ -I LIBC -D__FRAMAC__ -D__FC_MACHDEP_X86_32 -dD -nostdinc -m32] diff --git a/tests/syntax/oracle/cpp-command.1.res.oracle b/tests/syntax/oracle/cpp-command.1.res.oracle index afdf8e4c586..924d0947253 100644 --- a/tests/syntax/oracle/cpp-command.1.res.oracle +++ b/tests/syntax/oracle/cpp-command.1.res.oracle @@ -1,2 +1,2 @@ [kernel] Parsing cpp-command.c (with preprocessing) -%1 = cpp-command.c %2 = /tmp/cpp-command.c125b21.i %args = -I/home/bobot/Sources/frama-c/_build/install/default/share/frama-c/share/libc -D__FRAMAC__ -D__FC_MACHDEP_X86_32 -dD -nostdinc -m32 +%1 = cpp-command.c %2 = /tmp/FILE.i %args = -I LIBC -D__FRAMAC__ -D__FC_MACHDEP_X86_32 -dD -nostdinc -m32 diff --git a/tests/syntax/oracle/multiple_decls_contracts.0.res.oracle b/tests/syntax/oracle/multiple_decls_contracts.0.res.oracle index 1f940c2ffdf..b92cc616a72 100644 --- a/tests/syntax/oracle/multiple_decls_contracts.0.res.oracle +++ b/tests/syntax/oracle/multiple_decls_contracts.0.res.oracle @@ -1,4 +1,4 @@ -[kernel] Parsing /home/bobot/Sources/frama-c/_build/default/share/libc/string.h (with preprocessing) +[kernel] Parsing SHARE/libc/string.h (with preprocessing) [kernel] Parsing multiple_decls_contracts.c (with preprocessing) [kernel] Parsing multiple_decls_contracts.c (with preprocessing) [kernel] multiple_decls_contracts.c:11: Warning: diff --git a/tests/syntax/oracle/multiple_decls_contracts.1.res.oracle b/tests/syntax/oracle/multiple_decls_contracts.1.res.oracle index 5be71f76406..a42ae24841e 100644 --- a/tests/syntax/oracle/multiple_decls_contracts.1.res.oracle +++ b/tests/syntax/oracle/multiple_decls_contracts.1.res.oracle @@ -1,5 +1,5 @@ [kernel] Parsing multiple_decls_contracts.c (with preprocessing) -[kernel] Parsing /home/bobot/Sources/frama-c/_build/default/share/libc/string.h (with preprocessing) +[kernel] Parsing SHARE/libc/string.h (with preprocessing) [kernel] Parsing multiple_decls_contracts.c (with preprocessing) [kernel] multiple_decls_contracts.c:11: Warning: dropping duplicate def'n of func strdup at multiple_decls_contracts.c:11 in favor of that at multiple_decls_contracts.c:11 diff --git a/tests/syntax/oracle/multiple_decls_contracts.2.res.oracle b/tests/syntax/oracle/multiple_decls_contracts.2.res.oracle index 0eb3fb7b6a3..eba6fd7fe81 100644 --- a/tests/syntax/oracle/multiple_decls_contracts.2.res.oracle +++ b/tests/syntax/oracle/multiple_decls_contracts.2.res.oracle @@ -1,6 +1,6 @@ [kernel] Parsing multiple_decls_contracts.c (with preprocessing) [kernel] Parsing multiple_decls_contracts.c (with preprocessing) -[kernel] Parsing /home/bobot/Sources/frama-c/_build/default/share/libc/string.h (with preprocessing) +[kernel] Parsing SHARE/libc/string.h (with preprocessing) [kernel] multiple_decls_contracts.c:11: Warning: dropping duplicate def'n of func strdup at multiple_decls_contracts.c:11 in favor of that at multiple_decls_contracts.c:11 /* Generated by Frama-C */ -- GitLab