2
* Copyright (C) 2006-2009 Citrix Systems Inc.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation; version 2.1 only. with the special
7
* exception on linking described in file LICENSE.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Lesser General Public License for more details.
14
(***************************************************************************
16
**************************************************************************)
23
try int_of_string (List.hd (String.split '\000' data))
29
let tid, rid, ty, data = pkt in
30
printf "%3x %s %d(%d) %s \"%s\".\n%!" !i op tid rid (Xb.Op.to_string ty) (String.escaped data);
32
let y (tid, ty, data) =
33
let spkt = (tid, !i, ty, data) in
35
send_packet xb tid !i ty data;
36
let rpkt = recv_packet xb in
39
let (_, _, _, data) = rpkt in
42
let x spkt = ignore (y spkt) in
44
x (0, Xb.Op.Read, "\000");
45
x (0, Xb.Op.Write, "\000");
46
x (0, Xb.Op.Getdomainpath, "\000");
47
x (0, Xb.Op.Directory, "\000");
48
x (0, Xb.Op.Mkdir, "\000");
49
x (0, Xb.Op.Getperms, "\000");
50
x (0, Xb.Op.Setperms, "\000");
52
(* too many arguments *)
53
x (0, Xb.Op.Write, "/test\000xxx\000yyy\000\000zzz");
54
x (0, Xb.Op.Read, "/test");
55
x (0, Xb.Op.Read, "/test\000");
56
x (0, Xb.Op.Read, "/test\000some\000otherargs");
57
x (0, Xb.Op.Directory, "/test\000spurious\000abc");
58
x (0, Xb.Op.Directory, "/test\000spurious");
59
x (0, Xb.Op.Getperms, "/test\000someotherargs");
60
x (0, Xb.Op.Getperms, "/test\000someotherargs\000others");
63
x (0, Xb.Op.Write, "/test\000");
64
x (0, Xb.Op.Write, "/test\000abc");
65
x (0, Xb.Op.Read, "/test");
66
x (0, Xb.Op.Read, "/test\000");
67
x (0, Xb.Op.Read, "/test\000\000");
68
x (0, Xb.Op.Write, "/test");
69
x (0, Xb.Op.Read, "/test");
70
x (0, Xb.Op.Read, "/test\000");
71
x (0, Xb.Op.Read, "/test\000\000");
73
x (0, Xb.Op.Write, "\000/");
75
x (0, Xb.Op.Directory, "/test");
76
x (0, Xb.Op.Directory, "/test\000");
77
x (0, Xb.Op.Directory, "/test\000\000");
79
x (0, Xb.Op.Rm, "/test");
80
x (0, Xb.Op.Directory, "/test");
81
x (0, Xb.Op.Directory, "/test\000");
82
x (0, Xb.Op.Directory, "/test\000\000");
84
x (0, Xb.Op.Write, "/test/abc\000x1");
85
x (0, Xb.Op.Write, "/test/def\000x2");
86
x (0, Xb.Op.Write, "/test/xyz\000x3");
87
x (0, Xb.Op.Write, "/test/xyz\000x4");
89
x (0, Xb.Op.Directory, "/test");
90
x (0, Xb.Op.Directory, "/test\000");
91
x (0, Xb.Op.Directory, "/test\000spurious\000");
93
x (0, Xb.Op.Getperms, "/test");
94
x (0, Xb.Op.Getperms, "/test\000");
95
x (0, Xb.Op.Getperms, "/test\000spurious\000");
97
(* setperms getperms *)
98
x (0, Xb.Op.Setperms, "/test");
99
x (0, Xb.Op.Getperms, "/test\000");
100
x (0, Xb.Op.Setperms, "/test\000");
101
x (0, Xb.Op.Getperms, "/test\000");
102
x (0, Xb.Op.Setperms, "/test\000\000");
103
x (0, Xb.Op.Getperms, "/test\000");
104
x (0, Xb.Op.Setperms, "/test\000n0\000");
105
x (0, Xb.Op.Getperms, "/test\000");
106
x (0, Xb.Op.Setperms, "/test\000n0");
107
x (0, Xb.Op.Getperms, "/test\000");
108
x (0, Xb.Op.Setperms, "/test\000n0\000r1");
109
x (0, Xb.Op.Getperms, "/test\000");
110
x (0, Xb.Op.Setperms, "/test\000n0\000r1\000");
111
x (0, Xb.Op.Getperms, "/test\000");
112
x (0, Xb.Op.Setperms, "/test\000n0r2\000spurious");
113
x (0, Xb.Op.Getperms, "/test\000");
115
(* get domain path *)
116
x (0, Xb.Op.Getdomainpath, "3\000");
117
x (0, Xb.Op.Getdomainpath, "10\000");
118
x (0, Xb.Op.Getdomainpath, "13 \000");
119
x (0, Xb.Op.Getdomainpath, " 17\000");
120
x (0, Xb.Op.Getdomainpath, "45\000spurious");
121
x (0, Xb.Op.Getdomainpath, "45\000really\000");
123
let t1 = tnb (y (0, Xb.Op.Transaction_start, "\000")) in
124
x (t1, Xb.Op.Transaction_end, "\000");
125
let t2 = tnb (y (0, Xb.Op.Transaction_start, "\000")) in
126
x (t2, Xb.Op.Transaction_end, string_of_int t2 ^ "\000");
127
let t3 = tnb (y (0, Xb.Op.Transaction_start, "\000\000")) in
128
x (t3, Xb.Op.Transaction_end, "0\000\000");
131
(***************************************************************************
133
**************************************************************************)
137
let xb = open_xb () in
138
finally (fun () -> do_test xb) (fun () -> close_xb xb);