From 27a5daae33616e662a36ed514c31618d51ad66e3 Mon Sep 17 00:00:00 2001 From: Niclas Eklund Date: Thu, 2 Sep 2010 16:15:32 +0200 Subject: Add test suite for ic --- .../JavaClient.java | 759 +++++++++++++++++++++ .../java_client_erl_server_SUITE_data/Makefile.src | 88 +++ .../java_erl_test.idl | 68 ++ .../java_client_erl_server_SUITE_data/m_i_impl.erl | 169 +++++ 4 files changed, 1084 insertions(+) create mode 100644 lib/ic/test/java_client_erl_server_SUITE_data/JavaClient.java create mode 100644 lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src create mode 100644 lib/ic/test/java_client_erl_server_SUITE_data/java_erl_test.idl create mode 100644 lib/ic/test/java_client_erl_server_SUITE_data/m_i_impl.erl (limited to 'lib/ic/test/java_client_erl_server_SUITE_data') diff --git a/lib/ic/test/java_client_erl_server_SUITE_data/JavaClient.java b/lib/ic/test/java_client_erl_server_SUITE_data/JavaClient.java new file mode 100644 index 0000000000..1881279ac8 --- /dev/null +++ b/lib/ic/test/java_client_erl_server_SUITE_data/JavaClient.java @@ -0,0 +1,759 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 2003-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% + * + */ +public class JavaClient { + + public static void main(String[] argv) + { + System.out.println("Hello World!"); + if (argv.length < 4) { + System.out.println("Too few arguments!"); + System.exit(1); + } + // for (int j = 0; j < argv.length; j++) + // System.out.println(argv[j]); + try { + if (argv[3].equals("marshal_ll")) { + System.out.println("marshal_ll"); + marshal_ll(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_ull")) { + marshal_ull(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_l")) { + marshal_l(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_ul")) { + marshal_ul(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_s")) { + marshal_s(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_us")) { + marshal_us(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_c")) { + marshal_c(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_wc")) { + marshal_wc(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_str")) { + marshal_str(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_any_3")) { + marshal_any_3(argv[0], argv[1], argv[2], argv[3]); + } + else if (argv[3].equals("marshal_any_2")) { + marshal_any_2(argv[0], argv[1], argv[2], argv[3]); + } + else { + System.out.println("Unknown test: "+argv[3]); + System.exit(2); + } + } catch (java.lang.Exception e) { + System.out.println("Exception!: "+e); + System.exit(3); + } + System.exit(0); + } + + + + static void marshal_ll(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + System.out.println("Just warming up.."+i); + verify_ll(i, 3, 2, 1); + verify_ll(i, 5, 4, 3); + verify_ll(i, -128, 0, 1); + // The small integer border + verify_ll(i, 255, 0, 1); + verify_ll(i, 256, 0, 1); + // The integer border + verify_ll(i, (1L<<26)-1L, 0L, 1); + verify_ll(i, 1L<<26, 0L, 1); + verify_ll(i, -(1L<<26), 0L, 1); + verify_ll(i, (1L<<27)-1L, 0L, 1); + verify_ll(i, 1L<<27, 0L, 1); + verify_ll(i, -(1L<<27), 0L, 1); + // Bignum byte borders + verify_ll(i, (1L<<32)-1L, 0L, 1); + verify_ll(i, 1L<<32, 0L, 1); + verify_ll(i, -(1L<<32)+1L, 0L, 1); + verify_ll(i, -(1L<<32), 0L, 1); + verify_ll(i, (1L<<40)-1L, 0L, 1); + verify_ll(i, 1L<<40, 0L, 1); + verify_ll(i, -(1L<<40)+1L, 0L, 1); + verify_ll(i, -(1L<<40), 0L, 1); + verify_ll(i, (1L<<48)-1L, 0L, 1); + verify_ll(i, 1L<<48, 0L, 1); + verify_ll(i, -(1L<<48)+1L, 0L, 1); + verify_ll(i, -(1L<<48), 0L, 1); + // Java long border + verify_ll(i, java.lang.Long.MAX_VALUE, 0L, 1); + verify_ll(i, java.lang.Long.MIN_VALUE, 0L, 1); + verify_ll(i, -1L, 0L, 1); + // Impossible decodes + verify_ll_bad(i, java.lang.Long.MAX_VALUE, -1L, 1); + verify_ll_bad(i, java.lang.Long.MIN_VALUE, 1L, 1); + verify_ll_bad(i, java.lang.Long.MIN_VALUE, 0L, -1); + verify_ll_bad(i, java.lang.Long.MAX_VALUE, -1L, 2); + verify_ll_bad(i, java.lang.Long.MIN_VALUE, 0L, 2); + } + + static void marshal_ull(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_ull(i, 3, 2, 1); + verify_ull(i, 5, 4, 3); + // The small integer border + verify_ull(i, 255, 0, 1); + verify_ull(i, 256, 0, 1); + // The integer border + verify_ull(i, (1L<<26)-1L, 0L, 1); + verify_ull(i, 1L<<26, 0L, 1); + verify_ull(i, (1L<<27)-1L, 0L, 1); + verify_ull(i, 1L<<27, 0L, 1); + // Bignum byte borders + verify_ull(i, (1L<<32)-1L, 0L, 1); + verify_ull(i, 1L<<32, 0L, 1); + verify_ull(i, (1L<<40)-1L, 0L, 1); + verify_ull(i, 1L<<40, 0L, 1); + verify_ull(i, (1L<<48)-1L, 0L, 1); + verify_ull(i, 1L<<48, 0L, 1); + // Java long border + verify_ull(i, java.lang.Long.MAX_VALUE, 0L, 1); + verify_ull(i, java.lang.Long.MIN_VALUE, 0L, 1); + verify_ull(i, -1L, 0L, 1); + verify_ull(i, java.lang.Long.MAX_VALUE, + java.lang.Long.MIN_VALUE, 1); + // Impossible decodes + verify_ull_bad(i, -1L, -1L, 1); + verify_ull_bad(i, java.lang.Long.MAX_VALUE, -1L, 2); + } + + static void marshal_l(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_l(i, 3, 2, 1); + verify_l(i, 5, 4, 3); + verify_l(i, -128, 0, 1); + // The small integer border + verify_l(i, 255, 0, 1); + verify_l(i, 256, 0, 1); + // The integer border + verify_l(i, (1<<26)-1, 0, 1); + verify_l(i, 1<<26, 0, 1); + verify_l(i, -(1<<26), 0, 1); + verify_l(i, (1<<27)-1, 0, 1); + verify_l(i, 1<<27, 0, 1); + verify_l(i, -(1<<27), 0, 1); + // Java int border + verify_l(i, java.lang.Integer.MAX_VALUE, 0, 1); + verify_l(i, java.lang.Integer.MIN_VALUE, 0, 1); + // Impossible decodes + verify_l_bad(i, java.lang.Integer.MAX_VALUE, -1, 1); + verify_l_bad(i, java.lang.Integer.MIN_VALUE, 1, 1); + verify_l_bad(i, java.lang.Integer.MIN_VALUE, 0, -1); + } + + static void marshal_ul(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_ul(i, 3, 2, 1); + verify_ul(i, 5, 4, 3); + // The small integer border + verify_ul(i, 255, 0, 1); + verify_ul(i, 256, 0, 1); + // The integer border + verify_ul(i, (1<<26)-1, 0, 1); + verify_ul(i, 1<<26, 0, 1); + verify_ul(i, (1<<27)-1, 0, 1); + verify_ul(i, 1<<27, 0, 1); + // Java int border + verify_ul(i, java.lang.Integer.MAX_VALUE, 0, 1); + verify_ul(i, java.lang.Integer.MIN_VALUE, 0, 1); + verify_ul(i, -1, 0, 1); + verify_ul(i, java.lang.Integer.MAX_VALUE, + java.lang.Integer.MIN_VALUE, 1); + // Impossible decodes + verify_ul_bad(i, -1, -1, 1); + } + + static void marshal_s(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_s(i, 3, 2, 1); + verify_s(i, 5, 4, 3); + verify_s(i, -128, 0, 1); + // The small integer border + verify_s(i, 255, 0, 1); + verify_s(i, 256, 0, 1); + // Java short border + verify_s(i, java.lang.Short.MAX_VALUE, 0, 1); + verify_s(i, java.lang.Short.MIN_VALUE, 0, 1); + // Impossible decodes + verify_s_bad(i, java.lang.Short.MAX_VALUE, -1, 1); + verify_s_bad(i, java.lang.Short.MIN_VALUE, 1, 1); + verify_s_bad(i, java.lang.Short.MIN_VALUE, 0, -1); + } + + static void marshal_us(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_us(i, 3, 2, 1); + verify_us(i, 5, 4, 3); + // The small integer border + verify_us(i, 255, 0, 1); + verify_us(i, 256, 0, 1); + // Java short border + verify_us(i, java.lang.Short.MAX_VALUE, 0, 1); + verify_us(i, java.lang.Short.MIN_VALUE, 0, 1); + verify_us(i, -1, 0, 1); + verify_us(i, java.lang.Short.MAX_VALUE, + java.lang.Short.MIN_VALUE, 1); + // Impossible decodes + verify_us_bad(i, -1, -1, 1); + } + + static void marshal_c(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_c(i, '\3', '\2', 1); + verify_c(i, '\5', '\4', 3); + // The small integer border + verify_c(i, '\u00FF', '\0', 1); + verify_c(i, '\u0100', '\0', 1); + // Java char border + verify_c(i, java.lang.Character.MAX_VALUE, '\0', 1); + verify_c(i, java.lang.Character.MIN_VALUE, '\0', 1); + verify_c(i, java.lang.Character.MAX_VALUE, + java.lang.Character.MIN_VALUE, 1); + // Impossible decodes + verify_c_bad(i, '\u8000', '\0', 2); + } + + static void marshal_wc(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_wc(i, '\3', '\2', 1); + verify_wc(i, '\5', '\4', 3); + // The small integer border + verify_wc(i, '\u00FF', '\0', 1); + verify_wc(i, '\u0100', '\0', 1); + // Java char border + verify_wc(i, java.lang.Character.MAX_VALUE, '\0', 1); + verify_wc(i, java.lang.Character.MIN_VALUE, '\0', 1); + verify_wc(i, java.lang.Character.MAX_VALUE, + java.lang.Character.MIN_VALUE, 1); + // Impossible decodes + verify_c_bad(i, '\u8000', '\0', 2); + } + + static void marshal_str(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + // Just warming up.. + verify_str(i, 100, 100); + verify_str(i, 100, 1); + // Erlang string border + verify_str(i, 65535, 1); + verify_str(i, 2, 65535); + // Erlang string border out + verify_str(i, 65536, 1); + verify_str(i, 65536, 65536); + } + + static void marshal_any_3(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + com.ericsson.otp.ic.Any x = new com.ericsson.otp.ic.Any(); + com.ericsson.otp.ic.Any y = new com.ericsson.otp.ic.Any(); + com.ericsson.otp.ic.Any z = new com.ericsson.otp.ic.Any(); + + x.insert_longlong(java.lang.Long.MAX_VALUE); + y.insert_longlong(1L); + z.insert_longlong(java.lang.Long.MAX_VALUE-1L); + System.out.println("verify_any_3 longlong max"); + verify_any_3(i, x, y, 1, z); + + x.insert_longlong(java.lang.Long.MIN_VALUE); + y.insert_longlong(-1L); + z.insert_longlong(java.lang.Long.MIN_VALUE+1L); + System.out.println("verify_any_3 longlong min"); + verify_any_3(i, x, y, 1, z); + + x.insert_ulonglong(-1L); + y.insert_longlong(1L); + z.insert_ulonglong(-2L); + System.out.println("verify_any_3 ulonglong max"); + verify_any_3(i, x, y, 1, z); + + x.insert_ulonglong(0L); + y.insert_longlong(-1L); + z.insert_ulonglong(1L); + System.out.println("verify_any_3 ulonglong min"); + verify_any_3(i, x, y, 1, z); + + x.insert_long(java.lang.Integer.MAX_VALUE); + y.insert_long(1); + z.insert_long(java.lang.Integer.MAX_VALUE-1); + System.out.println("verify_any_3 long max"); + verify_any_3(i, x, y, 1, z); + + x.insert_long(java.lang.Integer.MIN_VALUE); + y.insert_long(-1); + z.insert_long(java.lang.Integer.MIN_VALUE+1); + System.out.println("verify_any_3 long min"); + verify_any_3(i, x, y, 1, z); + + x.insert_ulong(-1); + y.insert_long(1); + z.insert_ulong(-2); + System.out.println("verify_any_3 ulong max"); + verify_any_3(i, x, y, 1, z); + + x.insert_ulong(0); + y.insert_long(-1); + z.insert_ulong(1); + System.out.println("verify_any_3 ulong min"); + verify_any_3(i, x, y, 1, z); + + x.insert_short(java.lang.Short.MAX_VALUE); + y.insert_short((short)1); + z.insert_short((short)(java.lang.Short.MAX_VALUE-1)); + System.out.println("verify_any_3 short max"); + verify_any_3(i, x, y, 1, z); + + x.insert_short(java.lang.Short.MIN_VALUE); + y.insert_short((short)-1); + z.insert_short((short)(java.lang.Short.MIN_VALUE+1)); + System.out.println("verify_any_3 short min"); + verify_any_3(i, x, y, 1, z); + + x.insert_ushort((short)-1); + y.insert_short((short)1); + z.insert_ushort((short)-2); + System.out.println("verify_any_3 ushort max"); + verify_any_3(i, x, y, 1, z); + + x.insert_ushort((short)0); + y.insert_short((short)-1); + z.insert_ushort((short)1); + System.out.println("verify_any_3 ushort min"); + verify_any_3(i, x, y, 1, z); + + x.insert_char('\377'); + y.insert_char('\1'); + z.insert_char('\376'); + System.out.println("verify_any_3 char max"); + verify_any_3(i, x, y, 1, z); + + x.insert_wchar('\uFFFF'); + y.insert_wchar('\u0001'); + z.insert_wchar('\uFFFE'); + System.out.println("verify_any_3 char max"); + verify_any_3(i, x, y, 1, z); + } + + static void marshal_any_2(String selfNode, String peerNode, + String cookie, String serverName) + throws java.lang.Exception + { + m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName); + m.s s = new m.s(); + com.ericsson.otp.ic.Any a = new com.ericsson.otp.ic.Any(); + // + s.ull_x = -1L; + s.ll_x = java.lang.Long.MAX_VALUE; + s.ll_y = 1L; + s.ull_z = -2L; + s.ll_z = java.lang.Long.MAX_VALUE-1L; + // + s.ul_x = -1; + s.l_x = java.lang.Integer.MAX_VALUE; + s.l_y = 1; + s.ul_z = -2; + s.l_z = java.lang.Integer.MAX_VALUE-1; + // + s.us_x = (short)-1; + s.s_x = java.lang.Short.MAX_VALUE; + s.s_y = (short)1; + s.us_z = (short)-2; + s.s_z = (short)(java.lang.Short.MAX_VALUE-1); + // + s.c_x = '\377'; + s.c_y = '\1'; + s.c_z = '\376'; + s.wc_x = '\uFFFF'; + s.wc_y = '\u0001'; + s.wc_z = '\uFFFE'; + m.sHelper.insert(a, s); + verify_any_2(i, a, 1); + + s.ull_x = 0L; + s.ll_x = java.lang.Long.MIN_VALUE; + s.ll_y = -1L; + s.ull_z = 1L; + s.ll_z = java.lang.Long.MIN_VALUE+1L; + // + s.ul_x = 0; + s.l_x = java.lang.Integer.MIN_VALUE; + s.l_y = -1; + s.ul_z = 1; + s.l_z = java.lang.Integer.MIN_VALUE+1; + // + s.us_x = (short)0; + s.s_x = java.lang.Short.MIN_VALUE; + s.s_y = (short)-1; + s.us_z = (short)1; + s.s_z = (short)(java.lang.Short.MIN_VALUE+1); + // + s.c_x = '\0'; + s.c_y = '\0'; + s.c_z = '\0'; + s.wc_x = '\u0000'; + s.wc_y = '\u0000'; + s.wc_z = '\u0000'; + m.sHelper.insert(a, s); + verify_any_2(i, a, 1); + } + + + static void verify_ll(m._iStub i, long x, long y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + System.out.println("verify_ll "+a); + a.ll_x = x; + a.ll_y = y; + long expected = (x - y)*(short)b; + long result = i.marshal_ll(a, (short)b); + if (result == expected) { + System.out.println("verify_ll("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_ll("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_ull(m._iStub i, long x, long y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.ull_x = x; + a.ll_y = y; + long expected = (x - y)*(short)b; + long result = i.marshal_ull(a, (short)b); + if (result == expected) { + System.out.println("verify_ull("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_ull("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_l(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.l_x = x; + a.l_y = y; + int expected = (x - y)*(short)b; + int result = i.marshal_l(a, (short)b); + if (result == expected) { + System.out.println("verify_l("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_l("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_ul(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.ul_x = x; + a.l_y = y; + int expected = (x - y)*(short)b; + int result = i.marshal_ul(a, (short)b); + if (result == expected) { + System.out.println("verify_ul("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_ul("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_s(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.s_x = (short)x; + a.s_y = (short)y; + short expected = (short)((x - y)*(short)b); + short result = i.marshal_s(a, (short)b); + if (result == expected) { + System.out.println("verify_s("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_s("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_us(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.us_x = (short)x; + a.s_y = (short)y; + short expected = (short)((x - y)*(short)b); + short result = i.marshal_us(a, (short)b); + if (result == expected) { + System.out.println("verify_us("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_us("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_c(m._iStub i, char x, char y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.c_x = x; + a.c_y = y; + char expected = (char)(((int)x - (int)y)*(short)b); + char result = i.marshal_c(a, (short)b); + if (result == expected) { + System.out.println("verify_c("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_c("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_wc(m._iStub i, char x, char y, int b) + throws java.lang.Exception + { + m.s a = new m.s(); + a.wc_x = x; + a.wc_y = y; + char expected = (char)(((int)x - (int)y)*(short)b); + char result = i.marshal_wc(a, (short)b); + if (result == expected) { + System.out.println("verify_wc("+x+", "+y+", "+b+") => " + +result); + } else { + System.out.println("verify_wc("+x+", "+y+", "+b+") => " + +result+" != "+expected); + System.exit(4); + } + } + + static void verify_str(m._iStub i, int a_len, int b_len) + throws java.lang.Exception + { + String a = mk_str(a_len); + String b = mk_str(b_len); + String expected = a + b; + String result = i.strcat(a, b); + if (result.equals(expected)) { + System.out.println("verify_str(\""+a+"\", \""+b+"\") => \"" + +result+"\""); + } else { + System.out.println("verify_str(\""+a+"\", \""+b+"\") => \"" + +result+"\" != \""+expected.length()+"\""); + System.exit(4); + } + } + + static String mk_str(int len) + throws StringIndexOutOfBoundsException + { + StringBuffer s = new StringBuffer(); + // 17 characters is prime relative all bases of two - on purpose + do s.append("qwertyuiopasdfghj"); while (s.length() < len); + return s.substring(0, len); + } + + static void verify_any_3(m._iStub i, + com.ericsson.otp.ic.Any x, + com.ericsson.otp.ic.Any y, + int b, + com.ericsson.otp.ic.Any expected) + throws java.lang.Exception + { + com.ericsson.otp.ic.Any result = i.marshal_any_3(x, y, (short)b); + if (! expected.equal(result)) { + System.exit(4); + } + } + + static void verify_any_2(m._iStub i, com.ericsson.otp.ic.Any a, int b) + throws java.lang.Exception + { + com.ericsson.otp.ic.Any result = i.marshal_any_2(a, (short)b); + if (! a.equal(result)) { + System.exit(4); + } + } + + + + static void verify_ll_bad(m._iStub i, long x, long y, int b) + throws java.lang.Exception + { + try { + verify_ll(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_ull_bad(m._iStub i, long x, long y, int b) + throws java.lang.Exception + { + try { + verify_ull(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_l_bad(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + try { + verify_l(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_ul_bad(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + try { + verify_ul(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_s_bad(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + try { + verify_s(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_us_bad(m._iStub i, int x, int y, int b) + throws java.lang.Exception + { + try { + verify_us(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_c_bad(m._iStub i, char x, char y, int b) + throws java.lang.Exception + { + try { + verify_c(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + + static void verify_wc_bad(m._iStub i, char x, char y, int b) + throws java.lang.Exception + { + try { + verify_wc(i, x, y, b); + System.out.println("Expected exception missing!"); + System.exit(5); + } catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) { + System.out.println("Expected exception: "+e); + } + } + +} diff --git a/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src b/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src new file mode 100644 index 0000000000..de1503401c --- /dev/null +++ b/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src @@ -0,0 +1,88 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2003-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% +# +# +# Makefile.src for java_client_erl_server test +# Note: This file *must* work for both Unix and Windows +# +# We use both `rm' (Unix) and `del' (Windows) for removing files, but +# with a `-' in front so that the error in not finding `rm' (`del') on +# Windows (Unix) is ignored. +# +# VxWorks? XXX +# + +.SUFFIXES: +.SUFFIXES: .erl .idl .@EMULATOR@ .java + + +JAVAC = @JAVAC@ +ERLC = erlc + +# ic variables available from ts: +# +# ic_libpath: @ic_libpath@ +# ic_include_path: @ic_include_path@ + +IC_INCLUDE_PATH = @ic_include_path@ +IC_CLASSPATH = @ic_classpath@ + +JINTERFACE_CLASSPATH = @jinterface_classpath@ + +CLASSPATH = .@PS@$(IC_CLASSPATH)@PS@$(JINTERFACE_CLASSPATH)@PS@ + +GEN_JAVA_FILES = \ + m@DS@_iImplBase.java \ + m@DS@_iStub.java \ + m@DS@i.java m@DS@iHelper.java m@DS@iHolder.java \ + m@DS@s.java m@DS@sHelper.java m@DS@sHolder.java + +GEN_HRL_FILES = \ + m.hrl \ + m_i.hrl \ + oe_java_erl_test.hrl + +GEN_ERL_FILES = \ + m_i.erl \ + oe_java_erl_test.erl + +JAVA_FILES = $(GEN_JAVA_FILES) JavaClient.java +CLASS_FILES = $(JAVA_FILES:.java=.class) +ERL_FILES = $(GEN_ERL_FILES) m_i_impl.erl +EBINS = $(ERL_FILES:.erl=.@EMULATOR@) + + +all: $(CLASS_FILES) $(EBINS) + +clean: + -rm -f $(GEN_JAVA_FILES) $(CLASS_FILES) \ + $(GEN_ERL_FILES) $(GEN_HRL_FILES) $(EBINS) + -del /F /Q $(GEN_JAVA_FILES) $(CLASS_FILES) \ + $(GEN_ERL_FILES) $(GEN_HRL_FILES) $(EBINS) + +$(GEN_JAVA_FILES) : java_erl_test.idl + $(ERLC) -I $(IC_INCLUDE_PATH) "+{be,java}" java_erl_test.idl + +$(CLASS_FILES) : $(JAVA_FILES) + $(JAVAC) -classpath $(CLASSPATH) $(JAVA_FILES) + +$(GEN_ERL_FILES) $(GEN_HRL_FILES): java_erl_test.idl + $(ERLC) -I $(IC_INCLUDE_PATH) "+{be,erl_genserv}" java_erl_test.idl + +.erl.@EMULATOR@: + $(ERLC) -I $(IC_INCLUDE_PATH) $< diff --git a/lib/ic/test/java_client_erl_server_SUITE_data/java_erl_test.idl b/lib/ic/test/java_client_erl_server_SUITE_data/java_erl_test.idl new file mode 100644 index 0000000000..b72c972d3b --- /dev/null +++ b/lib/ic/test/java_client_erl_server_SUITE_data/java_erl_test.idl @@ -0,0 +1,68 @@ + + +// %CopyrightBegin% +// +// Copyright Ericsson AB 2003-2010. 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% +module m { + + struct s { + long long ll_x; + unsigned long long ull_x; + long long ll_y; + long long ll_z; + unsigned long long ull_z; + + long l_x; + unsigned long ul_x; + long l_y; + long l_z; + unsigned long ul_z; + + short s_x; + unsigned short us_x; + short s_y; + short s_z; + unsigned short us_z; + + char c_x; + char c_y; + char c_z; + + wchar wc_x; + wchar wc_y; + wchar wc_z; + }; + + interface i { + long long marshal_ll( in s a, in short b ); + unsigned long long marshal_ull( in s a, in short b ); + + long marshal_l( in s a, in short b ); + unsigned long marshal_ul( in s a, in short b ); + + short marshal_s( in s a, in short b ); + unsigned short marshal_us( in s a, in short b ); + + char marshal_c( in s a, in short b ); + wchar marshal_wc( in s a, in short b ); + + string strcat( in string a, in string b ); + + any marshal_any_3( in any x, in any y, in short b ); + any marshal_any_2( in any a, in short b ); + }; + +}; diff --git a/lib/ic/test/java_client_erl_server_SUITE_data/m_i_impl.erl b/lib/ic/test/java_client_erl_server_SUITE_data/m_i_impl.erl new file mode 100644 index 0000000000..77e532288f --- /dev/null +++ b/lib/ic/test/java_client_erl_server_SUITE_data/m_i_impl.erl @@ -0,0 +1,169 @@ +%%-------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2003-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% +%% +%%-------------------------------------------------------------------- +-module(m_i_impl). + +-export([marshal_ll/3,marshal_ull/3, + marshal_l/3,marshal_ul/3, + marshal_s/3,marshal_us/3, + marshal_c/3,marshal_wc/3, + strcat/3, + marshal_any_3/4,marshal_any_2/3]). +-export([init/1,terminate/2,code_change/3]). + +-include("m.hrl"). + +-define(TK_M_S, {tk_struct, + "IDL:m/s:1.0", + "s", + [{"ll_x",tk_longlong}, + {"ull_x",tk_ulonglong}, + {"ll_y",tk_longlong}, + {"ll_z",tk_longlong}, + {"ull_z",tk_ulonglong}, + {"l_x",tk_long}, + {"ul_x",tk_ulong}, + {"l_y",tk_long}, + {"l_z",tk_long}, + {"ul_z",tk_ulong}, + {"s_x",tk_short}, + {"us_x",tk_ushort}, + {"s_y",tk_short}, + {"s_z",tk_short}, + {"us_z",tk_ushort}, + {"c_x",tk_char}, + {"c_y",tk_char}, + {"c_z",tk_char}, + {"wc_x",tk_wchar}, + {"wc_y",tk_wchar}, + {"wc_z",tk_wchar}|_]}). + + + +marshal_ll(State, #m_s{ll_x = X, ll_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + +marshal_ull(State, #m_s{ull_x = X, ll_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + + +marshal_l(State, #m_s{l_x = X, l_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + +marshal_ul(State, #m_s{ul_x = X, l_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + + +marshal_s(State, #m_s{s_x = X, s_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + +marshal_us(State, #m_s{us_x = X, s_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + + +marshal_c(State, #m_s{c_x = X, c_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + +marshal_wc(State, #m_s{wc_x = X, wc_y = Y}=_A, B) when integer(B) -> + R = (X - Y)*B, + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + +strcat(State, A, B) when list(A), list(B) -> + R = A++B, + io:format("~p", [{?MODULE,?LINE,[length(A),length(B),A,B,R]}]), + {reply, R, State}; +strcat(State, A, B) -> + io:format("~p", [{?MODULE,?LINE,[A,B]}]), + {reply, [], State}. + +marshal_any_3(State, {any,TkX,_}=X, {any,_,_}=Y, B) when integer(B) -> + R = any(mul(sub(any(X), any(Y)), B), TkX), + io:format("~p", [{?MODULE,?LINE,[X,Y,B,R]}]), + {reply, R, State}. + +marshal_any_2(State, + {any,TkA,#m_s{ll_x=LL_X, ull_x=ULL_X, ll_y=LL_Y, + l_x=L_X, ul_x=UL_X, l_y=L_Y, + s_x=S_X, us_x=US_X, s_y=S_Y, + c_x=C_X, c_y=C_Y, + wc_x=WC_X, wc_y=WC_Y} = A}, + B) when integer(B) -> + {check_type_code,?TK_M_S} = {check_type_code,TkA}, + ULL_Z = (ULL_X - LL_Y) * B, + LL_Z = (LL_X - LL_Y) * B, + UL_Z = (UL_X - L_Y) * B, + L_Z = (L_X - L_Y) * B, + US_Z = (US_X - S_Y) * B, + S_Z = (S_X - S_Y) * B, + C_Z = (C_X - C_Y) * B, + WC_Z = (WC_X - WC_Y) * B, + R = A#m_s{ll_z=LL_Z, ull_z=ULL_Z, + l_z=L_Z, ul_z=UL_Z, + s_z=S_Z, us_z=US_Z, + c_z=C_Z, wc_z=WC_Z}, + io:format("~p", [{?MODULE,?LINE,[A,B,R]}]), + {reply, {any,TkA,R}, State}. + + + +init(_Env) -> + {ok, []}. + +terminate(_Reason, _State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + + +any({any,tk_longlong,X}) -> X; +any({any,tk_long,X}) -> X; +any({any,tk_short,X}) -> X; +any({any,tk_ulonglong,X}) -> X; +any({any,tk_ulong,X}) -> X; +any({any,tk_ushort,X}) -> X; +any({any,tk_char,X}) -> X; +any({any,tk_wchar,X}) -> X. + +any(X, Tk) when integer(X) -> {any,Tk,X}. + +sub(X, Y) when integer(X), integer(Y) -> + X - Y. + +mul(X, Y) when integer(X), integer(Y) -> + X * Y. + +napp(0, L) -> L; +napp(N, L) when integer(N), N >= 1 -> napp(N-1, L)++L. -- cgit v1.2.3