summaryrefslogtreecommitdiff
path: root/testprogs/ejs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-07 07:43:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:18 -0500
commit0fe84a92fbd8cded71cce8c31b510296a1165fb6 (patch)
tree504fc4312c15b2895ae1e8f4a0c9e2ceed435382 /testprogs/ejs
parent74ac1686d5d0fcadbdacc8ff1bf9ab200e748737 (diff)
downloadsamba-0fe84a92fbd8cded71cce8c31b510296a1165fb6.tar.gz
samba-0fe84a92fbd8cded71cce8c31b510296a1165fb6.tar.bz2
samba-0fe84a92fbd8cded71cce8c31b510296a1165fb6.zip
r8196: - added testing of the EchoData interface in the echo test script
- add asserts on all calls for correct results (This used to be commit 0b67754c281f387148b64ba00742437330dc68f7)
Diffstat (limited to 'testprogs/ejs')
-rw-r--r--testprogs/ejs/echo.js86
1 files changed, 75 insertions, 11 deletions
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js
index 1579afa94f..992c6be5dd 100644
--- a/testprogs/ejs/echo.js
+++ b/testprogs/ejs/echo.js
@@ -5,26 +5,79 @@
function irpcObj()
{
var o = new Object();
- o.in = new Object();
+ o.input = new Object();
return o;
}
-function test_AddOne(binding)
+/*
+ generate a ramp as an integer array
+ */
+function ramp_array(N)
{
- var status;
- var conn = new Object();
- var io = irpcObj();
+ var a = new Array(N);
+ for (i=0;i<N;i++) {
+ a[i] = i+1;
+ }
+ return a;
+}
+
- status = rpc_connect(conn, binding, "rpcecho");
+/*
+ check that a status result is OK
+*/
+function check_status_ok(status)
+{
if (status.is_ok != true) {
- print("Failed to connect to " + binding + " - " + status.errstr + "\n");
- return;
+ printVars(status);
}
+ assert(status.is_ok == true);
+}
+
+/*
+ check that two arrays are equal
+*/
+function check_array_equal(a1, a2)
+{
+ assert(a1.length == a2.length);
+ for (i=0; i<a1.length; i++) {
+ assert(a1[i] == a2[i]);
+ }
+}
+
+/*
+ test the echo_AddOne interface
+*/
+function test_AddOne(conn)
+{
+ var status;
+ var io = irpcObj();
+
+ print("Testing echo_AddOne\n");
for (i=0;i<10;i++) {
- io.in.in_data = i;
+ io.input.in_data = i;
status = dcerpc_echo_AddOne(conn, io);
- print("AddOne(" + i + ")=" + io.out.out_data + "\n");
+ check_status_ok(status);
+ assert(io.output.out_data == i + 1);
+ }
+}
+
+/*
+ test the echo_EchoData interface
+*/
+function test_EchoData(conn)
+{
+ var status;
+ var io = irpcObj();
+
+ print("Testing echo_EchoData\n");
+
+ for (i=0; i<30; i=i+5) {
+ io.input.len = i;
+ io.input.in_data = ramp_array(i);
+ status = dcerpc_echo_EchoData(conn, io);
+ check_status_ok(status);
+ check_array_equal(io.input.in_data, io.output.out_data);
}
}
@@ -34,5 +87,16 @@ if (ARGV.length == 0) {
}
var binding = ARGV[0];
+var conn = new Object();
+
+print("Connecting to " + binding + "\n");
+status = rpc_connect(conn, binding, "rpcecho");
+if (status.is_ok != true) {
+ print("Failed to connect to " + binding + " - " + status.errstr + "\n");
+ return;
+}
+
+test_AddOne(conn);
+test_EchoData(conn);
-test_AddOne(binding);
+print("All OK\n");