aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarlon James <marlon.james@gmail.com>2021-03-03 12:06:53 -0800
committertgingold <tgingold@users.noreply.github.com>2021-03-04 07:49:28 +0100
commit062ff5b6a41caf93e03c417e31a8a6471993abf1 (patch)
treefcc773b7c6a153e911120ee611945bb3347e91c2
parent783cbac7ba4c14aa7e27f28755dccd7e4ee4d54e (diff)
downloadghdl-062ff5b6a41caf93e03c417e31a8a6471993abf1.tar.gz
ghdl-062ff5b6a41caf93e03c417e31a8a6471993abf1.tar.bz2
ghdl-062ff5b6a41caf93e03c417e31a8a6471993abf1.zip
VHPI: add tests for loading libraries
-rw-r--r--.github/workflows/Test.yml2
-rwxr-xr-xscripts/ci-run.sh2
-rwxr-xr-xtestsuite/suite_driver.sh2
-rwxr-xr-xtestsuite/testsuite.sh4
-rw-r--r--testsuite/vhpi/001load_lib/mydesign.vhdl9
-rwxr-xr-xtestsuite/vhpi/001load_lib/testsuite.sh32
-rw-r--r--testsuite/vhpi/001load_lib/vhpi_lib.c13
-rw-r--r--testsuite/vhpi/002load_entrypoint/mydesign.vhdl9
-rwxr-xr-xtestsuite/vhpi/002load_entrypoint/testsuite.sh32
-rw-r--r--testsuite/vhpi/002load_entrypoint/vhpi_lib.c7
-rw-r--r--testsuite/vhpi/003load_multi_lib/mydesign.vhdl9
-rwxr-xr-xtestsuite/vhpi/003load_multi_lib/testsuite.sh38
-rw-r--r--testsuite/vhpi/003load_multi_lib/vhpi_lib1.c7
-rw-r--r--testsuite/vhpi/003load_multi_lib/vhpi_lib2.c7
-rwxr-xr-xtestsuite/vhpi/testsuite.sh5
15 files changed, 173 insertions, 5 deletions
diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml
index 2067a620c..ac4103751 100644
--- a/.github/workflows/Test.yml
+++ b/.github/workflows/Test.yml
@@ -273,7 +273,7 @@ jobs:
{icon: '🟪', installs: 'MINGW64', arch: x86_64, pkg: 'llvm' },
]
suite: [
- 'sanity pyunit vpi',
+ 'sanity pyunit vpi vhpi',
'gna',
'vests',
'synth',
diff --git a/scripts/ci-run.sh b/scripts/ci-run.sh
index b0ebfd894..2854ee7f3 100755
--- a/scripts/ci-run.sh
+++ b/scripts/ci-run.sh
@@ -460,7 +460,7 @@ EOF
tests+=" synth"
fi
- tests+=" vpi"
+ tests+=" vpi vhpi"
# Run tests in docker container
$RUN "$GHDL_TEST_IMAGE" bash -c "GHDL=ghdl ./testsuite/testsuite.sh $tests"
diff --git a/testsuite/suite_driver.sh b/testsuite/suite_driver.sh
index 66a584a86..d3d7cf7c1 100755
--- a/testsuite/suite_driver.sh
+++ b/testsuite/suite_driver.sh
@@ -14,7 +14,7 @@ shift
# This is the only place where test dirs are specified.
#Do not duplicate this line
-dirs="*[0-9]"
+dirs="*[0-9]*"
failures=""
full=n
diff --git a/testsuite/testsuite.sh b/testsuite/testsuite.sh
index b52b0ea8d..947cc7d6f 100755
--- a/testsuite/testsuite.sh
+++ b/testsuite/testsuite.sh
@@ -97,7 +97,7 @@ for opt; do
esac
done
-if [ "x$tests" = "x" ]; then tests="sanity pyunit gna vests synth vpi"; fi
+if [ "x$tests" = "x" ]; then tests="sanity pyunit gna vests synth vpi vhpi"; fi
echo "> tests: $tests"
echo "> args: $@"
@@ -105,7 +105,7 @@ echo "> args: $@"
# Run a testsuite
do_test() {
case $1 in
- sanity|gna|synth|vpi)
+ sanity|gna|synth|vpi|vhpi)
gstart "[GHDL - test] $1"
cd "$1"
../suite_driver.sh $@
diff --git a/testsuite/vhpi/001load_lib/mydesign.vhdl b/testsuite/vhpi/001load_lib/mydesign.vhdl
new file mode 100644
index 000000000..38fdfda98
--- /dev/null
+++ b/testsuite/vhpi/001load_lib/mydesign.vhdl
@@ -0,0 +1,9 @@
+library ieee ;
+use ieee.std_logic_1164.all;
+
+entity myentity is
+end myentity;
+
+architecture arch of myentity is
+begin
+end arch;
diff --git a/testsuite/vhpi/001load_lib/testsuite.sh b/testsuite/vhpi/001load_lib/testsuite.sh
new file mode 100755
index 000000000..1a23b1b69
--- /dev/null
+++ b/testsuite/vhpi/001load_lib/testsuite.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze mydesign.vhdl
+elab myentity
+
+if c_compiler_is_available && ghdl_has_feature myentity vhpi; then
+ $GHDL --vpi-compile -v gcc -c vhpi_lib.c
+ $GHDL --vpi-link -v gcc -o vhpi_lib.vhpi vhpi_lib.o
+
+ add_vpi_path
+
+ simulate myentity --vhpi=./vhpi_lib.vhpi | tee myentity.out
+ if grep -q Error myentity.out; then
+ echo "Error in output"
+ exit 1;
+ fi
+ if grep -q error myentity.out; then
+ echo "error in output"
+ exit 1;
+ fi
+ if ! grep -q "VHPI lib" myentity.out; then
+ echo "VHPI Library not loaded"
+ exit 1;
+ fi
+
+ rm -f vhpi_lib.vhpi vhpi_lib.o myentity.out
+fi
+clean
+
+echo "Test successful"
diff --git a/testsuite/vhpi/001load_lib/vhpi_lib.c b/testsuite/vhpi/001load_lib/vhpi_lib.c
new file mode 100644
index 000000000..46b70ede4
--- /dev/null
+++ b/testsuite/vhpi/001load_lib/vhpi_lib.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <vpi_user.h>
+
+void my_startup()
+{
+ printf ("VHPI lib\n");
+}
+
+void (*vhpi_startup_routines[]) () =
+{
+ my_startup,
+ 0
+};
diff --git a/testsuite/vhpi/002load_entrypoint/mydesign.vhdl b/testsuite/vhpi/002load_entrypoint/mydesign.vhdl
new file mode 100644
index 000000000..38fdfda98
--- /dev/null
+++ b/testsuite/vhpi/002load_entrypoint/mydesign.vhdl
@@ -0,0 +1,9 @@
+library ieee ;
+use ieee.std_logic_1164.all;
+
+entity myentity is
+end myentity;
+
+architecture arch of myentity is
+begin
+end arch;
diff --git a/testsuite/vhpi/002load_entrypoint/testsuite.sh b/testsuite/vhpi/002load_entrypoint/testsuite.sh
new file mode 100755
index 000000000..bdc2e8a6a
--- /dev/null
+++ b/testsuite/vhpi/002load_entrypoint/testsuite.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze mydesign.vhdl
+elab myentity
+
+if c_compiler_is_available && ghdl_has_feature myentity vhpi; then
+ $GHDL --vpi-compile -v gcc -c vhpi_lib.c
+ $GHDL --vpi-link -v gcc -o vhpi_lib.vhpi vhpi_lib.o
+
+ add_vpi_path
+
+ simulate myentity --vhpi=./vhpi_lib.vhpi:my_startup | tee myentity.out
+ if grep -q Error myentity.out; then
+ echo "Error in output"
+ exit 1;
+ fi
+ if grep -q error myentity.out; then
+ echo "error in output"
+ exit 1;
+ fi
+ if ! grep -q "VHPI lib" myentity.out; then
+ echo "VHPI Library not loaded"
+ exit 1;
+ fi
+
+ rm -f vhpi_lib.vhpi vhpi_lib.o myentity.out
+fi
+clean
+
+echo "Test successful"
diff --git a/testsuite/vhpi/002load_entrypoint/vhpi_lib.c b/testsuite/vhpi/002load_entrypoint/vhpi_lib.c
new file mode 100644
index 000000000..414eac731
--- /dev/null
+++ b/testsuite/vhpi/002load_entrypoint/vhpi_lib.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include <vpi_user.h>
+
+void my_startup()
+{
+ printf ("VHPI lib\n");
+}
diff --git a/testsuite/vhpi/003load_multi_lib/mydesign.vhdl b/testsuite/vhpi/003load_multi_lib/mydesign.vhdl
new file mode 100644
index 000000000..38fdfda98
--- /dev/null
+++ b/testsuite/vhpi/003load_multi_lib/mydesign.vhdl
@@ -0,0 +1,9 @@
+library ieee ;
+use ieee.std_logic_1164.all;
+
+entity myentity is
+end myentity;
+
+architecture arch of myentity is
+begin
+end arch;
diff --git a/testsuite/vhpi/003load_multi_lib/testsuite.sh b/testsuite/vhpi/003load_multi_lib/testsuite.sh
new file mode 100755
index 000000000..a8c3772b5
--- /dev/null
+++ b/testsuite/vhpi/003load_multi_lib/testsuite.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze mydesign.vhdl
+elab myentity
+
+if c_compiler_is_available && ghdl_has_feature myentity vhpi; then
+ $GHDL --vpi-compile -v gcc -c vhpi_lib1.c
+ $GHDL --vpi-link -v gcc -o vhpi_lib1.vhpi vhpi_lib1.o
+ $GHDL --vpi-compile -v gcc -c vhpi_lib2.c
+ $GHDL --vpi-link -v gcc -o vhpi_lib2.vhpi vhpi_lib2.o
+
+ add_vpi_path
+
+ simulate myentity --vhpi=./vhpi_lib1.vhpi:my_startup --vhpi=./vhpi_lib2.vhpi:my_startup | tee myentity.out
+ if grep -q Error myentity.out; then
+ echo "Error in output"
+ exit 1;
+ fi
+ if grep -q error myentity.out; then
+ echo "error in output"
+ exit 1;
+ fi
+ if ! grep -q "VHPI lib 1" myentity.out; then
+ echo "VHPI Library 1 not loaded"
+ exit 1;
+ fi
+ if ! grep -q "VHPI lib 2" myentity.out; then
+ echo "VHPI Library 2 not loaded"
+ exit 1;
+ fi
+
+ rm -f vhpi_lib1.vhpi vhpi_lib1.o vhpi_lib2.vhpi vhpi_lib2.o myentity.out
+fi
+clean
+
+echo "Test successful"
diff --git a/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c b/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c
new file mode 100644
index 000000000..3a9ceaf2a
--- /dev/null
+++ b/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include <vpi_user.h>
+
+void my_startup()
+{
+ printf ("VHPI lib 1\n");
+}
diff --git a/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c b/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c
new file mode 100644
index 000000000..b1f6c7119
--- /dev/null
+++ b/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include <vpi_user.h>
+
+void my_startup()
+{
+ printf ("VHPI lib 2\n");
+}
diff --git a/testsuite/vhpi/testsuite.sh b/testsuite/vhpi/testsuite.sh
new file mode 100755
index 000000000..e97a19ba0
--- /dev/null
+++ b/testsuite/vhpi/testsuite.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+set -e
+
+$(dirname "$0")/../suite_driver.sh vhpi $@