aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/ddll_SUITE_data
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /erts/emulator/test/ddll_SUITE_data
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'erts/emulator/test/ddll_SUITE_data')
-rw-r--r--erts/emulator/test/ddll_SUITE_data/Makefile.src3
-rw-r--r--erts/emulator/test/ddll_SUITE_data/dummy_drv.c49
-rw-r--r--erts/emulator/test/ddll_SUITE_data/echo_drv.c52
-rw-r--r--erts/emulator/test/ddll_SUITE_data/echo_drv_fail_init.c59
-rw-r--r--erts/emulator/test/ddll_SUITE_data/initfail_drv.c46
-rw-r--r--erts/emulator/test/ddll_SUITE_data/lock_drv.c55
-rw-r--r--erts/emulator/test/ddll_SUITE_data/noinit_drv.c58
-rw-r--r--erts/emulator/test/ddll_SUITE_data/wrongname_drv.c50
8 files changed, 372 insertions, 0 deletions
diff --git a/erts/emulator/test/ddll_SUITE_data/Makefile.src b/erts/emulator/test/ddll_SUITE_data/Makefile.src
new file mode 100644
index 0000000000..61652a12e2
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/Makefile.src
@@ -0,0 +1,3 @@
+all: echo_drv@dll@ echo_drv_fail_init@dll@ noinit_drv@dll@ wrongname_drv@dll@ initfail_drv@dll@ dummy_drv@dll@ lock_drv@dll@
+
+@SHLIB_RULES@
diff --git a/erts/emulator/test/ddll_SUITE_data/dummy_drv.c b/erts/emulator/test/ddll_SUITE_data/dummy_drv.c
new file mode 100644
index 0000000000..e0d5067743
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/dummy_drv.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+#ifndef DRIVER_INIT
+# define DRIVER_INIT(x) driver_init
+#endif
+
+static ErlDrvPort erlang_port;
+static ErlDrvData dummy_start(ErlDrvPort, char*);
+static void dummy_read(ErlDrvData port, char *buf, int count);
+static void dummy_stop(ErlDrvData), easy_read(ErlDrvData, char*, int);
+
+static ErlDrvEntry dummy_driver_entry = {
+ NULL,
+ dummy_start,
+ dummy_stop,
+ dummy_read,
+ NULL,
+ NULL,
+ "dummy_drv",
+ NULL
+};
+
+DRIVER_INIT(dummy_drv)
+{
+ erlang_port = (ErlDrvPort)-1;
+ return &dummy_driver_entry;
+}
+
+static ErlDrvData dummy_start(ErlDrvPort port,char *buf)
+{
+ if (erlang_port != (ErlDrvPort)-1) {
+ return ERL_DRV_ERROR_GENERAL;
+ }
+
+ erlang_port = port;
+ return (ErlDrvData)port;
+}
+
+static void dummy_read(ErlDrvData port, char *buf, int count)
+{
+ driver_output(erlang_port, buf, count);
+}
+
+static void dummy_stop(ErlDrvData port)
+{
+ erlang_port = (ErlDrvPort)-1;
+}
+
diff --git a/erts/emulator/test/ddll_SUITE_data/echo_drv.c b/erts/emulator/test/ddll_SUITE_data/echo_drv.c
new file mode 100644
index 0000000000..edf78a979d
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/echo_drv.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+static ErlDrvPort erlang_port;
+static ErlDrvData echo_start(ErlDrvPort, char *);
+static void from_erlang(ErlDrvData, char*, int);
+static int echo_call(ErlDrvData drv_data, unsigned int command, char *buf,
+ int len, char **rbuf, int rlen, unsigned *ret_flags);
+static ErlDrvEntry echo_driver_entry = {
+ NULL, /* Init */
+ echo_start,
+ NULL, /* Stop */
+ from_erlang,
+ NULL, /* Ready input */
+ NULL, /* Ready output */
+ "echo_drv",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ echo_call
+};
+
+DRIVER_INIT(echo_drv)
+{
+ return &echo_driver_entry;
+}
+
+static ErlDrvData
+echo_start(ErlDrvPort port, char *buf)
+{
+ return (ErlDrvData) port;
+}
+
+static void
+from_erlang(ErlDrvData data, char *buf, int count)
+{
+ driver_output((ErlDrvPort) data, buf, count);
+}
+
+static int
+echo_call(ErlDrvData drv_data, unsigned int command, char *buf,
+ int len, char **rbuf, int rlen, unsigned *ret_flags)
+{
+ *rbuf = buf;
+ *ret_flags |= DRIVER_CALL_KEEP_BUFFER;
+ return len;
+}
+
diff --git a/erts/emulator/test/ddll_SUITE_data/echo_drv_fail_init.c b/erts/emulator/test/ddll_SUITE_data/echo_drv_fail_init.c
new file mode 100644
index 0000000000..3b2a44d907
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/echo_drv_fail_init.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+static ErlDrvPort erlang_port;
+static ErlDrvData echo_start(ErlDrvPort, char *);
+static void from_erlang(ErlDrvData, char*, int);
+static int echo_call(ErlDrvData drv_data, unsigned int command, char *buf,
+ int len, char **rbuf, int rlen, unsigned *ret_flags);
+static int echo_failing_init(void);
+
+static ErlDrvEntry echo_driver_entry = {
+ echo_failing_init,
+ echo_start,
+ NULL, /* Stop */
+ from_erlang,
+ NULL, /* Ready input */
+ NULL, /* Ready output */
+ "echo_drv",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ echo_call
+};
+
+DRIVER_INIT(echo_drv)
+{
+ return &echo_driver_entry;
+}
+
+static int echo_failing_init(void)
+{
+ return -1;
+}
+
+static ErlDrvData
+echo_start(ErlDrvPort port, char *buf)
+{
+ return (ErlDrvData) port;
+}
+
+static void
+from_erlang(ErlDrvData data, char *buf, int count)
+{
+ driver_output((ErlDrvPort) data, buf, count);
+}
+
+static int
+echo_call(ErlDrvData drv_data, unsigned int command, char *buf,
+ int len, char **rbuf, int rlen, unsigned *ret_flags)
+{
+ *rbuf = buf;
+ *ret_flags |= DRIVER_CALL_KEEP_BUFFER;
+ return len;
+}
+
diff --git a/erts/emulator/test/ddll_SUITE_data/initfail_drv.c b/erts/emulator/test/ddll_SUITE_data/initfail_drv.c
new file mode 100644
index 0000000000..b676ff5121
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/initfail_drv.c
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+static ErlDrvPort erlang_port;
+static ErlDrvData easy_start(ErlDrvPort, char*);
+static void easy_stop(ErlDrvData), easy_read(ErlDrvData, char*, int);
+
+static ErlDrvEntry easy_driver_entry =
+{
+ NULL,
+ easy_start,
+ easy_stop,
+ easy_read,
+ NULL,
+ NULL,
+ "easy",
+ NULL
+};
+
+DRIVER_INIT(initfail_drv)
+{
+ erlang_port = (ErlDrvPort)-1;
+ return 0;
+}
+
+static ErlDrvData easy_start(ErlDrvPort port, char *buf)
+{
+ if (erlang_port != (ErlDrvPort)-1) {
+ return ERL_DRV_ERROR_GENERAL;
+ }
+
+ fprintf(stderr, "Easy driver started with args %s\n", buf);
+ erlang_port = port;
+ return (ErlDrvData)port;
+}
+
+static void easy_read(ErlDrvData port, char *buf, int count)
+{
+ driver_output(erlang_port, buf, count);
+}
+
+static void easy_stop(ErlDrvData port)
+{
+ erlang_port = (ErlDrvPort) -1;
+}
+
diff --git a/erts/emulator/test/ddll_SUITE_data/lock_drv.c b/erts/emulator/test/ddll_SUITE_data/lock_drv.c
new file mode 100644
index 0000000000..2ec8fa3a29
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/lock_drv.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+static ErlDrvPort erlang_port;
+static ErlDrvData echo_start(ErlDrvPort, char *);
+static void from_erlang(ErlDrvData, char*, int);
+static int echo_call(ErlDrvData drv_data, unsigned int command, char *buf,
+ int len, char **rbuf, int rlen, unsigned *ret_flags);
+static ErlDrvEntry echo_driver_entry = {
+ NULL, /* Init */
+ echo_start,
+ NULL, /* Stop */
+ from_erlang,
+ NULL, /* Ready input */
+ NULL, /* Ready output */
+ "lock_drv",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ echo_call
+};
+
+DRIVER_INIT(echo_drv)
+{
+ return &echo_driver_entry;
+}
+
+static ErlDrvData
+echo_start(ErlDrvPort port, char *buf)
+{
+ driver_lock_driver(port);
+ return (ErlDrvData) port;
+}
+
+static void
+from_erlang(ErlDrvData data, char *buf, int count)
+{
+ driver_output((ErlDrvPort) data, buf, count);
+}
+
+static int
+echo_call(ErlDrvData drv_data, unsigned int command, char *buf,
+ int len, char **rbuf, int rlen, unsigned *ret_flags)
+{
+ ErlDrvPort port = (ErlDrvPort) drv_data;
+ driver_lock_driver(port);
+ *rbuf = buf;
+ *ret_flags |= DRIVER_CALL_KEEP_BUFFER;
+ return len;
+}
+
diff --git a/erts/emulator/test/ddll_SUITE_data/noinit_drv.c b/erts/emulator/test/ddll_SUITE_data/noinit_drv.c
new file mode 100644
index 0000000000..931386a305
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/noinit_drv.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+static ErlDrvPort erlang_port;
+static ErlDrvData easy_start(ErlDrvPort, char*);
+static void easy_stop(ErlDrvData), easy_read(ErlDrvData, char*, int);
+
+static ErlDrvEntry easy_driver_entry =
+{
+ NULL,
+ easy_start,
+ easy_stop,
+ easy_read,
+ NULL,
+ NULL,
+ "easy",
+ NULL
+};
+
+#ifdef __WIN32__
+/*
+ * Define a correct driver_init here, or the module won't compile.
+ * Note that it will not actually be used.
+ */
+DRIVER_INIT(noinit_drv)
+
+#else
+/*
+ * Provoke an error when loading the module.
+ */
+int no_driver_init(void *handle)
+#endif
+{
+ erlang_port = (ErlDrvPort)-1;
+ return &easy_driver_entry;
+}
+
+static ErlDrvData easy_start(ErlDrvPort port,char *buf)
+{
+ if (erlang_port != (ErlDrvPort)-1) {
+ return ERL_DRV_ERROR_GENERAL;
+ }
+
+ fprintf(stderr, "Easy driver started with args %s\n", buf);
+ erlang_port = port;
+ return (ErlDrvData)port;
+}
+
+static void easy_read(ErlDrvData port, char *buf, int count)
+{
+ driver_output(erlang_port, buf, count);
+}
+
+static void easy_stop(ErlDrvData port)
+{
+ erlang_port = (ErlDrvPort)-1;
+}
+
diff --git a/erts/emulator/test/ddll_SUITE_data/wrongname_drv.c b/erts/emulator/test/ddll_SUITE_data/wrongname_drv.c
new file mode 100644
index 0000000000..3a35820ee7
--- /dev/null
+++ b/erts/emulator/test/ddll_SUITE_data/wrongname_drv.c
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include "erl_driver.h"
+
+#ifndef DRIVER_INIT
+# define DRIVER_INIT(x) driver_init
+#endif
+
+static ErlDrvPort erlang_port;
+static ErlDrvData easy_start(ErlDrvPort, char*);
+static void easy_stop(ErlDrvData), easy_read(ErlDrvData, char*, int);
+
+static ErlDrvEntry easy_driver_entry =
+{
+ NULL,
+ easy_start,
+ easy_stop,
+ easy_read,
+ NULL,
+ NULL,
+ "easy",
+ NULL
+};
+
+DRIVER_INIT(wrongname_drv)
+{
+ erlang_port = (ErlDrvPort)-1;
+ return &easy_driver_entry;
+}
+
+static ErlDrvData easy_start(ErlDrvPort port,char *buf)
+{
+ if (erlang_port != (ErlDrvPort)-1) {
+ return ERL_DRV_ERROR_GENERAL;
+ }
+
+ fprintf(stderr, "Easy driver started with args %s\n", buf);
+ erlang_port = port;
+ return (ErlDrvData)port;
+}
+
+static void easy_read(ErlDrvData port, char *buf, int count)
+{
+ driver_output(erlang_port, buf, count);
+}
+
+static void easy_stop(ErlDrvData port)
+{
+ erlang_port = (ErlDrvPort)-1;
+}
+