3 # tests for the "net registry" command - local access to the registry db
6 NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
8 NETREG="${NET} registry"
11 . $incdir/test_functions.sh
19 ${NETREG} enumerate ${KEY}
26 ${NETREG} getsd ${KEY}
29 test_enumerate_nonexisting()
32 ${NETREG} enumerate ${KEY}
33 if test "x$?" = "x0" ; then
34 echo "ERROR: enumerate succeeded with key '${KEY}'"
41 test_enumerate_no_key()
44 if test "x$?" = "x0" ; then
45 echo "ERROR: enumerate succeeded without any key spcified"
52 test_create_existing()
55 EXPECTED="createkey opened existing ${KEY}"
56 OUTPUT=`${NETREG} createkey ${KEY}`
57 if test "x$?" = "x0" ; then
58 if test "$OUTPUT" = "$EXPECTED" ; then
61 echo "got '$OUTPUT', expected '$EXPECTED'"
73 BASEKEY=`dirname $KEY`
74 SUBKEY=`basename $KEY`
76 ${NETREG} createkey ${KEY}
77 if test "x$?" != "x0" ; then
82 # check enumerate of basekey lists new key:
83 OUTPUT=`${NETREG} enumerate ${BASEKEY}`
84 if test "x$?" != "x0" ; then
85 echo "ERROR: failed to enumerate key '${BASEKEY}'"
92 EXPECTED="Keyname = ${SUBKEY}"
93 echo -e "$OUTPUT" | grep ^Keyname | grep ${SUBKEY}
94 if test "x$?" != "x0" ; then
95 echo "ERROR: did not find expexted '$EXPECTED' in output"
101 # check enumerate of new key works:
102 ${NETREG} enumerate ${KEY}
108 BASEKEY=`dirname ${KEY}`
109 SUBKEY=`basename ${KEY}`
111 test_createkey "${KEY}"
113 if test "x$?" != "x0" ; then
118 ${NETREG} deletekey ${KEY}
120 # check enumerate of basekey does not show key anymore:
121 OUTPUT=`${NETREG} enumerate ${BASEKEY}`
122 if test "x$?" != "x0" ; then
128 UNEXPECTED="Keyname = ${SUBKEY}"
129 echo -e "$OUTPUT" | grep ^Keyname | grep ${SUBKEY}
130 if test "x$?" = "x0" ; then
131 echo "ERROR: found '$UNEXPECTED' after delete in output"
137 # check enumerate of key itself does not work anymore:
138 ${NETREG} enumerate ${KEY}
139 if test "x$?" = "x0" ; then
140 echo "ERROR: 'enumerate ${KEY}' works after 'deletekey ${KEY}'"
147 test_deletekey_nonexisting()
151 test_deletekey "${KEY}"
153 if test "x$?" != "x0" ; then
158 ${NETREG} deletekey "${KEY}"
159 if test "x$?" = "x0" ; then
160 echo "ERROR: delete after delete succeeded for key '${KEY}'"
165 test_createkey_with_subkey()
168 KEY2=`dirname ${KEY}`
169 SUBKEYNAME2=`basename ${KEY}`
170 BASENAME=`dirname ${KEY2}`
171 SUBKEYNAME1=`basename ${KEY2}`
173 ${NETREG} createkey ${KEY}
175 if test "x$?" != "x0" ; then
180 # check we can enumerate to level key
181 ${NETREG} enumerate ${KEY}
182 if test "x$?" != "x0" ; then
183 echo "ERROR: failed to enumerate '${KEY}' after creation"
189 ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
192 test_deletekey_with_subkey()
195 KEY2=`dirname ${KEY}`
197 ${NETREG} createkey ${KEY}
199 if test "x$?" != "x0" ; then
204 OUTPUT=`${NETREG} deletekey ${KEY2}`
206 if test "x$?" = "x0" ; then
207 echo "ERROR: delete of key with subkey succeeded"
214 ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
224 test_createkey ${KEY}
225 if test "x$?" != "x0" ; then
230 ${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE} ${VALVALUE}
231 if test "x$?" != "x0" ; then
232 echo "ERROR: failed to set value testval in key ${KEY}"
237 OUTPUT=`${NETREG} enumerate ${KEY}`
238 if test "x$?" != "x0" ; then
239 echo "ERROR: failure calling enumerate for key ${KEY}"
246 echo -e "$OUTPUT" | {
249 SEARCH1=`echo $LINE | grep ^Valuename | grep ${VALNAME}`
250 if test "x$?" = "x0" ; then
253 SEARCH2=`echo $LINE | grep "^Value " | grep ${VALVALUE}`
254 if test "x$?" = "x0" ; then
261 if test "x$FOUND" != "x1" ; then
262 echo "ERROR: did not find value '${VALNAME}' with enumerate"
263 echo "enumerate output:"
276 ${NETREG} deletevalue ${KEY} ${VALNAME}
279 test_deletevalue_nonexisting()
284 ${NETREG} deletevalue ${KEY} ${VALNAME}
285 if test "x$?" = "x0" ; then
286 echo "ERROR: succeeded deleting value ${VALNAME}"
293 test_setvalue_twice()
302 OUTPUT=`test_setvalue ${KEY} ${VALNAME} ${VALTYPE1} ${VALVALUE1}`
303 if test "x$?" != "x0" ; then
309 ${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE2} ${VALVALUE2}
313 testit "enumerate HKLM" \
314 test_enumerate HKLM || \
315 failed=`expr $failed + 1`
317 testit "enumerate nonexisting hive" \
318 test_enumerate_nonexisting XYZ || \
319 failed=`expr $failed + 1`
321 testit "enumerate without key" \
322 test_enumerate_no_key || \
323 failed=`expr $failed + 1`
325 testit "getsd HKLM" \
327 failed=`expr $failed + 1`
329 testit "create existing HKLM" \
330 test_create_existing || \
331 failed=`expr $failed + 1`
333 testit "create key" \
334 test_createkey HKLM/testkey || \
335 failed=`expr $failed + 1`
337 testit "delete key" \
338 test_deletekey HKLM/testkey || \
339 failed=`expr $failed + 1`
341 testit "delete^2 key" \
342 test_deletekey_nonexisting HKLM/testkey || \
343 failed=`expr $failed + 1`
345 testit "enumerate nonexisting key" \
346 test_enumerate_nonexisting HKLM/testkey || \
347 failed=`expr $failed +1`
349 testit "create key with subkey" \
350 test_createkey_with_subkey HKLM/testkey/subkey || \
351 failed=`expr $failed + 1`
353 testit "delete key with subkey" \
354 test_deletekey_with_subkey HKLM/testkey/subkey || \
355 failed=`expr $failed + 1`
358 test_setvalue HKLM/testkey testval sz moin || \
359 failed=`expr $failed + 1`
361 testit "delete value" \
362 test_deletevalue HKLM/testkey testval || \
363 failed=`expr $failed + 1`
365 testit "delete nonexisting value" \
366 test_deletevalue_nonexisting HKLM/testkey testval || \
367 failed=`expr $failed + 1`
369 testit "set value to different type"
370 test_setvalue_twice HKLM/testkey testval sz moin dword 42 || \
371 failed=`expr $failed + 1`
373 testit "delete key with value" \
374 test_deletekey HKLM/testkey || \
375 failed=`expr $failed + 1`