blob: 992c6be5dd9f9977fe4e1d74dbcbe80a43397ad5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
demonstrate access to rpc calls from ejs
*/
function irpcObj()
{
var o = new Object();
o.input = new Object();
return o;
}
/*
generate a ramp as an integer array
*/
function ramp_array(N)
{
var a = new Array(N);
for (i=0;i<N;i++) {
a[i] = i+1;
}
return a;
}
/*
check that a status result is OK
*/
function check_status_ok(status)
{
if (status.is_ok != true) {
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.input.in_data = i;
status = dcerpc_echo_AddOne(conn, io);
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);
}
}
if (ARGV.length == 0) {
print("Usage: echo.js <RPCBINDING>\n");
exit(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);
print("All OK\n");
|