2 Unix SMB/CIFS implementation.
4 local testing of registry library
6 Copyright (C) Jelmer Vernooij 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "lib/registry/registry.h"
25 #include "lib/cmdline/popt_common.h"
26 #include "torture/torture.h"
27 #include "torture/ui.h"
29 static bool test_hive(struct torture_context
*parent_ctx
, const char *backend
, const char *location
)
32 struct registry_key
*root
, *subkey
;
34 struct torture_test
*ctx
= torture_test(parent_ctx
, "test_hive", backend
);
36 if (!reg_has_backend(backend
)) {
37 torture_skip(ctx
, "Backend '%s' support not compiled in", backend
);
41 error
= reg_open_hive(ctx
, backend
, location
, NULL
, cmdline_credentials
, &root
);
42 torture_assert_werr_ok(ctx
, error
, "reg_open_hive()");
44 /* This is a new backend. There should be no subkeys and no
46 error
= reg_key_num_subkeys(root
, &count
);
47 torture_assert_werr_ok(ctx
, error
, "reg_key_num_subkeys()");
49 torture_assert(ctx
, count
!= 0, "New key has non-zero subkey count");
51 error
= reg_key_num_values(root
, &count
);
52 torture_assert_werr_ok(ctx
, error
, "reg_key_num_values");
54 torture_assert(ctx
, count
!= 0, "New key has non-zero value count");
56 error
= reg_key_add_name(ctx
, root
, "Nested\\Key", SEC_MASK_GENERIC
, NULL
, &subkey
);
57 torture_assert_werr_ok(ctx
, error
, "reg_key_add_name");
59 error
= reg_key_del(root
, "Nested\\Key");
60 torture_assert_werr_ok(ctx
, error
, "reg_key_del");
69 BOOL
torture_registry(struct torture_context
*torture
)
75 ret
&= test_hive(torture
, "nt4", "TEST.DAT");
76 ret
&= test_hive(torture
, "ldb", "test.ldb");
77 ret
&= test_hive(torture
, "gconf", ".");
78 ret
&= test_hive(torture
, "dir", ".");