aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/test/erl_match_SUITE_data
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2009-12-15 10:33:33 +0000
committerErlang/OTP <[email protected]>2009-12-15 12:24:17 +0100
commitfe272a8454d2379c2ed5b0f9f04b493574316a8d (patch)
tree38e09b9529109886886241b03a20f589c3559d04 /lib/erl_interface/test/erl_match_SUITE_data
parentde4639e46760493bad61ae48a5d894001216720e (diff)
downloadotp-fe272a8454d2379c2ed5b0f9f04b493574316a8d.tar.gz
otp-fe272a8454d2379c2ed5b0f9f04b493574316a8d.tar.bz2
otp-fe272a8454d2379c2ed5b0f9f04b493574316a8d.zip
Include the test suites for erl_interface
Diffstat (limited to 'lib/erl_interface/test/erl_match_SUITE_data')
-rw-r--r--lib/erl_interface/test/erl_match_SUITE_data/Makefile.first21
-rw-r--r--lib/erl_interface/test/erl_match_SUITE_data/Makefile.src42
-rw-r--r--lib/erl_interface/test/erl_match_SUITE_data/match_test.c113
3 files changed, 176 insertions, 0 deletions
diff --git a/lib/erl_interface/test/erl_match_SUITE_data/Makefile.first b/lib/erl_interface/test/erl_match_SUITE_data/Makefile.first
new file mode 100644
index 0000000000..12141d210c
--- /dev/null
+++ b/lib/erl_interface/test/erl_match_SUITE_data/Makefile.first
@@ -0,0 +1,21 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2000-2009. All Rights Reserved.
+#
+# The contents of this file are subject to the Erlang Public License,
+# Version 1.1, (the "License"); you may not use this file except in
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+
+match_test_decl.c: match_test.c
+ erl -noinput -pa ../all_SUITE_data -s init_tc run match_test -s erlang halt
diff --git a/lib/erl_interface/test/erl_match_SUITE_data/Makefile.src b/lib/erl_interface/test/erl_match_SUITE_data/Makefile.src
new file mode 100644
index 0000000000..8ce6c9c985
--- /dev/null
+++ b/lib/erl_interface/test/erl_match_SUITE_data/Makefile.src
@@ -0,0 +1,42 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1997-2009. All Rights Reserved.
+#
+# The contents of this file are subject to the Erlang Public License,
+# Version 1.1, (the "License"); you may not use this file except in
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+
+include @erl_interface_mk_include@@[email protected]
+
+CC0 = @CC@
+CC = ..@DS@all_SUITE_data@DS@gccifier@exe@ -CC"$(CC0)"
+LD = @LD@
+LIBPATH = @erl_interface_libpath@
+LIBERL = $(LIBPATH)/@erl_interface_lib@
+LIBEI = $(LIBPATH)/@erl_interface_eilib@
+LIBFLAGS = ../all_SUITE_data/runner@obj@ \
+ $(LIBERL) $(LIBEI) @LIBS@ @erl_interface_sock_libs@ \
+ @erl_interface_threadlib@
+CFLAGS = @EI_CFLAGS@ $(THR_DEFS) -I@erl_interface_include@ -I../all_SUITE_data
+MATCH_OBJS = match_test@obj@ match_test_decl@obj@
+
+all: match_test@exe@
+
+clean:
+ $(RM) $(MATCH_OBJS)
+ $(RM) match_test@exe@
+
+match_test@exe@: $(MATCH_OBJS) $(LIBERL) $(LIBEI)
+ $(LD) @CROSSLDFLAGS@ -o $@ $(MATCH_OBJS) $(LIBFLAGS)
+
diff --git a/lib/erl_interface/test/erl_match_SUITE_data/match_test.c b/lib/erl_interface/test/erl_match_SUITE_data/match_test.c
new file mode 100644
index 0000000000..153a528b0b
--- /dev/null
+++ b/lib/erl_interface/test/erl_match_SUITE_data/match_test.c
@@ -0,0 +1,113 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1997-2009. All Rights Reserved.
+ *
+ * The contents of this file are subject to the Erlang Public License,
+ * Version 1.1, (the "License"); you may not use this file except in
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ */
+
+/*
+ * Purpose: Tests the erl_match() function.
+ * Author: Bjorn Gustavsson
+ */
+
+#include "runner.h"
+
+TESTCASE(erl_match_server)
+{
+ erl_init(NULL, 0);
+
+ for (;;) {
+ ETERM* pattern;
+ ETERM* term;
+
+ pattern = get_term();
+ if (pattern == NULL) {
+ report(1);
+ return;
+ } else {
+ term = get_term();
+ if (term == NULL) {
+ fail("Unexpected EOF term");
+ } else {
+ send_term(erl_mk_int(erl_match(pattern, term)));
+ erl_free_term(pattern);
+ erl_free_term(term);
+ }
+ }
+ }
+
+}
+
+TESTCASE(erl_match_bind)
+{
+ erl_init(NULL, 0);
+
+ for (;;) {
+ char* pattern;
+ ETERM* term;
+
+ pattern=read_packet(NULL);
+
+ switch (pattern[0]) {
+ case 'e':
+ free(pattern);
+ report(1);
+ return;
+
+ case 'b':
+ {
+ ETERM* patt_term;
+
+ /*
+ * Get the pattern string and convert it using erl_format().
+ *
+ * Note that the call to get_term() below destroys the buffer
+ * that the pattern variable points to. Therefore, it is
+ * essential to call erl_format() here, before
+ * calling get_term().
+ */
+
+ message("Pattern: %s", pattern+1);
+ patt_term = erl_format(pattern+1);
+ free(pattern);
+
+ if (patt_term == NULL) {
+ fail("erl_format() failed");
+ }
+
+ /*
+ * Get the term and send back the result of the erl_match()
+ * call.
+ */
+
+ term = get_term();
+ if (term == NULL) {
+ fail("Unexpected eof term");
+ }
+ else {
+ send_term(erl_mk_int(erl_match(patt_term, term)));
+ }
+ erl_free_term(patt_term);
+ erl_free_term(term);
+ }
+ break;
+
+ default:
+ free(pattern);
+ fail("Illegal character received");
+ }
+
+ }
+}