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"
26 static BOOL test_hive(TALLOC_CTX *mem_ctx, const char *backend, const char *location)
29 struct registry_key *root, *subkey;
32 if (!reg_has_backend(backend)) {
33 printf("Backend '%s' support not compiled in, ignoring\n", backend);
37 error = reg_open_hive(mem_ctx, backend, location, NULL, &root);
38 if (!W_ERROR_IS_OK(error)) {
39 printf("reg_open_hive() failed\n");
43 /* This is a new backend. There should be no subkeys and no
45 error = reg_key_num_subkeys(root, &count);
46 if (!W_ERROR_IS_OK(error)) {
47 printf("reg_key_num_subkeys failed\n");
52 printf("New key has non-zero subkey count\n");
56 error = reg_key_num_values(root, &count);
57 if (!W_ERROR_IS_OK(error)) {
58 printf("reg_key_num_values failed\n");
63 printf("New key has non-zero value count\n");
67 error = reg_key_add_name(mem_ctx, root, "Nested\\Key", SEC_MASK_GENERIC, NULL, &subkey);
68 if (!W_ERROR_IS_OK(error)) {
72 error = reg_key_del(root, "Nested\\Key");
73 if (!W_ERROR_IS_OK(error)) {
82 BOOL torture_registry(void)
85 TALLOC_CTX *mem_ctx = talloc_init("torture_registry");
89 ret &= test_hive(mem_ctx, "nt4", "TEST.DAT");
90 ret &= test_hive(mem_ctx, "ldb", "test.ldb");
91 ret &= test_hive(mem_ctx, "gconf", ".");
92 ret &= test_hive(mem_ctx, "dir", ".");