svn commit: samba r21347 - in branches/SAMBA_4_0: . source/librpc/idl source/torture source/torture/ndr

jelmer at samba.org jelmer at samba.org
Wed Feb 14 19:30:10 GMT 2007


Author: jelmer
Date: 2007-02-14 19:30:05 +0000 (Wed, 14 Feb 2007)
New Revision: 21347

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21347

Log:
All current tests in the testsuite mainly test the RPC code in general. Since 
we're running the testsuite mainly against ourselves, we only check that the 
push/pull functions work in our own environment, not whether they generate/parse
the same data that other systems do.

This commit adds the infrastructure for a testsuite for just the marshalling 
code. The idea is that you provide a data blob, a function name and a function 
to check the resulting struct for correctness.

Added:
   branches/SAMBA_4_0/source/torture/ndr/
   branches/SAMBA_4_0/source/torture/ndr/ndr.c
   branches/SAMBA_4_0/source/torture/ndr/ndr.h
   branches/SAMBA_4_0/source/torture/ndr/winreg.c
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/librpc/idl/winreg.idl
   branches/SAMBA_4_0/source/torture/config.mk


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:merge
   - jelmer at samba.org-20060824212938-5923465160f6ab63
jelmer at samba.org-20060830112659-186f132eebc987cc
jelmer at samba.org-20060904121718-63b73248146c14f8
jelmer at samba.org-20060904124721-5e70ab0bd405f748
metze at samba.org-20061010151401-45a5a2ed52cfe172
jelmer at samba.org-20061016130323-400ce51ee51ab30e
jelmer at samba.org-20061016195822-c7783d3ea1a56a53
jelmer at samba.org-20061016230421-75bca2ad62945ede
jelmer at samba.org-20061017145110-8c83a3dd979f6a6a
jelmer at samba.org-20061029173623-eb0459f1d3eb5720
jelmer at samba.org-20070115022006-h5ef1deqflt940b6
jelmer at samba.org-20070116142934-hv99dpwbnq2znh8f
jelmer at samba.org-20070116144126-70rip3bppmvgs3t6
jelmer at samba.org-20070116151516-imvui4r33cj850j9
jelmer at samba.org-20070116154739-3tji4fft7964qgrj
jelmer at samba.org-20070116173900-iasa25stcfty6pbr
jelmer at samba.org-20070117144550-te3o0iy10y14iyo4
jelmer at samba.org-20070122000024-q911packyrjk69ud
jelmer at samba.org-20070122181120-3n8ah238pjbzylyo
jelmer at samba.org-20070122182054-6b26fqrdqyjhyeuc
jelmer at samba.org-20070122233549-k085tfo2o1eqz7mm
jelmer at samba.org-20070123002251-0smz35eva10x84tc
jelmer at samba.org-20070123003546-p0jl6j9tw79q5j1k
jelmer at samba.org-20070123012404-o9w5pmgkm94zsxlu
jelmer at samba.org-20070123094731-ns7dzzzqtb0dlcod
jelmer at samba.org-20070125123431-g3pqm92r31ez9xyc
jelmer at samba.org-20070126125959-3w3t26aps9hmwukv
jelmer at samba.org-20070126132607-64kt7rc2wtqh0c7u
jelmer at samba.org-20070126133903-onfotbg1051ktojo
jelmer at samba.org-20070126144259-171b4t0744jigs5x
jelmer at samba.org-20070126152205-xj7j1avc7683rjy5
jelmer at samba.org-20070128010235-e8st47gcy00ii8kc
jelmer at samba.org-20070128130853-xjjrlrtf830pwnx6
jelmer at samba.org-20070130120806-gfqshokma9j6j3uv
jelmer at samba.org-20070131002510-55yxynmb1o4zvx0x
jelmer at samba.org-20070131115042-oocen3olfgu53jlm
jelmer at samba.org-20070206235608-980jutwyp43708k6
jelmer at samba.org-20070207185718-i1xx6bvmdeeii72p
jelmer at samba.org-20070208234639-i0h5mfefbn1a1lkl
jelmer at samba.org-20070209001154-lol5huzwdq9jw2e7
jelmer at samba.org-20070209093351-buzkh0t55nt863gw
jelmer at samba.org-20070212120516-lwfxtpxx1lerwro2
jelmer at samba.org-20070212130037-e7t2bh0ufajvi8m6
jelmer at samba.org-20070212173050-hpr37tn9ws2zhfko
jelmer at samba.org-20070214123932-nmsy6lnin8gtzxrn
jelmer at samba.org-20070214141810-0df8ykq1d0dl6yia
jelmer at samba.org-20070214143534-pc63vqrp827s6sdo
jelmer at samba.org-20070214145213-idzserezbwc2alty
jelmer at samba.org-20070214150805-zjdhqbtwy28fac3c

   + jelmer at samba.org-20060824212938-5923465160f6ab63
