Rev 11658: Add simple tests for genrand in file:///home/jelmer/bzr.samba/SAMBA_4_0/

Jelmer Vernooij jelmer at samba.org
Sun Mar 4 22:33:21 GMT 2007


At file:///home/jelmer/bzr.samba/SAMBA_4_0/

------------------------------------------------------------
revno: 11658
revision-id: jelmer at samba.org-20070304223307-xafpwvov6tgmdb8z
parent: svn-v2:21687 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Sun 2007-03-04 23:33:07 +0100
message:
  Add simple tests for genrand
added:
  source/lib/compression/testsuite.c testsuite.c-20070304220830-7goxd50vmeqoxq9d-1
  source/lib/util/tests/genrand.c genrand.c-20070304222419-s3skaz7zixplsf4p-1
modified:
  source/torture/local/config.mk svn-v2:12008 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2ftorture%2flocal%2fconfig.mk
  source/torture/local/local.c   svn-v2:16333 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2ftorture%2flocal%2flocal.c
=== added file 'source/lib/compression/testsuite.c'
--- a/source/lib/compression/testsuite.c	1970-01-01 00:00:00 +0000
+++ b/source/lib/compression/testsuite.c	2007-03-04 22:33:07 +0000
@@ -0,0 +1,33 @@
+/* 
+   Unix SMB/CIFS implementation.
+   test suite for the compression functions
+
+   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/torture.h"
+#include "lib/compression/mszip.h"
+
+struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx)
+{
+	struct torture_suite *suite = torture_suite_create(mem_ctx, "COMPRESSION");
+
+	torture_suite_add_simple_test(suite, "pull_charset", test_pull_charset);
+
+	return suite;
+}

=== added file 'source/lib/util/tests/genrand.c'
--- a/source/lib/util/tests/genrand.c	1970-01-01 00:00:00 +0000
+++ b/source/lib/util/tests/genrand.c	2007-03-04 22:33:07 +0000
@@ -0,0 +1,66 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   local testing of random data routines.
+
+   Copyright (C) Jelmer Vernooij <jelmer at samba.org>
+   
+   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/torture.h"
+
+static void dummy_reseed(int *d)
+{
+	*d = 42;
+}
+
+static bool test_reseed_callback(struct torture_context *tctx)
+{
+	set_rand_reseed_callback(dummy_reseed);
+	return true;
+}
+
+static bool test_check_password_quality(struct torture_context *tctx)
+{
+	torture_assert(tctx, !check_password_quality(""), "empty password");
+	torture_assert(tctx, !check_password_quality("a"), "one char password");
+	torture_assert(tctx, !check_password_quality("aaaaaaaaaaaa"), "same char password");
+	torture_assert(tctx, !check_password_quality("BLA"), "multiple upcases password");
+	torture_assert(tctx, !check_password_quality("123"), "digits only");
+	torture_assert(tctx, check_password_quality("A2e"), "valid");
+	torture_assert(tctx, check_password_quality("BA2eLi443"), "valid");
+	return true;
+}
+
+static bool test_generate_random_str(struct torture_context *tctx)
+{
+	TALLOC_CTX *mem_ctx = talloc_init(__FUNCTION__);
+	char *r = generate_random_str(mem_ctx, 10);
+	torture_assert_int_equal(tctx, strlen(r), 10, "right length generated");
+	r = generate_random_str(mem_ctx, 5);
+	torture_assert_int_equal(tctx, strlen(r), 5, "right length generated");
+	return true;
+}
+
+struct torture_suite *torture_local_genrand(TALLOC_CTX *mem_ctx)
+{
+	struct torture_suite *suite = torture_suite_create(mem_ctx, "GENRAND");
+	torture_suite_add_simple_test(suite, "reseed_callback", test_reseed_callback);
+	torture_suite_add_simple_test(suite, "check_password_quality", test_check_password_quality);
+	torture_suite_add_simple_test(suite, "generate_random_str", test_generate_random_str);
+	return suite;
+}

=== modified file 'source/torture/local/config.mk'
--- a/source/torture/local/config.mk	2007-03-03 01:20:36 +0000
+++ b/source/torture/local/config.mk	2007-03-04 22:33:07 +0000
@@ -25,6 +25,7 @@
 		resolve.o \
 		../../lib/util/tests/strlist.o \
 		../../lib/util/tests/file.o \
+		../../lib/util/tests/genrand.o \
 		sddl.o \
 		../../lib/tdr/testsuite.o \
 		event.o \

=== modified file 'source/torture/local/local.c'
--- a/source/torture/local/local.c	2007-03-03 01:20:36 +0000
+++ b/source/torture/local/local.c	2007-03-04 22:33:07 +0000
@@ -35,6 +35,7 @@
 	torture_local_util_strlist, 
 	torture_local_util_file, 
 	torture_local_idtree, 
+	torture_local_genrand, 
 	torture_local_iconv,
 	torture_local_socket, 
 	torture_local_socket_wrapper, 



More information about the samba-cvs mailing list