aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/a_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/a_SUITE_data
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'erts/emulator/test/a_SUITE_data')
-rw-r--r--erts/emulator/test/a_SUITE_data/Makefile.src10
-rw-r--r--erts/emulator/test/a_SUITE_data/timer_driver.c77
2 files changed, 87 insertions, 0 deletions
diff --git a/erts/emulator/test/a_SUITE_data/Makefile.src b/erts/emulator/test/a_SUITE_data/Makefile.src
new file mode 100644
index 0000000000..b4f1c4a2a5
--- /dev/null
+++ b/erts/emulator/test/a_SUITE_data/Makefile.src
@@ -0,0 +1,10 @@
+#
+# NOTE:
+# Suites with makefiles are run first. We want a_SUITE to be run first;
+# therefore, keep this makefile even if it should be empty.
+#
+
+all: timer_driver@dll@
+
+@SHLIB_RULES@
+
diff --git a/erts/emulator/test/a_SUITE_data/timer_driver.c b/erts/emulator/test/a_SUITE_data/timer_driver.c
new file mode 100644
index 0000000000..ef4dcdf501
--- /dev/null
+++ b/erts/emulator/test/a_SUITE_data/timer_driver.c
@@ -0,0 +1,77 @@
+/*
+ * Copied from driver_SUITE and modified...
+ */
+
+#include <stdio.h>
+#include "erl_driver.h"
+
+#define get_int32(s) ((((unsigned char*) (s))[0] << 24) | \
+ (((unsigned char*) (s))[1] << 16) | \
+ (((unsigned char*) (s))[2] << 8) | \
+ (((unsigned char*) (s))[3]))
+
+#define START_TIMER 0
+#define CANCEL_TIMER 1
+#define DELAY_START_TIMER 2
+#define TIMER 3
+#define CANCELLED 4
+
+static ErlDrvData timer_start(ErlDrvPort, char*);
+static void timer_stop(ErlDrvData), timer_read(ErlDrvData, char*, int), timer(ErlDrvData);
+
+static ErlDrvEntry timer_driver_entry =
+{
+ NULL,
+ timer_start,
+ timer_stop,
+ timer_read,
+ NULL,
+ NULL,
+ "timer_driver",
+ NULL,
+ NULL,
+ NULL,
+ timer,
+ NULL,
+ NULL
+};
+
+DRIVER_INIT(timer_drv)
+{
+ return &timer_driver_entry;
+}
+
+static ErlDrvData timer_start(ErlDrvPort port, char *buf)
+{
+ return (ErlDrvData)port;
+}
+
+/* set the timer, this is monitored from erlang measuring the time */
+static void timer_read(ErlDrvData port, char *buf, int len)
+{
+ char reply[1];
+
+ if (buf[0] == START_TIMER) {
+ /* fprintf(stderr, "[timer_drv] Setting timeout: %i\n", get_int32(buf + 1)); */
+ driver_set_timer(port, get_int32(buf + 1));
+ } else if (buf[0] == CANCEL_TIMER) {
+ /* fprintf(stderr, "[timer_drv] Timer cancelled\n"); */
+ driver_cancel_timer(port);
+ reply[0] = CANCELLED;
+ driver_output(port, reply, 1);
+ }
+}
+
+static void timer_stop(ErlDrvData port)
+{
+ driver_cancel_timer(port);
+}
+
+static void timer(ErlDrvData port)
+{
+ char reply[1];
+
+ /* fprintf(stderr, "[timer_drv] timer timed out\n"); */
+ reply[0] = TIMER;
+ driver_output((ErlDrvPort)port, reply, 1);
+}