jelmer at samba.org-20060830112659-186f132eebc987cc
jelmer at samba.org-20060904121718-63b73248146c14f8
jelmer at samba.org-20060904124721-5e70ab0bd405f748
metze at samba.org-20061010151401-45a5a2ed52cfe172
jelmer at samba.org-20061016130323-400ce51ee51ab30e
jelmer at samba.org-20061016195822-c7783d3ea1a56a53
jelmer at samba.org-20061016230421-75bca2ad62945ede
jelmer at samba.org-20061017145110-8c83a3dd979f6a6a
jelmer at samba.org-20061029173623-eb0459f1d3eb5720
jelmer at samba.org-20070115022006-h5ef1deqflt940b6
jelmer at samba.org-20070116142934-hv99dpwbnq2znh8f
jelmer at samba.org-20070116144126-70rip3bppmvgs3t6
jelmer at samba.org-20070116151516-imvui4r33cj850j9
jelmer at samba.org-20070116154739-3tji4fft7964qgrj
jelmer at samba.org-20070116173900-iasa25stcfty6pbr
jelmer at samba.org-20070117144550-te3o0iy10y14iyo4
jelmer at samba.org-20070122000024-q911packyrjk69ud
jelmer at samba.org-20070122181120-3n8ah238pjbzylyo
jelmer at samba.org-20070122182054-6b26fqrdqyjhyeuc
jelmer at samba.org-20070122233549-k085tfo2o1eqz7mm
jelmer at samba.org-20070123002251-0smz35eva10x84tc
jelmer at samba.org-20070123003546-p0jl6j9tw79q5j1k
jelmer at samba.org-20070123012404-o9w5pmgkm94zsxlu
jelmer at samba.org-20070123094731-ns7dzzzqtb0dlcod
jelmer at samba.org-20070125123431-g3pqm92r31ez9xyc
jelmer at samba.org-20070126125959-3w3t26aps9hmwukv
jelmer at samba.org-20070126132607-64kt7rc2wtqh0c7u
jelmer at samba.org-20070126133903-onfotbg1051ktojo
jelmer at samba.org-20070126144259-171b4t0744jigs5x
jelmer at samba.org-20070126152205-xj7j1avc7683rjy5
jelmer at samba.org-20070128010235-e8st47gcy00ii8kc
jelmer at samba.org-20070128130853-xjjrlrtf830pwnx6
jelmer at samba.org-20070130120806-gfqshokma9j6j3uv
jelmer at samba.org-20070131002510-55yxynmb1o4zvx0x
jelmer at samba.org-20070131115042-oocen3olfgu53jlm
jelmer at samba.org-20070206235608-980jutwyp43708k6
jelmer at samba.org-20070207185718-i1xx6bvmdeeii72p
jelmer at samba.org-20070208234639-i0h5mfefbn1a1lkl
jelmer at samba.org-20070209001154-lol5huzwdq9jw2e7
jelmer at samba.org-20070209093351-buzkh0t55nt863gw
jelmer at samba.org-20070212120516-lwfxtpxx1lerwro2
jelmer at samba.org-20070212130037-e7t2bh0ufajvi8m6
jelmer at samba.org-20070212173050-hpr37tn9ws2zhfko
jelmer at samba.org-20070214123932-nmsy6lnin8gtzxrn
jelmer at samba.org-20070214141810-0df8ykq1d0dl6yia
jelmer at samba.org-20070214143534-pc63vqrp827s6sdo
jelmer at samba.org-20070214145213-idzserezbwc2alty
jelmer at samba.org-20070214150805-zjdhqbtwy28fac3c
jelmer at samba.org-20070214192135-0yxxt5pto2lv4p4h


