Add test for extract_type_header.py script
This commit is contained in:
parent
67b81c440b
commit
004cd60d51
|
@ -0,0 +1,35 @@
|
|||
default: tests.log
|
||||
|
||||
include ../../src/config.inc
|
||||
include ../../src/common
|
||||
|
||||
ifeq ($(BUILD_ENV_),MSVC)
|
||||
exe=../../../src/goto-cc/goto-cl
|
||||
is_windows=true
|
||||
else
|
||||
exe=../../../src/goto-cc/goto-cc
|
||||
is_windows=false
|
||||
endif
|
||||
|
||||
test:
|
||||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument ../../../src/cbmc/cbmc ./../../../scripts/extract_type_header.py $(is_windows)'
|
||||
|
||||
tests.log:
|
||||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument ../../../src/cbmc/cbmc ./../../../scripts/extract_type_header.py $(is_windows)'
|
||||
|
||||
show:
|
||||
@for dir in *; do \
|
||||
if [ -d "$$dir" ]; then \
|
||||
vim -o "$$dir/*.c" "$$dir/*.out"; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for dir in *; do \
|
||||
$(RM) tests.log; \
|
||||
if [ -d "$$dir" ]; then \
|
||||
cd "$$dir"; \
|
||||
$(RM) *.out *.gb; \
|
||||
cd ..; \
|
||||
fi \
|
||||
done
|
|
@ -0,0 +1,42 @@
|
|||
struct A
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
typedef struct A myStruct;
|
||||
|
||||
#define address a
|
||||
|
||||
#define bucket(X, Y, Z) \
|
||||
if(X) \
|
||||
{ \
|
||||
Z = get_b(X) == Y; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Z = get_default() == Y; \
|
||||
}
|
||||
|
||||
#ifndef address
|
||||
# define address 1
|
||||
#endif
|
||||
|
||||
int get_b(myStruct *s)
|
||||
{
|
||||
return s->b;
|
||||
}
|
||||
|
||||
int get_default()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
myStruct aStruct = {123, 456};
|
||||
__CPROVER_assert(aStruct.address == 123, "address");
|
||||
int z;
|
||||
bucket(&aStruct, 456, z);
|
||||
__CPROVER_assert(z, "bucket");
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
CORE
|
||||
main.c
|
||||
|
||||
^EXIT=0$
|
||||
^SIGNAL=0$
|
||||
#define address a
|
||||
#define bucket\(X, Y, Z\)
|
||||
if\(X\)
|
||||
Z = get_b\(X\) == Y;
|
||||
else
|
||||
Z = get_default\(\) == Y;
|
||||
#ifndef address
|
||||
# define address 1
|
||||
#endif
|
||||
--
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
goto_cc=$1
|
||||
goto_instrument=$2
|
||||
cbmc=$3
|
||||
python_script=$4
|
||||
is_windows=$5
|
||||
|
||||
name=${*:$#}
|
||||
name=${name%.c}
|
||||
|
||||
args=${*:6:$#-6}
|
||||
|
||||
if [[ "${is_windows}" == "true" ]]; then
|
||||
$goto_cc "${name}.c"
|
||||
mv "${name}.exe" "${name}.gb"
|
||||
else
|
||||
$goto_cc -o "${name}.gb" "${name}.c"
|
||||
fi
|
||||
|
||||
export PATH=$PATH:"$(pwd)../../../src/goto-instrument/"
|
||||
$python_script "${name}.gb" "${name}.c" "header.h"
|
||||
cat "header.h"
|
||||
rm -f "header.h"
|
|
@ -15,5 +15,5 @@ Trying the macro: SUCCESS
|
|||
#include "data_structure.h"
|
||||
--
|
||||
^warning: ignoring
|
||||
struct A default_config = {5, 6};
|
||||
struct A my_config={ .a=7, .b=8 };
|
||||
struct A default_config = \{5, 6\};
|
||||
struct A my_config=\{ .a=7, .b=8 \};
|
||||
|
|
|
@ -96,7 +96,7 @@ def make_header_file(goto_binary, c_file, header_out=None):
|
|||
subprocess.run(drop_header_cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
check=True,
|
||||
check=False,
|
||||
universal_newlines=True,
|
||||
cwd=tmpdir,
|
||||
shell=False)
|
||||
|
|
Loading…
Reference in New Issue