aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue803
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-01-26 07:50:21 +0100
committerTristan Gingold <tgingold@free.fr>2021-01-26 07:50:21 +0100
commit7135caeea2880d7d1ee96a66bd7941bcc56a4ddb (patch)
treea544198df50588d8d4d917b76d9b9ef11928fe18 /testsuite/gna/issue803
parent0978b48007afe920d8f7000c2c8722327c901259 (diff)
downloadghdl-7135caeea2880d7d1ee96a66bd7941bcc56a4ddb.tar.gz
ghdl-7135caeea2880d7d1ee96a66bd7941bcc56a4ddb.tar.bz2
ghdl-7135caeea2880d7d1ee96a66bd7941bcc56a4ddb.zip
testsuite/gna: add a test for #803
Diffstat (limited to 'testsuite/gna/issue803')
-rw-r--r--testsuite/gna/issue803/main-mac.c27
-rw-r--r--testsuite/gna/issue803/main-win.c27
-rw-r--r--testsuite/gna/issue803/main.c33
-rw-r--r--testsuite/gna/issue803/tb.vhdl10
-rwxr-xr-xtestsuite/gna/issue803/testsuite.sh34
5 files changed, 131 insertions, 0 deletions
diff --git a/testsuite/gna/issue803/main-mac.c b/testsuite/gna/issue803/main-mac.c
new file mode 100644
index 000000000..665c347e0
--- /dev/null
+++ b/testsuite/gna/issue803/main-mac.c
@@ -0,0 +1,27 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+
+ void* h = dlopen("./tb.dylib", RTLD_LAZY);
+ if (!h){
+ fprintf(stderr, "%s\n", dlerror());
+ exit(1);
+ }
+
+ typedef int main_t(int, char**);
+
+ main_t* ghdl_main = (main_t*)dlsym(h, "ghdl_main");
+ if (!ghdl_main){
+ fprintf(stderr, "%s\n", dlerror());
+ exit(2);
+ }
+
+ printf("ghdl_main return: %d\n", ghdl_main(argc, argv));
+
+ dlclose(h);
+
+ return 0;
+
+}
diff --git a/testsuite/gna/issue803/main-win.c b/testsuite/gna/issue803/main-win.c
new file mode 100644
index 000000000..0cb560b3d
--- /dev/null
+++ b/testsuite/gna/issue803/main-win.c
@@ -0,0 +1,27 @@
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+
+ void* h = LoadLibraryA(".\\tb.dll");
+ if (!h){
+ fprintf(stderr, "error: cannot load library\n");
+ exit(1);
+ }
+
+ typedef int main_t(int, char**);
+
+ main_t* ghdl_main = (main_t*)GetProcAddress(h, "_ghdl_main");
+ if (!ghdl_main){
+ fprintf(stderr, "error: cannot find symbol\n");
+ exit(2);
+ }
+
+ printf("ghdl_main return: %d\n", ghdl_main(argc, argv));
+
+ FreeLibrary(h);
+
+ return 0;
+
+}
diff --git a/testsuite/gna/issue803/main.c b/testsuite/gna/issue803/main.c
new file mode 100644
index 000000000..80feb6019
--- /dev/null
+++ b/testsuite/gna/issue803/main.c
@@ -0,0 +1,33 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+
+ void* h = dlopen("./tb.so", RTLD_LAZY);
+ if (!h){
+ fprintf(stderr, "%s\n", dlerror());
+ exit(1);
+ }
+
+ typedef int main_t(int, char**);
+
+ h = dlopen("./tb.so", RTLD_LAZY);
+ if (!h){
+ fprintf(stderr, "%s\n", dlerror());
+ exit(1);
+ }
+
+ main_t* ghdl_main = (main_t*)dlsym(h, "ghdl_main");
+ if (!ghdl_main){
+ fprintf(stderr, "%s\n", dlerror());
+ exit(2);
+ }
+
+ printf("ghdl_main return: %d\n", ghdl_main(argc, argv));
+
+ dlclose(h);
+
+ return 0;
+
+}
diff --git a/testsuite/gna/issue803/tb.vhdl b/testsuite/gna/issue803/tb.vhdl
new file mode 100644
index 000000000..61ee11e42
--- /dev/null
+++ b/testsuite/gna/issue803/tb.vhdl
@@ -0,0 +1,10 @@
+entity tb is
+end entity;
+
+architecture arch of tb is
+begin
+ process begin
+ report "Hello!" severity failure;
+ wait;
+ end process;
+end;
diff --git a/testsuite/gna/issue803/testsuite.sh b/testsuite/gna/issue803/testsuite.sh
new file mode 100755
index 000000000..018511ed9
--- /dev/null
+++ b/testsuite/gna/issue803/testsuite.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+
+if $GHDL --version | grep -q "GCC back-end"; then
+ echo "GCC backend detected"
+elif $GHDL --version | grep -q "LLVM back-end"; then
+ echo "LLVM backend detected"
+else
+ echo "This test requires GCC or LLVM backends"
+ exit 0
+fi
+
+if [ "$OS" = "Windows_NT" ]; then
+ gcc main-win.c -o main
+ analyze tb.vhdl
+ $GHDL -e -Wl,-shared -Wl,-Wl,-u,ghdl_main -o tb.dll tb
+ ./main
+ rm main.exe tb.dll *.o
+elif [ "$(uname -o)" = "Darwin" ]; then
+ gcc main-mac.c -o main
+ analyze tb.vhdl
+ $GHDL -e -Wl,-shared -Wl,-Wl,-u,_ghdl_main -o tb.dylib tb
+ ./main
+ rm main tb.dylib *.o
+else
+ echo "This test is disabled on Linux (requires an -fpic libgrt)"
+ exit 0
+fi
+
+clean
+
+echo "Test successful"