From 8a88fdfc881ba6c57759065bd8fe9ebcaf922e9e Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 27 Apr 2019 15:31:02 +0200 Subject: Add testcase for vhpidirect. --- testsuite/gna/bug097/getrand.c | 7 +++++++ testsuite/gna/bug097/tb.vhdl | 14 ++++++++++++++ testsuite/gna/bug097/testsuite.sh | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 testsuite/gna/bug097/getrand.c create mode 100644 testsuite/gna/bug097/tb.vhdl create mode 100755 testsuite/gna/bug097/testsuite.sh diff --git a/testsuite/gna/bug097/getrand.c b/testsuite/gna/bug097/getrand.c new file mode 100644 index 000000000..f0d7cd885 --- /dev/null +++ b/testsuite/gna/bug097/getrand.c @@ -0,0 +1,7 @@ +#include + +int +get_rand (void) +{ + return rand(); +} diff --git a/testsuite/gna/bug097/tb.vhdl b/testsuite/gna/bug097/tb.vhdl new file mode 100644 index 000000000..d58580da8 --- /dev/null +++ b/testsuite/gna/bug097/tb.vhdl @@ -0,0 +1,14 @@ +entity tb is +end tb; + +architecture behav of tb is + function get_rand return integer; + attribute foreign of get_rand: function is "VHPIDIRECT ./getrand.so get_rand"; + + function get_rand return integer is + begin + assert false severity failure; + end get_rand; +begin + assert get_rand >= 0 severity note; +end behav; diff --git a/testsuite/gna/bug097/testsuite.sh b/testsuite/gna/bug097/testsuite.sh new file mode 100755 index 000000000..126e39c03 --- /dev/null +++ b/testsuite/gna/bug097/testsuite.sh @@ -0,0 +1,14 @@ +#! /bin/sh + +. ../../testenv.sh + +gcc -c -fPIC getrand.c +gcc -o getrand.so --shared getrand.o + +analyze tb.vhdl +elab_simulate tb + +clean +rm -f getrand.o getrand.so + +echo "Test successful" -- cgit v1.2.3