summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-01-31 14:36:24 +0100
committerStefan Metzmacher <metze@samba.org>2011-01-31 18:39:42 +0100
commit675a5e959877caf587315496a3ca92b6407d3afb (patch)
treed2ca0d0b9500ae9dcfbbe3a4ffc86ee3e92add8c
parentb586e5aabd85c1b1d19586139789ba14a0e31d84 (diff)
downloadsamba-675a5e959877caf587315496a3ca92b6407d3afb.tar.gz
samba-675a5e959877caf587315496a3ca92b6407d3afb.tar.bz2
samba-675a5e959877caf587315496a3ca92b6407d3afb.zip
midltests: add examples of toplevel vs. embedded unions with global 'ms_union'
metze
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_17.idl94
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_17.txt137
2 files changed, 231 insertions, 0 deletions
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_17.idl b/testprogs/win32/midltests/valid/midltests_union_align_17.idl
new file mode 100644
index 0000000000..f1514527dc
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_17.idl
@@ -0,0 +1,94 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ struct us {
+ enum level_enum level;
+ [switch_is(level)] union {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ } u;
+ };
+
+ void midltests_fn(
+ [in,ref] enum level_enum *level,
+ [in,switch_is(*level)] union u u,
+ [out,ref] struct us *us,
+ [in,out,ref] char *c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ enum level_enum level;
+ char c = 'c';
+ struct us us;
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ level = ZERO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = ONE;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = TWO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = FOUR;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = EIGHT;
+ cli_midltests_fn(&level, u, &us, &c);
+}
+
+void srv_midltests_fn(enum level_enum *level, union u u, struct us *us, char *c)
+{
+ printf("srv_midltests_fn: Start\n");
+ us->level = *level;
+ us->u.h = u.h;
+ printf("srv_midltests_fn: End\n");
+ return;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_17.txt b/testprogs/win32/midltests/valid/midltests_union_align_17.txt
new file mode 100644
index 0000000000..7b62241a73
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_17.txt
@@ -0,0 +1,137 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+ndr32:in => out: ptype[request] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+ndr32:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 00 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+NDRTcpThread[ndr64] stop
+
+Test OK