summaryrefslogtreecommitdiff
path: root/source4/lib/registry/tests/registry.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/registry/tests/registry.c')
-rw-r--r--source4/lib/registry/tests/registry.c96
1 files changed, 49 insertions, 47 deletions
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index fd2e98eac8..962c7fd2b5 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -28,16 +28,14 @@
#include "libcli/security/security.h"
#include "system/filesys.h"
-NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix,
- const char **tempdir);
-
/**
* Test obtaining a predefined key.
*/
static bool test_get_predefined(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -66,7 +64,8 @@ static bool test_get_predefined_unknown(struct torture_context *tctx,
static bool test_predef_key_by_name(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -84,7 +83,8 @@ static bool test_predef_key_by_name(struct torture_context *tctx,
static bool test_predef_key_by_name_invalid(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -100,7 +100,8 @@ static bool test_predef_key_by_name_invalid(struct torture_context *tctx,
static bool test_create_subkey(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *newkey;
WERROR error;
@@ -121,7 +122,8 @@ static bool test_create_subkey(struct torture_context *tctx,
static bool test_create_nested_subkey(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *newkey1, *newkey2;
WERROR error;
@@ -132,7 +134,7 @@ static bool test_create_nested_subkey(struct torture_context *tctx,
error = reg_key_add_name(rctx, root, "Hamburg", NULL, NULL,
&newkey1);
torture_assert_werr_ok(tctx, error, "Creating key return code");
- torture_assert(tctx, newkey2 != NULL, "Creating new key");
+ torture_assert(tctx, newkey1 != NULL, "Creating new key");
error = reg_key_add_name(rctx, root, "Hamburg\\Hamburg", NULL, NULL,
&newkey2);
@@ -148,7 +150,8 @@ static bool test_create_nested_subkey(struct torture_context *tctx,
static bool test_key_add_abs_top(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -165,7 +168,8 @@ static bool test_key_add_abs(struct torture_context *tctx,
const void *_data)
{
WERROR error;
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *result1, *result2;
error = reg_key_add_abs(tctx, rctx, "HKEY_CLASSES_ROOT\\bloe", 0, NULL, &result1);
@@ -190,7 +194,8 @@ static bool test_key_add_abs(struct torture_context *tctx,
static bool test_del_key(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *newkey;
WERROR error;
@@ -238,7 +243,8 @@ static bool create_test_key(struct torture_context *tctx,
static bool test_flush_key(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *subkey;
WERROR error;
@@ -256,7 +262,8 @@ static bool test_flush_key(struct torture_context *tctx, const void *_data)
static bool test_query_key(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *subkey;
WERROR error;
NTTIME last_changed_time;
@@ -280,7 +287,8 @@ static bool test_query_key(struct torture_context *tctx, const void *_data)
static bool test_query_key_nums(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *subkey1, *subkey2;
WERROR error;
uint32_t num_subkeys, num_values;
@@ -313,7 +321,8 @@ static bool test_query_key_nums(struct torture_context *tctx, const void *_data)
*/
static bool test_list_subkeys(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
NTTIME last_mod_time;
@@ -351,7 +360,8 @@ static bool test_list_subkeys(struct torture_context *tctx, const void *_data)
*/
static bool test_set_value(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
uint32_t data = 42;
@@ -371,10 +381,10 @@ static bool test_set_value(struct torture_context *tctx, const void *_data)
*/
static bool test_security(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
- uint32_t data = 42;
struct security_descriptor *osd, *nsd;
if (!create_test_key(tctx, rctx, "Düsseldorf", &root, &subkey))
@@ -405,7 +415,8 @@ static bool test_security(struct torture_context *tctx, const void *_data)
*/
static bool test_get_value(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
@@ -440,7 +451,8 @@ static bool test_get_value(struct torture_context *tctx, const void *_data)
*/
static bool test_del_value(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
@@ -474,7 +486,8 @@ static bool test_del_value(struct torture_context *tctx, const void *_data)
*/
static bool test_list_values(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
@@ -511,26 +524,20 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
const char *tempdir;
NTSTATUS status;
struct hive_key *hive_key;
+ const char *filename;
error = reg_open_local(tctx, &rctx, NULL, NULL);
- if (!W_ERROR_IS_OK(error))
- return false;
+ torture_assert_werr_ok(tctx, error, "Opening local registry failed");
status = torture_temp_dir(tctx, "registry-local", &tempdir);
- if (!NT_STATUS_IS_OK(status))
- return false;
+ torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
- error = reg_open_ldb_file(tctx,
- talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir),
- NULL,
- NULL,
- &hive_key);
- if (!W_ERROR_IS_OK(error))
- return false;
+ filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, &hive_key);
+ torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
- if (!W_ERROR_IS_OK(error))
- return false;
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
*data = rctx;
@@ -540,13 +547,10 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
static void tcase_add_tests(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test(tcase, "list_subkeys", test_list_subkeys);
- torture_tcase_add_simple_test(tcase, "get_predefined_key",
- test_get_predefined);
- torture_tcase_add_simple_test(tcase, "get_predefined_key",
- test_get_predefined_unknown);
+ torture_tcase_add_simple_test(tcase, "get_predefined_key", test_get_predefined);
+ torture_tcase_add_simple_test(tcase, "get_predefined_key", test_get_predefined_unknown);
torture_tcase_add_simple_test(tcase, "create_key", test_create_subkey);
- torture_tcase_add_simple_test(tcase, "create_key",
- test_create_nested_subkey);
+ torture_tcase_add_simple_test(tcase, "create_key", test_create_nested_subkey);
torture_tcase_add_simple_test(tcase, "key_add_abs", test_key_add_abs);
torture_tcase_add_simple_test(tcase, "key_add_abs_top", test_key_add_abs_top);
torture_tcase_add_simple_test(tcase, "set_value", test_set_value);
@@ -558,18 +562,16 @@ static void tcase_add_tests(struct torture_tcase *tcase)
torture_tcase_add_simple_test(tcase, "query_key", test_query_key);
torture_tcase_add_simple_test(tcase, "query_key_nums", test_query_key_nums);
torture_tcase_add_simple_test(tcase, "test_predef_key_by_name",
- test_predef_key_by_name);
- torture_tcase_add_simple_test(tcase, "security",
- test_security);
+ test_predef_key_by_name);
+ torture_tcase_add_simple_test(tcase, "security", test_security);
torture_tcase_add_simple_test(tcase, "test_predef_key_by_name_invalid",
- test_predef_key_by_name_invalid);
+ test_predef_key_by_name_invalid);
}
struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx)
{
struct torture_tcase *tcase;
- struct torture_suite *suite = torture_suite_create(mem_ctx,
- "REGISTRY");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "REGISTRY");
tcase = torture_suite_add_tcase(suite, "local");
torture_tcase_set_fixture(tcase, setup_local_registry, NULL);