From b409d4120f9ae451f93a2322267c0f346531d9f3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 15:16:40 +0000 Subject: r24667: Finally merge the registry improvements that Wilco Baan Hofman and I have been working on for at least half a year now. Contains the following improvements: * proper layering (finally!) for the registry library. Distinction is now made between 'real' backends (local, remote, wine, etc) and the low-level hive backends (regf, creg, ldb, ...) that are only used by the local registry backend * tests for all important hive and registry operations * re-enable RPC-WINREG tests (still needs more work though, as some return values aren't checked yet) * write support for REGF files * dir backend now supports setting/reading values, creating keys * support for storing security descriptors * remove CREG backend as it was incomplete, didn't match the data model and wasn't used at all anyway * support for parsing ADM files as used by the policy editor (see lib/policy) * support for parsing PREG files (format used by .POL files) * new streaming interface for registry diffs (improves speed and memory usage for regdiff/regpatch significantly) ... and fixes a large number of bugs in the registry code (This used to be commit 7a1eec6358bc863dfc671c542b7185d3e39d7b5a) --- source4/lib/registry/tests/hive.c | 383 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 383 insertions(+) create mode 100644 source4/lib/registry/tests/hive.c (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c new file mode 100644 index 0000000000..a04bc1168e --- /dev/null +++ b/source4/lib/registry/tests/hive.c @@ -0,0 +1,383 @@ +/* + Unix SMB/CIFS implementation. + + local testing of registry library - hives + + Copyright (C) Jelmer Vernooij 2005-2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/registry/registry.h" +#include "lib/cmdline/popt_common.h" +#include "torture/torture.h" +#include "librpc/gen_ndr/winreg.h" +#include "system/filesys.h" + +NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix, + const char **tempdir); + +static bool test_del_nonexistant_key(struct torture_context *tctx, + const void *test_data) +{ + const struct hive_key *root = test_data; + WERROR error = hive_key_del(root, "bla"); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + "invalid return code"); + + return true; +} + +static bool test_keyinfo_root(struct torture_context *tctx, + const void *test_data) +{ + uint32_t num_subkeys, num_values; + const struct hive_key *root = test_data; + WERROR error; + + /* This is a new backend. There should be no subkeys and no + * values */ + error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, + NULL); + torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); + + torture_assert_int_equal(tctx, num_subkeys, 0, "New key has non-zero subkey count"); + + torture_assert_werr_ok(tctx, error, "reg_key_num_values"); + + torture_assert_int_equal(tctx, num_values, 0, "New key has non-zero value count"); + + return true; +} + +static bool test_keyinfo_nums(struct torture_context *tctx, + const void *test_data) +{ + uint32_t num_subkeys, num_values; + const struct hive_key *root = test_data; + WERROR error; + struct hive_key *subkey; + uint32_t data = 42; + + error = hive_key_add_name(tctx, root, "Nested Keyll", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_set_value(root, "Answer", REG_DWORD, + data_blob_talloc(tctx, &data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "hive_set_value"); + + /* This is a new backend. There should be no subkeys and no + * values */ + error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, + NULL); + torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); + + torture_assert_int_equal(tctx, num_subkeys, 1, "subkey count"); + + torture_assert_werr_ok(tctx, error, "reg_key_num_values"); + + torture_assert_int_equal(tctx, num_values, 1, "value count"); + + return true; +} + +static bool test_add_subkey(struct torture_context *tctx, + const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + const struct hive_key *root = test_data; + TALLOC_CTX *mem_ctx = tctx; + + error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_key_del(root, "Nested Key"); + torture_assert_werr_ok(tctx, error, "reg_key_del"); + + return true; +} + +static bool test_flush_key(struct torture_context *tctx, + const void *test_data) +{ + const struct hive_key *root = test_data; + + torture_assert_werr_ok(tctx, hive_key_flush(root), "flush key"); + + return true; +} + +static bool test_del_key(struct torture_context *tctx, const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + const struct hive_key *root = test_data; + TALLOC_CTX *mem_ctx = tctx; + + error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_key_del(root, "Nested Key"); + torture_assert_werr_ok(tctx, error, "reg_key_del"); + + error = hive_key_del(root, "Nested Key"); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "reg_key_del"); + + return true; +} + +static bool test_set_value(struct torture_context *tctx, + const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + const struct hive_key *root = test_data; + TALLOC_CTX *mem_ctx = tctx; + uint32_t data = 42; + + error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "hive_set_value"); + + return true; +} + +static bool test_get_value(struct torture_context *tctx, const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + const struct hive_key *root = test_data; + TALLOC_CTX *mem_ctx = tctx; + uint32_t data = 42; + uint32_t type; + DATA_BLOB value; + + error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + "getting missing value"); + + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "hive_set_value"); + + error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); + torture_assert_werr_ok(tctx, error, "getting value"); + + torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); + + torture_assert_int_equal(tctx, value.length, 4, "value length"); + torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); + + return true; +} + +static bool test_del_value(struct torture_context *tctx, const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + const struct hive_key *root = test_data; + TALLOC_CTX *mem_ctx = tctx; + uint32_t data = 42; + uint32_t type; + DATA_BLOB value; + + error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "hive_set_value"); + + error = hive_del_value(subkey, "Answer"); + torture_assert_werr_ok(tctx, error, "deleting value"); + + error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "getting value"); + + error = hive_del_value(subkey, "Answer"); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "deleting value"); + + return true; +} + +static bool test_list_values(struct torture_context *tctx, + const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + const struct hive_key *root = test_data; + TALLOC_CTX *mem_ctx = tctx; + uint32_t data = 42; + uint32_t type; + DATA_BLOB value; + const char *name; + + error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "hive_set_value"); + + error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &value); + torture_assert_werr_ok(tctx, error, "getting value"); + + torture_assert_str_equal(tctx, name, "Answer", "value name"); + torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); + + torture_assert_int_equal(tctx, value.length, 4, "value length"); + torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); + + error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); + torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, + "getting missing value"); + + return true; +} + +static void tcase_add_tests(struct torture_tcase *tcase) +{ + torture_tcase_add_simple_test(tcase, "del_nonexistant_key", + test_del_nonexistant_key); + torture_tcase_add_simple_test(tcase, "add_subkey", test_add_subkey); + torture_tcase_add_simple_test(tcase, "flush_key", test_flush_key); + torture_tcase_add_simple_test(tcase, "get_info", test_keyinfo_root); + torture_tcase_add_simple_test(tcase, "get_info_nums", test_keyinfo_nums); + torture_tcase_add_simple_test(tcase, "set_value", test_set_value); + torture_tcase_add_simple_test(tcase, "get_value", test_get_value); + torture_tcase_add_simple_test(tcase, "list_values", test_list_values); + torture_tcase_add_simple_test(tcase, "del_key", test_del_key); + torture_tcase_add_simple_test(tcase, "del_value", test_del_value); +} + +static bool hive_setup_dir(struct torture_context *tctx, void **data) +{ + struct hive_key *key; + WERROR error; + const char *dirname; + NTSTATUS status; + + status = torture_temp_dir(tctx, "hive-dir", &dirname); + if (!NT_STATUS_IS_OK(status)) + return false; + + rmdir(dirname); + + error = reg_create_directory(tctx, dirname, &key); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to initialize dir hive\n"); + return false; + } + + *data = key; + + return true; +} + +static bool hive_setup_ldb(struct torture_context *tctx, void **data) +{ + struct hive_key *key; + WERROR error; + const char *dirname; + NTSTATUS status; + + status = torture_temp_dir(tctx, "hive-ldb", &dirname); + if (!NT_STATUS_IS_OK(status)) + return false; + + rmdir(dirname); + + error = reg_open_ldb_file(tctx, dirname, NULL, NULL, &key); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to initialize ldb hive\n"); + return false; + } + + *data = key; + + return true; +} + +static bool hive_setup_regf(struct torture_context *tctx, void **data) +{ + struct hive_key *key; + WERROR error; + const char *dirname; + NTSTATUS status; + + status = torture_temp_dir(tctx, "hive-dir", &dirname); + if (!NT_STATUS_IS_OK(status)) + return false; + + rmdir(dirname); + + error = reg_create_regf_file(tctx, dirname, 5, &key); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to create new regf file\n"); + return false; + } + + *data = key; + + return true; +} + +static bool test_dir_refuses_null_location(struct torture_context *tctx) +{ + torture_assert_werr_equal(tctx, WERR_INVALID_PARAM, + reg_open_directory(NULL, NULL, NULL), + "reg_open_directory accepts NULL location"); + return true; +} + +struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx) +{ + struct torture_tcase *tcase; + struct torture_suite *suite = torture_suite_create(mem_ctx, + "HIVE"); + + torture_suite_add_simple_test(suite, "dir-refuses-null-location", + test_dir_refuses_null_location); + + + tcase = torture_suite_add_tcase(suite, "dir"); + torture_tcase_set_fixture(tcase, hive_setup_dir, NULL); + tcase_add_tests(tcase); + + tcase = torture_suite_add_tcase(suite, "ldb"); + torture_tcase_set_fixture(tcase, hive_setup_ldb, NULL); + tcase_add_tests(tcase); + + tcase = torture_suite_add_tcase(suite, "regf"); + torture_tcase_set_fixture(tcase, hive_setup_regf, NULL); + tcase_add_tests(tcase); + + return suite; +} -- cgit From 98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 16:46:30 +0000 Subject: r25035: Fix some more warnings, use service pointer rather than service number in more places. (This used to be commit df9cebcb97e20564359097148665bd519f31bc6f) --- source4/lib/registry/tests/hive.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index a04bc1168e..a71e31474c 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -31,9 +31,9 @@ NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix, const char **tempdir); static bool test_del_nonexistant_key(struct torture_context *tctx, - const void *test_data) + const void *test_data) { - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; WERROR error = hive_key_del(root, "bla"); torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "invalid return code"); @@ -45,7 +45,7 @@ static bool test_keyinfo_root(struct torture_context *tctx, const void *test_data) { uint32_t num_subkeys, num_values; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; WERROR error; /* This is a new backend. There should be no subkeys and no @@ -67,7 +67,7 @@ static bool test_keyinfo_nums(struct torture_context *tctx, const void *test_data) { uint32_t num_subkeys, num_values; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; WERROR error; struct hive_key *subkey; uint32_t data = 42; @@ -100,7 +100,7 @@ static bool test_add_subkey(struct torture_context *tctx, { WERROR error; struct hive_key *subkey; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, @@ -114,9 +114,9 @@ static bool test_add_subkey(struct torture_context *tctx, } static bool test_flush_key(struct torture_context *tctx, - const void *test_data) + const void *test_data) { - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; torture_assert_werr_ok(tctx, hive_key_flush(root), "flush key"); @@ -127,7 +127,7 @@ static bool test_del_key(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, @@ -148,7 +148,7 @@ static bool test_set_value(struct torture_context *tctx, { WERROR error; struct hive_key *subkey; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t data = 42; @@ -167,7 +167,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t data = 42; uint32_t type; @@ -200,7 +200,7 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t data = 42; uint32_t type; @@ -231,7 +231,7 @@ static bool test_list_values(struct torture_context *tctx, { WERROR error; struct hive_key *subkey; - const struct hive_key *root = test_data; + const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t data = 42; uint32_t type; -- cgit From ab309ada8ba2e4ef867f7fdb13012d09cb8d05c9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Sep 2007 07:29:29 +0000 Subject: r25112: make torture_temp_dir() available via tortore/torture.h and return more detailed errors metze (This used to be commit c2b645c8763fd75a0a81983ec44a5990670c4fc4) --- source4/lib/registry/tests/hive.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index a71e31474c..dff6d1e829 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -27,9 +27,6 @@ #include "librpc/gen_ndr/winreg.h" #include "system/filesys.h" -NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix, - const char **tempdir); - static bool test_del_nonexistant_key(struct torture_context *tctx, const void *test_data) { -- cgit From c353a7b05e8475bbc726123ae41c91102d96c6f5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 10 Oct 2007 12:44:48 +0200 Subject: r25605: Last round of registry reformats (before this gets an obsession...). Guenther (This used to be commit ceb2ebfbf1eeb80bd34beadbba3a3c7a04da306a) --- source4/lib/registry/tests/hive.c | 154 ++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 71 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index dff6d1e829..9e76ce6aa1 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -1,20 +1,20 @@ -/* +/* Unix SMB/CIFS implementation. local testing of registry library - hives Copyright (C) Jelmer Vernooij 2005-2007 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -32,36 +32,38 @@ static bool test_del_nonexistant_key(struct torture_context *tctx, { const struct hive_key *root = (const struct hive_key *)test_data; WERROR error = hive_key_del(root, "bla"); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, - "invalid return code"); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + "invalid return code"); return true; } static bool test_keyinfo_root(struct torture_context *tctx, - const void *test_data) + const void *test_data) { uint32_t num_subkeys, num_values; const struct hive_key *root = (const struct hive_key *)test_data; WERROR error; - /* This is a new backend. There should be no subkeys and no + /* This is a new backend. There should be no subkeys and no * values */ - error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, - NULL); + error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, + NULL); torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); - torture_assert_int_equal(tctx, num_subkeys, 0, "New key has non-zero subkey count"); + torture_assert_int_equal(tctx, num_subkeys, 0, + "New key has non-zero subkey count"); torture_assert_werr_ok(tctx, error, "reg_key_num_values"); - torture_assert_int_equal(tctx, num_values, 0, "New key has non-zero value count"); + torture_assert_int_equal(tctx, num_values, 0, + "New key has non-zero value count"); return true; } static bool test_keyinfo_nums(struct torture_context *tctx, - const void *test_data) + const void *test_data) { uint32_t num_subkeys, num_values; const struct hive_key *root = (const struct hive_key *)test_data; @@ -69,18 +71,18 @@ static bool test_keyinfo_nums(struct torture_context *tctx, struct hive_key *subkey; uint32_t data = 42; - error = hive_key_add_name(tctx, root, "Nested Keyll", NULL, - NULL, &subkey); + error = hive_key_add_name(tctx, root, "Nested Keyll", NULL, + NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(root, "Answer", REG_DWORD, - data_blob_talloc(tctx, &data, sizeof(data))); + error = hive_set_value(root, "Answer", REG_DWORD, + data_blob_talloc(tctx, &data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_set_value"); - /* This is a new backend. There should be no subkeys and no + /* This is a new backend. There should be no subkeys and no * values */ - error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, - NULL); + error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, + NULL); torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); torture_assert_int_equal(tctx, num_subkeys, 1, "subkey count"); @@ -93,15 +95,15 @@ static bool test_keyinfo_nums(struct torture_context *tctx, } static bool test_add_subkey(struct torture_context *tctx, - const void *test_data) + const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, - NULL, &subkey); + error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, + NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_del(root, "Nested Key"); @@ -127,8 +129,8 @@ static bool test_del_key(struct torture_context *tctx, const void *test_data) const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, - NULL, &subkey); + error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, + NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_del(root, "Nested Key"); @@ -141,7 +143,7 @@ static bool test_del_key(struct torture_context *tctx, const void *test_data) } static bool test_set_value(struct torture_context *tctx, - const void *test_data) + const void *test_data) { WERROR error; struct hive_key *subkey; @@ -149,12 +151,12 @@ static bool test_set_value(struct torture_context *tctx, TALLOC_CTX *mem_ctx = tctx; uint32_t data = 42; - error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL, - NULL, &subkey); + error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL, + NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_set_value"); return true; @@ -170,16 +172,16 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) uint32_t type; DATA_BLOB value; - error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL, - NULL, &subkey); + error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL, + NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, - "getting missing value"); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + "getting missing value"); - error = hive_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_set_value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); @@ -203,12 +205,12 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) uint32_t type; DATA_BLOB value; - error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL, + error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_set_value"); error = hive_del_value(subkey, "Answer"); @@ -218,13 +220,14 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "getting value"); error = hive_del_value(subkey, "Answer"); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "deleting value"); + torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + "deleting value"); return true; } -static bool test_list_values(struct torture_context *tctx, - const void *test_data) +static bool test_list_values(struct torture_context *tctx, + const void *test_data) { WERROR error; struct hive_key *subkey; @@ -235,15 +238,16 @@ static bool test_list_values(struct torture_context *tctx, DATA_BLOB value; const char *name; - error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, - NULL, &subkey); + error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, + NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + error = hive_set_value(subkey, "Answer", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_set_value"); - error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &value); + error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, + &type, &value); torture_assert_werr_ok(tctx, error, "getting value"); torture_assert_str_equal(tctx, name, "Answer", "value name"); @@ -252,26 +256,36 @@ static bool test_list_values(struct torture_context *tctx, torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); - error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); - torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, - "getting missing value"); + error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, + &type, &value); + torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, + "getting missing value"); return true; } -static void tcase_add_tests(struct torture_tcase *tcase) +static void tcase_add_tests(struct torture_tcase *tcase) { - torture_tcase_add_simple_test(tcase, "del_nonexistant_key", - test_del_nonexistant_key); - torture_tcase_add_simple_test(tcase, "add_subkey", test_add_subkey); - torture_tcase_add_simple_test(tcase, "flush_key", test_flush_key); - torture_tcase_add_simple_test(tcase, "get_info", test_keyinfo_root); - torture_tcase_add_simple_test(tcase, "get_info_nums", test_keyinfo_nums); - torture_tcase_add_simple_test(tcase, "set_value", test_set_value); - torture_tcase_add_simple_test(tcase, "get_value", test_get_value); - torture_tcase_add_simple_test(tcase, "list_values", test_list_values); - torture_tcase_add_simple_test(tcase, "del_key", test_del_key); - torture_tcase_add_simple_test(tcase, "del_value", test_del_value); + torture_tcase_add_simple_test(tcase, "del_nonexistant_key", + test_del_nonexistant_key); + torture_tcase_add_simple_test(tcase, "add_subkey", + test_add_subkey); + torture_tcase_add_simple_test(tcase, "flush_key", + test_flush_key); + torture_tcase_add_simple_test(tcase, "get_info", + test_keyinfo_root); + torture_tcase_add_simple_test(tcase, "get_info_nums", + test_keyinfo_nums); + torture_tcase_add_simple_test(tcase, "set_value", + test_set_value); + torture_tcase_add_simple_test(tcase, "get_value", + test_get_value); + torture_tcase_add_simple_test(tcase, "list_values", + test_list_values); + torture_tcase_add_simple_test(tcase, "del_key", + test_del_key); + torture_tcase_add_simple_test(tcase, "del_value", + test_del_value); } static bool hive_setup_dir(struct torture_context *tctx, void **data) @@ -348,21 +362,19 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data) static bool test_dir_refuses_null_location(struct torture_context *tctx) { - torture_assert_werr_equal(tctx, WERR_INVALID_PARAM, - reg_open_directory(NULL, NULL, NULL), - "reg_open_directory accepts NULL location"); + torture_assert_werr_equal(tctx, WERR_INVALID_PARAM, + reg_open_directory(NULL, NULL, NULL), + "reg_open_directory accepts NULL location"); return true; } -struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx) +struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx) { struct torture_tcase *tcase; - struct torture_suite *suite = torture_suite_create(mem_ctx, - "HIVE"); - - torture_suite_add_simple_test(suite, "dir-refuses-null-location", - test_dir_refuses_null_location); + struct torture_suite *suite = torture_suite_create(mem_ctx, "HIVE"); + torture_suite_add_simple_test(suite, "dir-refuses-null-location", + test_dir_refuses_null_location); tcase = torture_suite_add_tcase(suite, "dir"); torture_tcase_set_fixture(tcase, hive_setup_dir, NULL); -- cgit From 0e3069186186ffed24269968d75c8f007900fd95 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 10 Oct 2007 14:12:25 +0200 Subject: r25613: verify the length and type before checking the value, hopefully gives more info why this fails some bigendian platforms metze (This used to be commit 1d2bc79aa5841bbdbaf003005a161bbf294c7366) --- source4/lib/registry/tests/hive.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 9e76ce6aa1..2ddfe6f036 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -187,10 +187,9 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); torture_assert_werr_ok(tctx, error, "getting value"); - torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); - torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); + torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); return true; } @@ -251,10 +250,10 @@ static bool test_list_values(struct torture_context *tctx, torture_assert_werr_ok(tctx, error, "getting value"); torture_assert_str_equal(tctx, name, "Answer", "value name"); - torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); + torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); -- cgit From d0d0a69d0b2fafafa1ab340c8a352406b07329ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Nov 2007 17:22:12 +0100 Subject: r25932: Remove unnecessary include - should fix the build on hosts without popt. (This used to be commit f250ae0c361aef864f25dfc7599ce1e7a4e29cf8) --- source4/lib/registry/tests/hive.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 2ddfe6f036..2a0f04eb54 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -22,7 +22,6 @@ #include "includes.h" #include "lib/registry/registry.h" -#include "lib/cmdline/popt_common.h" #include "torture/torture.h" #include "librpc/gen_ndr/winreg.h" #include "system/filesys.h" -- cgit From 96a200511e884a88dcf48fa5b313b2cddb2df566 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 00:27:31 +0100 Subject: r26443: Remove global_loadparm instances. (This used to be commit 8242c696235d1bfb402b5c276a57f36d93610545) --- source4/lib/registry/tests/hive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 2a0f04eb54..04a91d42fa 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -323,7 +323,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data) rmdir(dirname); - error = reg_open_ldb_file(tctx, dirname, NULL, NULL, &key); + error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->lp_ctx, &key); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to initialize ldb hive\n"); return false; -- cgit From 45015eda2421253f858f0a4500a57c2855f9686c Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 14 Dec 2007 10:38:26 +0100 Subject: r26451: Janitorial: fix warnings in lib/registry/ This does not fix the discarded qualifier warnings in tests, as the test data is currently passed as const. Jelmer wants to provide a test function that passes non-const test data, thus allowing for a cleaner way to fix those warnings. (This used to be commit 46dfa63d4f7381c5c6ce3f4b8b0bd9aa9e16950c) --- source4/lib/registry/tests/hive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 04a91d42fa..fdb7282395 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -290,7 +290,7 @@ static bool hive_setup_dir(struct torture_context *tctx, void **data) { struct hive_key *key; WERROR error; - const char *dirname; + char *dirname; NTSTATUS status; status = torture_temp_dir(tctx, "hive-dir", &dirname); @@ -314,7 +314,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data) { struct hive_key *key; WERROR error; - const char *dirname; + char *dirname; NTSTATUS status; status = torture_temp_dir(tctx, "hive-ldb", &dirname); @@ -338,7 +338,7 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data) { struct hive_key *key; WERROR error; - const char *dirname; + char *dirname; NTSTATUS status; status = torture_temp_dir(tctx, "hive-dir", &dirname); -- cgit From 09f820f0bd1a9fc7ffd171418ceb0e19df8e2e43 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Dec 2007 05:02:57 -0600 Subject: r26564: More python bindings for registry code. (This used to be commit f40fad9827d0e9567224bc1e64ea91e610a07a3f) --- source4/lib/registry/tests/hive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index fdb7282395..e3a301710f 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -211,13 +211,13 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) data_blob_talloc(mem_ctx, &data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_set_value"); - error = hive_del_value(subkey, "Answer"); + error = hive_key_del_value(subkey, "Answer"); torture_assert_werr_ok(tctx, error, "deleting value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "getting value"); - error = hive_del_value(subkey, "Answer"); + error = hive_key_del_value(subkey, "Answer"); torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "deleting value"); -- cgit From 249cc734cebfef31320ec10b05dbfaaaa39682ca Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Dec 2007 05:03:02 -0600 Subject: r26565: Fix python registry bindings. 'PROVISION_PYTHON=yes make test' works now. (This used to be commit 485d1fa3d17fe6cc7a0ecd80e8bac42d173bbb19) --- source4/lib/registry/tests/hive.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index e3a301710f..43ec9e4252 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -74,9 +74,9 @@ static bool test_keyinfo_nums(struct torture_context *tctx, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(root, "Answer", REG_DWORD, + error = hive_key_set_value(root, "Answer", REG_DWORD, data_blob_talloc(tctx, &data, sizeof(data))); - torture_assert_werr_ok(tctx, error, "hive_set_value"); + torture_assert_werr_ok(tctx, error, "hive_key_set_value"); /* This is a new backend. There should be no subkeys and no * values */ @@ -154,9 +154,9 @@ static bool test_set_value(struct torture_context *tctx, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(subkey, "Answer", REG_DWORD, + error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, &data, sizeof(data))); - torture_assert_werr_ok(tctx, error, "hive_set_value"); + torture_assert_werr_ok(tctx, error, "hive_key_set_value"); return true; } @@ -179,9 +179,9 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "getting missing value"); - error = hive_set_value(subkey, "Answer", REG_DWORD, + error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, &data, sizeof(data))); - torture_assert_werr_ok(tctx, error, "hive_set_value"); + torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); torture_assert_werr_ok(tctx, error, "getting value"); @@ -207,9 +207,9 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(subkey, "Answer", REG_DWORD, + error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, &data, sizeof(data))); - torture_assert_werr_ok(tctx, error, "hive_set_value"); + torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_key_del_value(subkey, "Answer"); torture_assert_werr_ok(tctx, error, "deleting value"); @@ -240,9 +240,9 @@ static bool test_list_values(struct torture_context *tctx, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); - error = hive_set_value(subkey, "Answer", REG_DWORD, + error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, &data, sizeof(data))); - torture_assert_werr_ok(tctx, error, "hive_set_value"); + torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &value); -- cgit From 3c744ddd2c33a9a06013f357261b8ea86804e8e8 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 24 Dec 2007 13:04:56 -0600 Subject: r26588: Janitorial: Rename torture_*_add_*test to torture_*_add_*test_const. Also rename the corresponding wrap_ functions. (This used to be commit e59c2eaf681f076d175b9779d1c27b5f74a57c96) --- source4/lib/registry/tests/hive.c | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 43ec9e4252..dc59d0f9ca 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -264,26 +264,26 @@ static bool test_list_values(struct torture_context *tctx, static void tcase_add_tests(struct torture_tcase *tcase) { - torture_tcase_add_simple_test(tcase, "del_nonexistant_key", - test_del_nonexistant_key); - torture_tcase_add_simple_test(tcase, "add_subkey", - test_add_subkey); - torture_tcase_add_simple_test(tcase, "flush_key", - test_flush_key); - torture_tcase_add_simple_test(tcase, "get_info", - test_keyinfo_root); - torture_tcase_add_simple_test(tcase, "get_info_nums", - test_keyinfo_nums); - torture_tcase_add_simple_test(tcase, "set_value", - test_set_value); - torture_tcase_add_simple_test(tcase, "get_value", - test_get_value); - torture_tcase_add_simple_test(tcase, "list_values", - test_list_values); - torture_tcase_add_simple_test(tcase, "del_key", - test_del_key); - torture_tcase_add_simple_test(tcase, "del_value", - test_del_value); + torture_tcase_add_simple_test_const(tcase, "del_nonexistant_key", + test_del_nonexistant_key); + torture_tcase_add_simple_test_const(tcase, "add_subkey", + test_add_subkey); + torture_tcase_add_simple_test_const(tcase, "flush_key", + test_flush_key); + torture_tcase_add_simple_test_const(tcase, "get_info", + test_keyinfo_root); + torture_tcase_add_simple_test_const(tcase, "get_info_nums", + test_keyinfo_nums); + torture_tcase_add_simple_test_const(tcase, "set_value", + test_set_value); + torture_tcase_add_simple_test_const(tcase, "get_value", + test_get_value); + torture_tcase_add_simple_test_const(tcase, "list_values", + test_list_values); + torture_tcase_add_simple_test_const(tcase, "del_key", + test_del_key); + torture_tcase_add_simple_test_const(tcase, "del_value", + test_del_value); } static bool hive_setup_dir(struct torture_context *tctx, void **data) -- cgit From a6caca9abcf4de57901ba8ecc610cf8c13cd2821 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 24 Dec 2007 13:06:57 -0600 Subject: r26589: torture: Add non-const version of torture_tcase_add_simple_test (This used to be commit 1ae9cde5105cc4349a44e6098e9393e06acaf95d) --- source4/lib/registry/tests/hive.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index dc59d0f9ca..bc3c82552e 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -61,11 +61,10 @@ static bool test_keyinfo_root(struct torture_context *tctx, return true; } -static bool test_keyinfo_nums(struct torture_context *tctx, - const void *test_data) +static bool test_keyinfo_nums(struct torture_context *tctx, void *test_data) { uint32_t num_subkeys, num_values; - const struct hive_key *root = (const struct hive_key *)test_data; + struct hive_key *root = (struct hive_key *)test_data; WERROR error; struct hive_key *subkey; uint32_t data = 42; @@ -111,10 +110,9 @@ static bool test_add_subkey(struct torture_context *tctx, return true; } -static bool test_flush_key(struct torture_context *tctx, - const void *test_data) +static bool test_flush_key(struct torture_context *tctx, void *test_data) { - const struct hive_key *root = (const struct hive_key *)test_data; + struct hive_key *root = (struct hive_key *)test_data; torture_assert_werr_ok(tctx, hive_key_flush(root), "flush key"); @@ -268,11 +266,11 @@ static void tcase_add_tests(struct torture_tcase *tcase) test_del_nonexistant_key); torture_tcase_add_simple_test_const(tcase, "add_subkey", test_add_subkey); - torture_tcase_add_simple_test_const(tcase, "flush_key", + torture_tcase_add_simple_test(tcase, "flush_key", test_flush_key); torture_tcase_add_simple_test_const(tcase, "get_info", test_keyinfo_root); - torture_tcase_add_simple_test_const(tcase, "get_info_nums", + torture_tcase_add_simple_test(tcase, "get_info_nums", test_keyinfo_nums); torture_tcase_add_simple_test_const(tcase, "set_value", test_set_value); -- cgit From df70180c0ff55a526cec997b6a9fc550cf2719d6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 Jan 2008 13:59:53 -0600 Subject: r26665: registry: Fix tests on bigendian machines. (This used to be commit bcd8f50f7952d1e502326f11ddfa8cfe8a982b1b) --- source4/lib/registry/tests/hive.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index bc3c82552e..36eea84d94 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -186,7 +186,9 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); - torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); + + torture_assert_int_equal(tctx, data, IVAL(value.data, 0), + "value data"); return true; } @@ -250,7 +252,9 @@ static bool test_list_values(struct torture_context *tctx, torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); - torture_assert(tctx, memcmp(value.data, &data, 4) == 0, "value data"); + + + torture_assert_int_equal(tctx, data, IVAL(value.data, 0), "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); -- cgit From 47f6bbf8cf5bdd03c72c59d00e3e1eab8895590e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 7 Jan 2008 14:11:29 -0600 Subject: r26689: registry: Return max_subkeynamelen, max_valnamelen and max_valbufsize in getkeyinfo(). (This used to be commit b06896d2378e536f5044dbe500a5232a89d6d0b5) --- source4/lib/registry/tests/hive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 36eea84d94..22b4785222 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -47,7 +47,7 @@ static bool test_keyinfo_root(struct torture_context *tctx, /* This is a new backend. There should be no subkeys and no * values */ error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, - NULL); + NULL, NULL, NULL, NULL); torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); torture_assert_int_equal(tctx, num_subkeys, 0, @@ -80,7 +80,7 @@ static bool test_keyinfo_nums(struct torture_context *tctx, void *test_data) /* This is a new backend. There should be no subkeys and no * values */ error = hive_key_get_info(tctx, root, NULL, &num_subkeys, &num_values, - NULL); + NULL, NULL, NULL, NULL); torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); torture_assert_int_equal(tctx, num_subkeys, 1, "subkey count"); -- cgit From 85d60d2d091a2eb6bd4c73c87c94b10ee93167ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 18 Jan 2008 02:45:00 +0100 Subject: registry: Improve error codes and update tests. Rather than map the error returned by the registry to the correct error, return the correct error in the first place. Also deal with the fact that the right error code is now returned in a couple of places. (This used to be commit 1e31fcb8a097810a97e2d4bb1f243f1b34cc2415) --- source4/lib/registry/tests/hive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 22b4785222..f72b7d6bf3 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -174,7 +174,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting missing value"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, @@ -215,7 +215,7 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) torture_assert_werr_ok(tctx, error, "deleting value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "getting value"); + torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting value"); error = hive_key_del_value(subkey, "Answer"); torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, -- cgit From 55ad09a01b31f2d2c9503f744b519e089f9f936b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 18 Jan 2008 03:37:06 +0100 Subject: registry: Use correct return values. (This used to be commit 98ebdbe52fd615ea62a3caa17acfe8bb31b8f85d) --- source4/lib/registry/tests/hive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index f72b7d6bf3..4d27e83a74 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -31,7 +31,7 @@ static bool test_del_nonexistant_key(struct torture_context *tctx, { const struct hive_key *root = (const struct hive_key *)test_data; WERROR error = hive_key_del(root, "bla"); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + torture_assert_werr_equal(tctx, error, WERR_BADFILE, "invalid return code"); return true; @@ -134,7 +134,7 @@ static bool test_del_key(struct torture_context *tctx, const void *test_data) torture_assert_werr_ok(tctx, error, "reg_key_del"); error = hive_key_del(root, "Nested Key"); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "reg_key_del"); + torture_assert_werr_equal(tctx, error, WERR_BADFILE, "reg_key_del"); return true; } @@ -218,7 +218,7 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting value"); error = hive_key_del_value(subkey, "Answer"); - torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, + torture_assert_werr_equal(tctx, error, WERR_BADFILE, "deleting value"); return true; -- cgit From c38c2765d1059b33f044a42c6555f3d10d339911 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 17:17:37 +0100 Subject: Remove yet more uses of global_loadparm. (This used to be commit e01c1e87c0fe9709df7eb5b863f7ce85564174cd) --- source4/lib/registry/tests/hive.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 4d27e83a74..1dcb464d80 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -25,6 +25,7 @@ #include "torture/torture.h" #include "librpc/gen_ndr/winreg.h" #include "system/filesys.h" +#include "param/param.h" static bool test_del_nonexistant_key(struct torture_context *tctx, const void *test_data) @@ -349,7 +350,8 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data) rmdir(dirname); - error = reg_create_regf_file(tctx, dirname, 5, &key); + error = reg_create_regf_file(tctx, lp_iconv_convenience(tctx->lp_ctx), + dirname, 5, &key); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to create new regf file\n"); return false; -- cgit From a13395c8731db614e543e60d3da67873c3164ea2 Mon Sep 17 00:00:00 2001 From: Andrew Kroeger Date: Sat, 16 Feb 2008 15:21:26 -0600 Subject: registry: Add an explicit test for recursive deletion. (This used to be commit 5e905804993df4c2ac28090d056e6db6bb63ac44) --- source4/lib/registry/tests/hive.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 4d27e83a74..915782694f 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -110,6 +110,38 @@ static bool test_add_subkey(struct torture_context *tctx, return true; } +static bool test_del_recursive(struct torture_context *tctx, + const void *test_data) +{ + WERROR error; + struct hive_key *subkey; + struct hive_key *subkey2; + const struct hive_key *root = (const struct hive_key *)test_data; + TALLOC_CTX *mem_ctx = tctx; + uint32_t data = 42; + + /* Create a new key under the root */ + error = hive_key_add_name(mem_ctx, root, "Parent Key", NULL, + NULL, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + /* Create a new key under "Parent Key" */ + error = hive_key_add_name(mem_ctx, subkey, "Child Key", NULL, + NULL, &subkey2); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + /* Create a new value under "Child Key" */ + error = hive_key_set_value(subkey2, "Answer Recursive", REG_DWORD, + data_blob_talloc(mem_ctx, &data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "hive_key_set_value"); + + /* Deleting "Parent Key" will also delete "Child Key" and the value. */ + error = hive_key_del(root, "Parent Key"); + torture_assert_werr_ok(tctx, error, "hive_key_del"); + + return true; +} + static bool test_flush_key(struct torture_context *tctx, void *test_data) { struct hive_key *root = (struct hive_key *)test_data; @@ -272,6 +304,11 @@ static void tcase_add_tests(struct torture_tcase *tcase) test_add_subkey); torture_tcase_add_simple_test(tcase, "flush_key", test_flush_key); + /* test_del_recursive() test must run before test_keyinfo_root(). + test_keyinfo_root() checks the number of subkeys, which verifies + the recursive delete worked properly. */ + torture_tcase_add_simple_test_const(tcase, "del_recursive", + test_del_recursive); torture_tcase_add_simple_test_const(tcase, "get_info", test_keyinfo_root); torture_tcase_add_simple_test(tcase, "get_info_nums", -- cgit From 8f8c56bfbcbfe8f80afb09eb1d481a108b252bee Mon Sep 17 00:00:00 2001 From: Andrew Kroeger Date: Fri, 28 Mar 2008 01:08:49 -0500 Subject: Convert some more files to GPLv3. (This used to be commit ebe5e8399422eb7e2ff4deb546338823e2718907) --- source4/lib/registry/tests/hive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 1e56f125c5..70b0241b04 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 225a65da2d3c675dba8bd2330dd56f949e21fa4b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Apr 2008 21:31:06 +0200 Subject: Attempt to fix get_value() test on sparc machines. (This used to be commit 10102d80d0f78777a69f6b3b1e5606d7d56b7254) --- source4/lib/registry/tests/hive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 70b0241b04..a16736c761 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -220,7 +220,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); - torture_assert_int_equal(tctx, data, IVAL(value.data, 0), + torture_assert_mem_equal(tctx, &data, value.data, sizeof(uint32_t), "value data"); return true; -- cgit From 12147fca2b3acd37eb20db82996714320cd4e9b2 Mon Sep 17 00:00:00 2001 From: Wilco Baan Hofman Date: Mon, 14 Apr 2008 22:52:51 +0200 Subject: Add support for security descriptors. Also patched the regf backend to support this. Did not touch the ldb, dir and rpc backends yet. (This used to be commit c4626f21a898da27a051f2c67f8fd73f55d4fc7d) --- source4/lib/registry/tests/hive.c | 56 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index a16736c761..4fe7f66c03 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -26,6 +26,7 @@ #include "librpc/gen_ndr/winreg.h" #include "system/filesys.h" #include "param/param.h" +#include "libcli/security/security.h" static bool test_del_nonexistant_key(struct torture_context *tctx, const void *test_data) @@ -297,6 +298,57 @@ static bool test_list_values(struct torture_context *tctx, return true; } +static bool test_hive_security(struct torture_context *tctx, const void *_data) +{ + struct hive_key *subkey = NULL; + const struct hive_key *root = _data; + WERROR error; + struct security_descriptor *osd, *nsd; + + osd = security_descriptor_dacl_create(tctx, + 0, + NULL, NULL, + SID_NT_AUTHENTICATED_USERS, + SEC_ACE_TYPE_ACCESS_ALLOWED, + SEC_GENERIC_ALL, + SEC_ACE_FLAG_OBJECT_INHERIT, + NULL); + + + error = hive_key_add_name(tctx, root, "SecurityKey", NULL, + osd, &subkey); + torture_assert_werr_ok(tctx, error, "hive_key_add_name"); + + error = hive_get_sec_desc(tctx, subkey, &nsd); + torture_assert_werr_ok (tctx, error, "getting security descriptor"); + + torture_assert(tctx, security_descriptor_equal(osd, nsd), + "security descriptor changed!"); + + /* Create a fresh security descriptor */ + talloc_free(osd); + osd = security_descriptor_dacl_create(tctx, + 0, + NULL, NULL, + SID_NT_AUTHENTICATED_USERS, + SEC_ACE_TYPE_ACCESS_ALLOWED, + SEC_GENERIC_ALL, + SEC_ACE_FLAG_OBJECT_INHERIT, + NULL); + + error = hive_set_sec_desc(subkey, osd); + torture_assert_werr_ok(tctx, error, "setting security descriptor"); + + printf("The second one is done.\n"); + error = hive_get_sec_desc(tctx, subkey, &nsd); + torture_assert_werr_ok (tctx, error, "getting security descriptor"); + + torture_assert(tctx, security_descriptor_equal(osd, nsd), + "security descriptor changed!"); + + return true; +} + static void tcase_add_tests(struct torture_tcase *tcase) { torture_tcase_add_simple_test_const(tcase, "del_nonexistant_key", @@ -324,6 +376,8 @@ static void tcase_add_tests(struct torture_tcase *tcase) test_del_key); torture_tcase_add_simple_test_const(tcase, "del_value", test_del_value); + torture_tcase_add_simple_test_const(tcase, "check hive security", + test_hive_security); } static bool hive_setup_dir(struct torture_context *tctx, void **data) @@ -381,7 +435,7 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data) char *dirname; NTSTATUS status; - status = torture_temp_dir(tctx, "hive-dir", &dirname); + status = torture_temp_dir(tctx, "hive-regf", &dirname); if (!NT_STATUS_IS_OK(status)) return false; -- cgit From a31b6607f22f6b3e1b354db2f9f611b299a2f7ae Mon Sep 17 00:00:00 2001 From: Wilco Baan Hofman Date: Mon, 14 Apr 2008 22:56:14 +0200 Subject: Remove debug stuff. (This used to be commit 7ba2e5dc5b6d82457c298f7ecdb6baea43f04854) --- source4/lib/registry/tests/hive.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 4fe7f66c03..474704b517 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -339,7 +339,6 @@ static bool test_hive_security(struct torture_context *tctx, const void *_data) error = hive_set_sec_desc(subkey, osd); torture_assert_werr_ok(tctx, error, "setting security descriptor"); - printf("The second one is done.\n"); error = hive_get_sec_desc(tctx, subkey, &nsd); torture_assert_werr_ok (tctx, error, "getting security descriptor"); -- cgit From 21fc7673780aa1d7c0caab7b17ff9171238913ba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 12:23:44 +0200 Subject: Specify event_context to ldb_wrap_connect explicitly. (This used to be commit b4e1ae07a284c044704322446c94351c2decff91) --- source4/lib/registry/tests/hive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index a16736c761..83abdd793d 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -363,7 +363,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data) rmdir(dirname); - error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->lp_ctx, &key); + error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->ev, tctx->lp_ctx, &key); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to initialize ldb hive\n"); return false; -- cgit From e739fe91cfdbb7c8a792c4bdc6c5f18603507fc6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 17 Apr 2008 15:54:22 +0200 Subject: Fix bug in registry test on big-endian machines. Andrew Bartlett (This used to be commit c74c67c38383b43efd707934e8c457b757e49db1) --- source4/lib/registry/tests/hive.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'source4/lib/registry/tests/hive.c') diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 83abdd793d..29f7e685c1 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -68,14 +68,15 @@ static bool test_keyinfo_nums(struct torture_context *tctx, void *test_data) struct hive_key *root = (struct hive_key *)test_data; WERROR error; struct hive_key *subkey; - uint32_t data = 42; + char data[4]; + SIVAL(data, 0, 42); error = hive_key_add_name(tctx, root, "Nested Keyll", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(root, "Answer", REG_DWORD, - data_blob_talloc(tctx, &data, sizeof(data))); + data_blob_talloc(tctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); /* This is a new backend. There should be no subkeys and no @@ -119,7 +120,8 @@ static bool test_del_recursive(struct torture_context *tctx, struct hive_key *subkey2; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - uint32_t data = 42; + char data[4]; + SIVAL(data, 0, 42); /* Create a new key under the root */ error = hive_key_add_name(mem_ctx, root, "Parent Key", NULL, @@ -133,7 +135,7 @@ static bool test_del_recursive(struct torture_context *tctx, /* Create a new value under "Child Key" */ error = hive_key_set_value(subkey2, "Answer Recursive", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); /* Deleting "Parent Key" will also delete "Child Key" and the value. */ @@ -179,14 +181,15 @@ static bool test_set_value(struct torture_context *tctx, struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - uint32_t data = 42; + char data[4]; + SIVAL(data, 0, 42); error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); return true; @@ -198,10 +201,12 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - uint32_t data = 42; + char data[4]; uint32_t type; DATA_BLOB value; + SIVAL(data, 0, 42); + error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); @@ -211,7 +216,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data) "getting missing value"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); @@ -232,16 +237,18 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data) struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - uint32_t data = 42; + char data[4]; uint32_t type; DATA_BLOB value; + SIVAL(data, 0, 42); + error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_key_del_value(subkey, "Answer"); @@ -264,17 +271,19 @@ static bool test_list_values(struct torture_context *tctx, struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; - uint32_t data = 42; + char data[4]; uint32_t type; DATA_BLOB value; const char *name; + int data_val = 42; + SIVAL(data, 0, data_val); error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, - data_blob_talloc(mem_ctx, &data, sizeof(data))); + data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, @@ -287,7 +296,7 @@ static bool test_list_values(struct torture_context *tctx, torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); - torture_assert_int_equal(tctx, data, IVAL(value.data, 0), "value data"); + torture_assert_int_equal(tctx, data_val, IVAL(value.data, 0), "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); -- cgit