Modified: branches/SAMBA_4_0/source/librpc/idl/winreg.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/winreg.idl	2007-02-14 17:17:32 UTC (rev 21346)
+++ branches/SAMBA_4_0/source/librpc/idl/winreg.idl	2007-02-14 19:30:05 UTC (rev 21347)
@@ -89,7 +89,7 @@
 
 	/******************/
 	/* Function: 0x05 */
-	WERROR winreg_CloseKey(
+	[public] WERROR winreg_CloseKey(
 		[in,out,ref] policy_handle *handle
 	);
 

Modified: branches/SAMBA_4_0/source/torture/config.mk
===================================================================
--- branches/SAMBA_4_0/source/torture/config.mk	2007-02-14 17:17:32 UTC (rev 21346)
+++ branches/SAMBA_4_0/source/torture/config.mk	2007-02-14 19:30:05 UTC (rev 21347)
@@ -96,6 +96,13 @@
 
 include smb2/config.mk
 
+[MODULE::torture_ndr]
+SUBSYSTEM = torture
+INIT_FUNCTION = torture_ndr_init
+PRIVATE_PROTO_HEADER = ndr/proto.h
+OBJ_FILES = ndr/ndr.o \
+			ndr/winreg.o
+
 [MODULE::torture_rpc]
 # TORTURE_NET and TORTURE_NBT use functions from torture_rpc...
 #OUTPUT_TYPE = INTEGRATED

Added: branches/SAMBA_4_0/source/torture/ndr/ndr.c
===================================================================
--- branches/SAMBA_4_0/source/torture/ndr/ndr.c	2007-02-14 17:17:32 UTC (rev 21346)
+++ branches/SAMBA_4_0/source/torture/ndr/ndr.c	2007-02-14 19:30:05 UTC (rev 21347)
@@ -0,0 +1,94 @@
+/* 
+   Unix SMB/CIFS implementation.
+   test suite for winreg ndr operations
+
+   Copyright (C) Jelmer Vernooij 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 "torture/ndr/ndr.h"
+#include "torture/ndr/proto.h"
+#include "util/dlinklist.h"
+
+struct ndr_pull_test_data {
+	DATA_BLOB data;
+	size_t struct_size;
+	ndr_pull_flags_fn_t pull_fn;
+	int ndr_flags;
+};
+
+static bool wrap_ndr_pull_test(struct torture_context *tctx,
+							   struct torture_tcase *tcase,
+							   struct torture_test *test)
+{
+	bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn;
+	const struct ndr_pull_test_data *data = test->data;
+	void *ds = talloc_zero_size(tctx, data->struct_size);
+	struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx);
+
+	ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
+
+	torture_assert_ntstatus_ok(tctx, data->pull_fn(ndr, data->ndr_flags, ds), 
+							   "pulling");
+
+	return check_fn(tctx, ds);
+}
+
+_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test(
+					struct torture_suite *suite, 
+					const char *name, ndr_pull_flags_fn_t pull_fn,
+					DATA_BLOB db, 
+					size_t struct_size,
+					int ndr_flags,
+					bool (*check_fn) (struct torture_context *ctx, void *data))
+{
+	struct torture_test *test; 
+	struct torture_tcase *tcase;
+	struct ndr_pull_test_data *data;
+	
+	tcase = torture_suite_add_tcase(suite, name);
+
+	test = talloc(tcase, struct torture_test);
+
+	test->name = talloc_strdup(test, name);
+	test->description = NULL;
+	test->run = wrap_ndr_pull_test;
+	data = talloc(test, struct ndr_pull_test_data);
+	data->data = db;
+	data->ndr_flags = ndr_flags;
+	data->struct_size = struct_size;
+	data->pull_fn = pull_fn;
+	test->data = data;
+	test->fn = check_fn;
+	test->dangerous = false;
+
+	DLIST_ADD_END(tcase->tests, test, struct torture_test *);
+
+	return test;
+}
+
+NTSTATUS torture_ndr_init(void)
+{
+	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "NDR");
+
+	torture_suite_add_suite(suite, ndr_winreg_suite(suite));
+
+	torture_register_suite(suite);
+
+	return NT_STATUS_OK;
+}
+

Added: branches/SAMBA_4_0/source/torture/ndr/ndr.h
===================================================================
--- branches/SAMBA_4_0/source/torture/ndr/ndr.h	2007-02-14 17:17:32 UTC (rev 21346)
+++ branches/SAMBA_4_0/source/torture/ndr/ndr.h	2007-02-14 19:30:05 UTC (rev 21347)
@@ -0,0 +1,45 @@
+/* 
+   Unix SMB/CIFS implementation.
+   SMB torture tester
+   Copyright (C) Jelmer Vernooij 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.
+*/
+
+#ifndef __TORTURE_NDR_H__
+#define __TORTURE_NDR_H__
+
+#include "torture/torture.h"
+#include "librpc/ndr/libndr.h"
+
+_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test(
+					struct torture_suite *suite, 
+					const char *name, ndr_pull_flags_fn_t fn,
+					DATA_BLOB db, 
+					size_t struct_size,
+					int ndr_flags,
+					bool (*check_fn) (struct torture_context *, void *data));
+
+#define torture_suite_add_ndr_pull_test(suite,name,data,check_fn) \
+		_torture_suite_add_ndr_pull_test(suite, #name, \
+			 (ndr_pull_flags_fn_t)ndr_pull_ ## name, data_blob_talloc(suite, data, sizeof(data)), \
+			 sizeof(struct name), 0, (bool (*) (struct torture_context *, void *)) check_fn);
+
+#define torture_suite_add_ndr_pull_fn_test(suite,name,data,flags,check_fn) \
+		_torture_suite_add_ndr_pull_test(suite, #name, \
+			 (ndr_pull_flags_fn_t)ndr_pull_ ## name, data_blob_talloc(suite, data, sizeof(data)), \
+			 sizeof(struct name), flags, (bool (*) (struct torture_context *, void *)) check_fn);
+
+#endif /* __TORTURE_NDR_H__ */

Added: branches/SAMBA_4_0/source/torture/ndr/winreg.c
===================================================================
--- branches/SAMBA_4_0/source/torture/ndr/winreg.c	2007-02-14 17:17:32 UTC (rev 21346)
+++ branches/SAMBA_4_0/source/torture/ndr/winreg.c	2007-02-14 19:30:05 UTC (rev 21347)
@@ -0,0 +1,48 @@
+/* 
+   Unix SMB/CIFS implementation.
+   test suite for winreg ndr operations
+
+   Copyright (C) Jelmer Vernooij 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 "torture/ndr/ndr.h"
+#include "librpc/gen_ndr/ndr_winreg.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "libcli/security/security.h"
+
+static const uint8_t winreg_closekey_data[] = { 
+        0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48, 
+        0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
+};
+
+static bool winreg_closekey_check(struct torture_context *tctx, 
+								  struct winreg_CloseKey *ck)
+{
+	torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
+	torture_assert_int_equal(tctx, ck->in.handle->handle_type, 0, "handle type");
+	return true;
+}
+
+struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
+{
+	struct torture_suite *suite = torture_suite_create(ctx, "winreg");
+
+	torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, winreg_closekey_data, NDR_IN, winreg_closekey_check );
+
+	return suite;
+}



More information about the samba-cvs mailing list