diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-28 06:46:03 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:30:08 -0500 |
commit | f6d2892faab30e6f205a81a008168b07e521ab85 (patch) | |
tree | a8564f854dc27aca17c3c6e81746a32c990ed3f1 /testprogs/ejs | |
parent | a97f6670288097adc7a924a93bb1078062ceee32 (diff) | |
download | samba-f6d2892faab30e6f205a81a008168b07e521ab85.tar.gz samba-f6d2892faab30e6f205a81a008168b07e521ab85.tar.bz2 samba-f6d2892faab30e6f205a81a008168b07e521ab85.zip |
r8821: continue the trend to move to a more OO style of interface for our js
calls. This changes the generated RPC and IRPC calls to use the 'this'
object pointer instead of requiring the passing of the object on each
call. So typical usage is now:
var echo = echo_init();
var io = irpcObj();
status = echo.connect("ncacn_np:server");
assert(status.is_ok);
io.input.in_data = 7;
status = echo.AddOne(io);
assert(status.is_ok);
(This used to be commit f7b49ecd0868c1f0fec75b371f132bbf357ad8c6)
Diffstat (limited to 'testprogs/ejs')
-rwxr-xr-x | testprogs/ejs/echo.js | 75 | ||||
-rwxr-xr-x | testprogs/ejs/samr.js | 48 |
2 files changed, 58 insertions, 65 deletions
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js index d464f8623e..aa44ca7eb0 100755 --- a/testprogs/ejs/echo.js +++ b/testprogs/ejs/echo.js @@ -16,8 +16,6 @@ if (ok == false) { libinclude("base.js"); -echo = rpcecho_init(); - /* generate a ramp as an integer array */ @@ -34,7 +32,7 @@ function ramp_array(N) /* test the echo_AddOne interface */ -function test_AddOne(conn) +function test_AddOne(echo) { var io = irpcObj(); @@ -42,7 +40,7 @@ function test_AddOne(conn) for (i=0;i<10;i++) { io.input.in_data = i; - status = echo.echo_AddOne(conn, io); + status = echo.echo_AddOne(io); check_status_ok(status); assert(io.output.out_data == i + 1); } @@ -51,7 +49,7 @@ function test_AddOne(conn) /* test the echo_EchoData interface */ -function test_EchoData(conn) +function test_EchoData(echo) { var io = irpcObj(); @@ -60,7 +58,7 @@ function test_EchoData(conn) for (i=0; i<30; i=i+5) { io.input.len = i; io.input.in_data = ramp_array(i); - status = echo.echo_EchoData(conn, io); + status = echo.echo_EchoData(io); check_status_ok(status); check_array_equal(io.input.in_data, io.output.out_data); } @@ -70,7 +68,7 @@ function test_EchoData(conn) /* test the echo_SinkData interface */ -function test_SinkData(conn) +function test_SinkData(echo) { var io = irpcObj(); @@ -79,7 +77,7 @@ function test_SinkData(conn) for (i=0; i<30; i=i+5) { io.input.len = i; io.input.data = ramp_array(i); - status = echo.echo_SinkData(conn, io); + status = echo.echo_SinkData(io); check_status_ok(status); } } @@ -88,7 +86,7 @@ function test_SinkData(conn) /* test the echo_SourceData interface */ -function test_SourceData(conn) +function test_SourceData(echo) { var io = irpcObj(); @@ -96,7 +94,7 @@ function test_SourceData(conn) for (i=0; i<30; i=i+5) { io.input.len = i; - status = echo.echo_SourceData(conn, io); + status = echo.echo_SourceData(io); check_status_ok(status); correct = ramp_array(i); check_array_equal(correct, io.output.data); @@ -107,14 +105,14 @@ function test_SourceData(conn) /* test the echo_TestCall interface */ -function test_TestCall(conn) +function test_TestCall(echo) { var io = irpcObj(); print("Testing echo_TestCall\n"); io.input.s1 = "my test string"; - status = echo.echo_TestCall(conn, io); + status = echo.echo_TestCall(io); check_status_ok(status); assert("this is a test string" == io.output.s2); } @@ -122,7 +120,7 @@ function test_TestCall(conn) /* test the echo_TestCall2 interface */ -function test_TestCall2(conn) +function test_TestCall2(echo) { var io = irpcObj(); @@ -130,7 +128,7 @@ function test_TestCall2(conn) for (i=1;i<=7;i++) { io.input.level = i; - status = echo.echo_TestCall2(conn, io); + status = echo.echo_TestCall2(io); check_status_ok(status); } } @@ -138,21 +136,21 @@ function test_TestCall2(conn) /* test the echo_TestSleep interface */ -function test_TestSleep(conn) +function test_TestSleep(echo) { var io = irpcObj(); print("Testing echo_TestSleep\n"); io.input.seconds = 1; - status = echo.echo_TestSleep(conn, io); + status = echo.echo_TestSleep(io); check_status_ok(status); } /* test the echo_TestEnum interface */ -function test_TestEnum(conn) +function test_TestEnum(echo) { var io = irpcObj(); @@ -164,7 +162,7 @@ function test_TestEnum(conn) io.input.foo2.e2 = echo.ECHO_ENUM1_32; io.input.foo3 = new Object(); io.input.foo3.e1 = echo.ECHO_ENUM2; - status = echo.echo_TestEnum(conn, io); + status = echo.echo_TestEnum(io); check_status_ok(status); assert(io.output.foo1 == echo.ECHO_ENUM1); assert(io.output.foo2.e1 == echo.ECHO_ENUM2); @@ -175,7 +173,7 @@ function test_TestEnum(conn) /* test the echo_TestSurrounding interface */ -function test_TestSurrounding(conn) +function test_TestSurrounding(echo) { var io = irpcObj(); @@ -184,7 +182,7 @@ function test_TestSurrounding(conn) io.input.data = new Object(); io.input.data.x = 10; io.input.data.surrounding = ramp_array(10); - status = echo.echo_TestSurrounding(conn, io); + status = echo.echo_TestSurrounding(io); check_status_ok(status); assert(io.output.data.surrounding.length == 20); check_array_zero(io.output.data.surrounding); @@ -193,48 +191,43 @@ function test_TestSurrounding(conn) /* test the echo_TestDoublePointer interface */ -function test_TestDoublePointer(conn) +function test_TestDoublePointer(echo) { var io = irpcObj(); print("Testing echo_TestDoublePointer\n"); io.input.data = 7; - status = echo.echo_TestDoublePointer(conn, io); + status = echo.echo_TestDoublePointer(io); check_status_ok(status); assert(io.input.data == io.input.data); } -if (ARGV.length == 0) { - print("Usage: echo.js <RPCBINDING>\n"); - exit(0); -} - if (options.ARGV.length != 1) { - println("Usage: samr.js <BINDING>"); + println("Usage: echo.js <BINDING>"); return -1; } var binding = options.ARGV[0]; -var conn = new Object(); +var echo = rpcecho_init(); print("Connecting to " + binding + "\n"); -status = rpc_connect(conn, binding, "rpcecho"); +status = echo.connect(binding); if (status.is_ok != true) { - print("Failed to connect to " + binding + " - " + status.errstr + "\n"); + printf("Failed to connect to %s - %s\n", binding, status.errstr); return; } -test_AddOne(conn); -test_EchoData(conn); -test_SinkData(conn); -test_SourceData(conn); -test_TestCall(conn); -test_TestCall2(conn); -test_TestSleep(conn); -test_TestEnum(conn); -test_TestSurrounding(conn); -test_TestDoublePointer(conn); +test_AddOne(echo); +test_EchoData(echo); +test_SinkData(echo); +test_SourceData(echo); +test_TestCall(echo); +test_TestCall2(echo); +test_TestSleep(echo); +test_TestEnum(echo); +test_TestSurrounding(echo); +test_TestDoublePointer(echo); print("All OK\n"); return 0; diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js index d0c2990158..b518fea234 100755 --- a/testprogs/ejs/samr.js +++ b/testprogs/ejs/samr.js @@ -21,39 +21,39 @@ libinclude("samr.js"); /* test the samr_Connect interface */ -function test_Connect(conn) +function test_Connect(samr) { print("Testing samr_Connect\n"); - return samrConnect(conn); + return samrConnect(samr); } /* test the samr_LookupDomain interface */ -function test_LookupDomain(conn, handle, domain) +function test_LookupDomain(samr, handle, domain) { print("Testing samr_LookupDomain\n"); - return samrLookupDomain(conn, handle, domain); + return samrLookupDomain(samr, handle, domain); } /* test the samr_OpenDomain interface */ -function test_OpenDomain(conn, handle, sid) +function test_OpenDomain(samr, handle, sid) { print("Testing samr_OpenDomain\n"); - return samrOpenDomain(conn, handle, sid); + return samrOpenDomain(samr, handle, sid); } /* test the samr_EnumDomainUsers interface */ -function test_EnumDomainUsers(conn, dom_handle) +function test_EnumDomainUsers(samr, dom_handle) { var i, users; print("Testing samr_EnumDomainUsers\n"); - users = samrEnumDomainUsers(conn, dom_handle); + users = samrEnumDomainUsers(samr, dom_handle); print("Found " + users.length + " users\n"); for (i=0;i<users.length;i++) { println("\t" + users[i].name + "\t(" + users[i].idx + ")"); @@ -63,10 +63,10 @@ function test_EnumDomainUsers(conn, dom_handle) /* test the samr_EnumDomainGroups interface */ -function test_EnumDomainGroups(conn, dom_handle) +function test_EnumDomainGroups(samr, dom_handle) { print("Testing samr_EnumDomainGroups\n"); - var i, groups = samrEnumDomainGroups(conn, dom_handle); + var i, groups = samrEnumDomainGroups(samr, dom_handle); print("Found " + groups.length + " groups\n"); for (i=0;i<groups.length;i++) { println("\t" + groups[i].name + "\t(" + groups[i].idx + ")"); @@ -76,10 +76,10 @@ function test_EnumDomainGroups(conn, dom_handle) /* test domain specific ops */ -function test_domain_ops(conn, dom_handle) +function test_domain_ops(samr, dom_handle) { - test_EnumDomainUsers(conn, dom_handle); - test_EnumDomainGroups(conn, dom_handle); + test_EnumDomainUsers(samr, dom_handle); + test_EnumDomainGroups(samr, dom_handle); } @@ -87,22 +87,22 @@ function test_domain_ops(conn, dom_handle) /* test the samr_EnumDomains interface */ -function test_EnumDomains(conn, handle) +function test_EnumDomains(samr, handle) { var i, domains; print("Testing samr_EnumDomains\n"); - domains = samrEnumDomains(conn, handle); + domains = samrEnumDomains(samr, handle); print("Found " + domains.length + " domains\n"); for (i=0;i<domains.length;i++) { print("\t" + domains[i].name + "\n"); } for (i=0;i<domains.length;i++) { print("Testing domain " + domains[i].name + "\n"); - sid = samrLookupDomain(conn, handle, domains[i].name); - dom_handle = test_OpenDomain(conn, handle, sid); - test_domain_ops(conn, dom_handle); - samrClose(conn, dom_handle); + sid = samrLookupDomain(samr, handle, domains[i].name); + dom_handle = test_OpenDomain(samr, handle, sid); + test_domain_ops(samr, dom_handle); + samrClose(samr, dom_handle); } } @@ -111,18 +111,18 @@ if (options.ARGV.length != 1) { return -1; } var binding = options.ARGV[0]; -var conn = new Object(); +var samr = samr_init(); print("Connecting to " + binding + "\n"); -status = rpc_connect(conn, binding, "samr"); +status = samr.connect(binding); if (status.is_ok != true) { print("Failed to connect to " + binding + " - " + status.errstr + "\n"); return -1; } -handle = test_Connect(conn); -test_EnumDomains(conn, handle); -samrClose(conn, handle); +handle = test_Connect(samr); +test_EnumDomains(samr, handle); +samrClose(samr, handle); print("All OK\n"); return 0; |