Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_xendconfsxp.aug
1 module Test_xendconfsxp =
2
3  (* Empty file and comments *)
4
5  test Xendconfsxp.lns get "\n" = { }
6
7  test Xendconfsxp.lns get "# my comment\n" =
8    { "#scomment" = " my comment" }
9
10  test Xendconfsxp.lns get " \n# my comment\n" =
11    { }
12    { "#scomment" = " my comment" }
13
14  test Xendconfsxp.lns get "# my comment\n\n" =
15    { "#scomment" = " my comment" }
16    { }
17
18  test Xendconfsxp.lns get "# my comment\n \n" =
19    { "#scomment" = " my comment" }
20    { }
21
22  test Xendconfsxp.lns get "# my comment\n#com2\n" =
23    { "#scomment" = " my comment" }
24    { "#scomment" = "com2" }
25
26  test Xendconfsxp.lns get "# my comment\n\n" =
27    { "#scomment" = " my comment" }
28    { }
29
30  test Xendconfsxp.lns get "\n# my comment\n" =
31    { }
32    { "#scomment" = " my comment" }
33
34  test Xendconfsxp.lns get "(key value)" =
35    { "key" { "item" = "value" } }
36
37  test Xendconfsxp.lns get "(key value)\n# com\n" =
38    { "key" { "item" = "value" } }
39    { }
40    { "#scomment" = " com" }
41
42  test Xendconfsxp.lns get "(k2ey value)" =
43    { "k2ey" { "item" = "value" } }
44
45  test Xendconfsxp.lns get "(- value)" =
46    { "-" { "item" = "value" } }
47
48  test Xendconfsxp.lns get "(-bar value)" =
49    { "-bar" { "item" = "value" } }
50
51  test Xendconfsxp.lns get "(k-ey v-alue)\n# com\n" =
52    { "k-ey" { "item" = "v-alue" } }
53    { }
54    { "#scomment" = " com" }
55
56  test Xendconfsxp.lns get "(key value)" =
57    { "key" { "item" = "value" } }
58
59  test Xendconfsxp.lns get "(key value)(key2 value2)" =
60    { "key"
61      { "item" = "value" }
62    }
63    { "key2"
64      { "item" = "value2" }
65    }
66
67  test Xendconfsxp.lns get "( key value )( key2 value2 )" =
68    { "key"
69      { "item" = "value" }
70    }
71    { "key2"
72      { "item" = "value2" }
73    }
74
75  let source_7 = "(key value)(key2 value2)"
76  test Xendconfsxp.lns get source_7 =
77    { "key"
78      { "item" = "value" }
79    }
80    { "key2"
81      { "item" = "value2" }
82    }
83
84 (* 2 items?  it is a key/item *)
85
86  test Xendconfsxp.lns get "(key value)" =
87    { "key"
88      { "item" = "value" }
89    }
90
91  test Xendconfsxp.lns get "( key value )" =
92    { "key"
93      { "item" = "value" }
94    }
95
96 (* 3 items?  Not allowed. 2nd item must be in ()'s *)
97  test Xendconfsxp.lns get "(key value value2)" = *
98
99 (* key/list pairs. *)
100
101 (* 0 item -- TODO: implement this. *)
102
103  test Xendconfsxp.lns get "( key ())" = *
104
105 (* 1 item *)
106
107  test Xendconfsxp.lns get "(key (listitem1) )" =
108    { "key"
109      { "array"
110        { "item" = "listitem1" }
111      }
112    }
113
114  test Xendconfsxp.lns get "(key ( (foo bar bar bat ) ) )" =
115    { "key"
116      { "array"
117        { "array"
118          { "item" = "foo" }
119          { "item" = "bar" }
120          { "item" = "bar" }
121          { "item" = "bat" }
122        }
123      }
124    }
125
126  test Xendconfsxp.lns get "(key ((foo foo foo (bar bar bar))))" =
127    { "key"
128      { "array"
129        { "array"
130          { "item" = "foo" }
131          { "item" = "foo" }
132          { "item" = "foo" }
133          { "array"
134            { "item" = "bar" }
135            { "item" = "bar" }
136            { "item" = "bar" }
137          }
138        }
139      }
140    }
141
142 (* 2 item *)
143
144  test Xendconfsxp.lns get "(xen-api-server (foo bar))" =
145    { "xen-api-server"
146      { "array"
147        { "item" = "foo" }
148        { "item" = "bar" }
149      }
150    }
151
152  test Xendconfsxp.lns get "( key ( value value2 ))" =
153    { "key"
154      { "array"
155        { "item" = "value" }
156        { "item" = "value2" }
157      }
158    }
159
160 (* 3 item *)
161
162  test Xendconfsxp.lns get "( key ( value value2 value3 ))" =
163    { "key"
164      { "array"
165        { "item" = "value" }
166        { "item" = "value2" }
167        { "item" = "value3" }
168      }
169    }
170
171 (* quotes *)
172  test Xendconfsxp.lns get "(key \"foo\")" = { "key" { "item" = "\"foo\"" } }
173  test Xendconfsxp.lns get "(key \"\")" = { "key" { "item" = "\"\"" } }
174  test Xendconfsxp.lns get "( key \"foo\" )" = { "key" { "item" = "\"foo\"" } }
175  test Xendconfsxp.lns get "( key \"f oo\" )" = { "key" { "item" = "\"f oo\"" } }
176  test Xendconfsxp.lns get "( key \"f  oo\" )" = { "key" { "item" = "\"f  oo\"" } }
177  test Xendconfsxp.lns get "(foo \"this is \\\"quoted\\\" in quotes\")" =
178    { "foo" { "item" = "\"this is \\\"quoted\\\" in quotes\"" } }
179
180  test Xendconfsxp.lns get "( key \"fo\\'\" )" = { "key" { "item" = "\"fo\\'\""} }
181  test Xendconfsxp.lns get "( key \"fo\\'\" )" = { "key" { "item" = "\"fo\\'\""} }
182  test Xendconfsxp.lns get "( key \"\")" = { "key" { "item" = "\"\"" } }
183
184 (* Newlines in strange places *)
185  test Xendconfsxp.lns get "(\nkey\nbar\n)" = { "key" { "item" = "bar" } }
186  test Xendconfsxp.lns get "(\n\n\nkey\n\n\nbar\n\n\n)" = { "key" { "item" = "bar" } }
187  test Xendconfsxp.lns get "(\nkey\nbar\n)" = { "key" { "item" = "bar" } }
188
189 (* Comments in strange places *)
190  test Xendconfsxp.lns get "(\nkey #aa\nbar)" =
191    { "key"
192      { "#comment" = "aa" }
193      { "item" = "bar" }
194    }
195
196  test Xendconfsxp.lns get "(\nkey\n#aa\nbar)" =
197    { "key"
198      { "#comment" = "aa" }
199      { "item" = "bar" }
200    }
201
202  test Xendconfsxp.lns get "(\nkey\n #aa\nbar)" =
203    { "key"
204      { "#comment" = "aa" }
205      { "item" = "bar" }
206    }
207
208 (* Comments must have 1 space before the # *)
209  test Xendconfsxp.lns get "(\nkey# com\nbar\n)" = *
210  test Xendconfsxp.lns get "(\nkey#aa\nbar)" = *
211
212 (* Comments may start a line *)
213  test Xendconfsxp.lns get "(\nkey\n# com\nbar)" =
214    { "key"
215      { "#comment" = "com" }
216      { "item" = "bar" }
217    }
218  test Xendconfsxp.lns get "(\nkey\n#aa\nbar)" =
219    { "key"
220      { "#comment" = "aa" }
221      { "item" = "bar" }
222    }
223
224 (* Sub lists *)
225  test Xendconfsxp.lns get "(key ((foo foo) (bar bar)))" =
226    { "key"
227      { "array"
228        { "array"
229          { "item" = "foo" }
230          { "item" = "foo" }
231        }
232        { "array"
233          { "item" = "bar" }
234          { "item" = "bar" }
235        }
236      }
237    }
238
239
240  test Xendconfsxp.lns get "(aaa ((bbb ccc ddd) (eee fff)))" =
241    { "aaa"
242      { "array"
243        { "array"
244          { "item" = "bbb" }
245          { "item" = "ccc" }
246          { "item" = "ddd" }
247        }
248        { "array"
249          { "item" = "eee" }
250          { "item" = "fff" }
251        }
252      }
253    }
254
255 (* Comments in strange places *)
256  test Xendconfsxp.lns get "(\nkey\nbar # bb\n)" =
257    { "key"
258      { "item" = "bar" }
259      { "#comment" = "bb" }
260    }
261  test Xendconfsxp.lns get "(\nkey\nbar \n#cc\n)" =
262    { "key" { "item" = "bar" }
263            { "#comment" = "cc" } }
264  test Xendconfsxp.lns get "(\nkey\nbar \n #cc\n)" =
265    { "key" { "item" = "bar" }
266            { "#comment" = "cc" } }
267  test Xendconfsxp.lns get "(\nkey\nbar \n #cc\n )" =
268    { "key" { "item" = "bar" }
269            { "#comment" = "cc" } }
270  test Xendconfsxp.lns get "(foo ((foo foo foo) (unix none)))" =
271    { "foo"
272      { "array"
273        { "array"
274          { "item" = "foo" }
275          { "item" = "foo" }
276          { "item" = "foo" }
277        }
278        { "array"
279          { "item" = "unix" }
280          { "item" = "none" }
281        }
282      }
283    }
284
285  test Xendconfsxp.lns get "(foo ((foo foo 'foo') (unix none)))" =
286    { "foo"
287      { "array"
288        { "array"
289          { "item" = "foo" }
290          { "item" = "foo" }
291          { "item" = "'foo'" }
292        }
293        { "array"
294          { "item" = "unix" }
295          { "item" = "none" }
296        }
297      }
298    }
299
300  test Xendconfsxp.lns get "(xen-api-server ((9363 pam '^localhost$ example\\.com$') (unix none)))" =
301    { "xen-api-server"
302      { "array"
303        { "array"
304          { "item" = "9363" }
305          { "item" = "pam" }
306          { "item" = "'^localhost$ example\.com$'" }
307        }
308        { "array"
309          { "item" = "unix" }
310          { "item" = "none" }
311        }
312      }
313    }
314
315  test Xendconfsxp.lns get "# -*- sh -*-\n#foo\n#bar\n\n\n(foo bar)" =
316    { "#scomment" = " -*- sh -*-" }
317    { "#scomment" = "foo" }
318    { "#scomment" = "bar" }
319    {  }
320    {  }
321    { "foo"
322      { "item" = "bar" }
323    }
324
325 (* Test whitespace before lparen *)
326  test Xendconfsxp.lns get  " (network-script network-bridge)\n#\n" =
327    { "network-script" { "item" = "network-bridge" } }
328                       {  }
329                       { "#scomment" = "" }
330
331 (* Bugs: *)
332
333 (* Note: It works if you change the last \n to \t *)
334  test Xendconfsxp.lns get "(\nkey\n# com\nbar\n)" = *