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"
28 static BOOL test_hive(TALLOC_CTX *mem_ctx, const char *backend, const char *location)
31 struct registry_key *root, *subkey;
34 if (!reg_has_backend(backend)) {
35 printf("Backend '%s' support not compiled in, ignoring\n", backend);
39 error = reg_open_hive(mem_ctx, backend, location, NULL, cmdline_credentials, &root);
40 if (!W_ERROR_IS_OK(error)) {
41 printf("reg_open_hive() failed\n");
45 /* This is a new backend. There should be no subkeys and no
47 error = reg_key_num_subkeys(root, &count);
48 if (!W_ERROR_IS_OK(error)) {
49 printf("reg_key_num_subkeys failed\n");
54 printf("New key has non-zero subkey count\n");
58 error = reg_key_num_values(root, &count);
59 if (!W_ERROR_IS_OK(error)) {
60 printf("reg_key_num_values failed\n");
65 printf("New key has non-zero value count\n");
69 error = reg_key_add_name(mem_ctx, root, "Nested\\Key", SEC_MASK_GENERIC, NULL, &subkey);
70 if (!W_ERROR_IS_OK(error)) {
74 error = reg_key_del(root, "Nested\\Key");
75 if (!W_ERROR_IS_OK(error)) {
84 BOOL torture_registry(struct torture_context *torture)
87 TALLOC_CTX *mem_ctx = talloc_init("torture_registry");
91 ret &= test_hive(mem_ctx, "nt4", "TEST.DAT");
92 ret &= test_hive(mem_ctx, "ldb", "test.ldb");
93 ret &= test_hive(mem_ctx, "gconf", ".");
94 ret &= test_hive(mem_ctx, "dir", ".");