From 1dbffa70ae42dc254abbea0b7a958044a621996d Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Thu, 27 Oct 2011 09:54:06 +0200 Subject: s4:lib/registry - enhance registry tests in respect to default values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jelmer Autobuild-User: Matthias Dieter Wallnöfer Autobuild-Date: Thu Nov 3 21:41:17 CET 2011 on sn-devel-104 --- source4/lib/registry/tests/registry.c | 55 ++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry') diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c index 7179c72e46..4e6dda448e 100644 --- a/source4/lib/registry/tests/registry.c +++ b/source4/lib/registry/tests/registry.c @@ -255,8 +255,9 @@ static bool test_query_key(struct torture_context *tctx, void *_data) NTTIME last_changed_time; uint32_t num_subkeys, num_values; const char *classname; + const char *data = "temp"; - if (!create_test_key(tctx, rctx, "Munchen", &root, &subkey)) + if (!create_test_key(tctx, rctx, "Muenchen", &root, &subkey)) return false; error = reg_key_get_info(tctx, subkey, &classname, @@ -268,6 +269,19 @@ static bool test_query_key(struct torture_context *tctx, void *_data) torture_assert_int_equal(tctx, num_subkeys, 0, "num subkeys"); torture_assert_int_equal(tctx, num_values, 0, "num values"); + error = reg_val_set(subkey, "", REG_SZ, + data_blob_talloc(tctx, data, sizeof(data))); + torture_assert_werr_ok(tctx, error, "set default value"); + + error = reg_key_get_info(tctx, subkey, &classname, + &num_subkeys, &num_values, + &last_changed_time, NULL, NULL, NULL); + + torture_assert_werr_ok(tctx, error, "get info key"); + torture_assert(tctx, classname == NULL, "classname"); + torture_assert_int_equal(tctx, num_subkeys, 0, "num subkeys"); + torture_assert_int_equal(tctx, num_values, 1, "num values"); + return true; } @@ -409,6 +423,8 @@ static bool test_get_value(struct torture_context *tctx, void *_data) DATA_BLOB data; char value[4]; uint32_t type; + const char *data_val = "temp"; + SIVAL(value, 0, 42); if (!create_test_key(tctx, rctx, "Duisburg", &root, &subkey)) @@ -432,6 +448,17 @@ static bool test_get_value(struct torture_context *tctx, void *_data) "value content ok"); torture_assert_int_equal(tctx, REG_DWORD, type, "value type"); + error = reg_val_set(subkey, "", REG_SZ, + data_blob_talloc(tctx, data_val, sizeof(data_val))); + torture_assert_werr_ok(tctx, error, "set default value"); + + error = reg_key_get_value_by_name(tctx, subkey, "", &type, + &data); + torture_assert_werr_ok(tctx, error, "getting default value"); + torture_assert_int_equal(tctx, REG_SZ, type, "value type ok"); + torture_assert_int_equal(tctx, sizeof(data_val), data.length, "value length ok"); + torture_assert_str_equal(tctx, data_val, (char *)data.data, "value ok"); + return true; } @@ -446,6 +473,8 @@ static bool test_del_value(struct torture_context *tctx, void *_data) DATA_BLOB data; uint32_t type; char value[4]; + const char *data_val = "temp"; + SIVAL(value, 0, 42); if (!create_test_key(tctx, rctx, "Warschau", &root, &subkey)) @@ -468,6 +497,17 @@ static bool test_del_value(struct torture_context *tctx, void *_data) torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting missing value"); + error = reg_del_value(tctx, subkey, ""); + torture_assert_werr_equal(tctx, error, WERR_BADFILE, + "unsetting missing default value"); + + error = reg_val_set(subkey, "", REG_SZ, + data_blob_talloc(tctx, data_val, sizeof(data_val))); + torture_assert_werr_ok(tctx, error, "set default value"); + + error = reg_del_value(tctx, subkey, ""); + torture_assert_werr_ok (tctx, error, "unsetting default value"); + return true; } @@ -483,6 +523,8 @@ static bool test_list_values(struct torture_context *tctx, void *_data) uint32_t type; const char *name; char value[4]; + const char *data_val = "temp"; + SIVAL(value, 0, 42); if (!create_test_key(tctx, rctx, "Bonn", &root, &subkey)) @@ -507,6 +549,17 @@ static bool test_list_values(struct torture_context *tctx, void *_data) torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, "getting missing value"); + error = reg_val_set(subkey, "", REG_SZ, + data_blob_talloc(tctx, data_val, sizeof(data_val))); + torture_assert_werr_ok(tctx, error, "set default value"); + + error = reg_key_get_value_by_index(tctx, subkey, 0, &name, + &type, &data); + torture_assert_werr_ok(tctx, error, "getting default value"); + torture_assert_int_equal(tctx, REG_SZ, type, "value type ok"); + torture_assert_int_equal(tctx, sizeof(data_val), data.length, "value length ok"); + torture_assert_str_equal(tctx, data_val, (char *)data.data, "value ok"); + return true; } -- cgit