summaryrefslogtreecommitdiffstats
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2011-10-27 09:54:06 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2011-11-03 21:41:17 +0100
commit1dbffa70ae42dc254abbea0b7a958044a621996d (patch)
treebb4e8d10b46417efc25ce5231b8e99fff8e973a0 /source4/lib/registry
parent7e0bef604af0abeedd46f3ae42bd3002f18556f5 (diff)
downloadsamba-1dbffa70ae42dc254abbea0b7a958044a621996d.tar.gz
samba-1dbffa70ae42dc254abbea0b7a958044a621996d.tar.xz
samba-1dbffa70ae42dc254abbea0b7a958044a621996d.zip
s4:lib/registry - enhance registry tests in respect to default values
Reviewed-by: Jelmer Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date: Thu Nov 3 21:41:17 CET 2011 on sn-devel-104
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/tests/registry.c55
1 files changed, 54 insertions, 1 deletions
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;
}