Example #1
0
File: hive.c Project: Arkhont/samba
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;
	uint8_t d[] = { 0x42, 0x00, 0x00, 0x00 };
	DATA_BLOB db = { d, 4 };

	/* 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, db);
	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(mem_ctx, root, "Parent Key");
	torture_assert_werr_ok(tctx, error, "hive_key_del");

	return true;
}
Example #2
0
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;
	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,
				  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;
}
Example #3
0
File: hive.c Project: Arkhont/samba
static bool test_del_nonexistant_key(struct torture_context *tctx,
				     const void *test_data)
{
	const struct hive_key *root = (const struct hive_key *)test_data;
	WERROR error = hive_key_del(tctx, root, "bla");
	torture_assert_werr_equal(tctx, error, WERR_BADFILE,
				  "invalid return code");

	return true;
}
Example #4
0
File: hive.c Project: Arkhont/samba
static bool test_del_key(struct torture_context *tctx, 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);
	torture_assert_werr_ok(tctx, error, "hive_key_add_name");

	error = hive_key_del(mem_ctx, root, "Nested Key");
	torture_assert_werr_ok(tctx, error, "reg_key_del");

	error = hive_key_del(mem_ctx, root, "Nested Key");
	torture_assert_werr_equal(tctx, error, WERR_BADFILE, "reg_key_del");

	return true;
}