lib/util: add tests for anonymous_shared_allocate/free()
authorStefan Metzmacher <metze@samba.org>
Tue, 18 Jan 2011 16:00:26 +0000 (17:00 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 20 Jan 2011 05:25:03 +0000 (06:25 +0100)
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Thu Jan 20 06:25:03 CET 2011 on sn-devel-104

lib/util/tests/anonymous_shared.c [new file with mode: 0644]
source4/torture/local/local.c
source4/torture/local/wscript_build

diff --git a/lib/util/tests/anonymous_shared.c b/lib/util/tests/anonymous_shared.c
new file mode 100644 (file)
index 0000000..512a53f
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   anonymous_shared testing
+
+   Copyright (C) Stefan Metzmacher 2011
+
+   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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "torture/torture.h"
+#include "torture/local/proto.h"
+
+static bool test_anonymous_shared_simple(struct torture_context *tctx)
+{
+       void *ptr;
+       size_t len;
+
+       torture_comment(tctx, "anonymous_shared_free(NULL)\n");
+       anonymous_shared_free(NULL);
+
+       len = 500;
+       torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
+                       (unsigned long long)len);
+       ptr = anonymous_shared_allocate(len);
+       torture_assert(tctx, ptr, "valid pointer");
+       memset(ptr, 0xfe, len);
+       torture_comment(tctx, "anonymous_shared_free(ptr)\n");
+       anonymous_shared_free(ptr);
+
+       len = 50000;
+       torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
+                       (unsigned long long)len);
+       ptr = anonymous_shared_allocate(len);
+       torture_assert(tctx, ptr, "valid pointer");
+       memset(ptr, 0xfe, len);
+       torture_comment(tctx, "anonymous_shared_free(ptr)\n");
+       anonymous_shared_free(ptr);
+
+       memset(&len, 0xFF, sizeof(len));
+       torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
+                       (unsigned long long)len);
+       ptr = anonymous_shared_allocate(len);
+       torture_assert(tctx, ptr == NULL, "null pointer");
+
+       return true;
+}
+
+/* local.anonymous_shared test suite creation */
+struct torture_suite *torture_local_util_anonymous_shared(TALLOC_CTX *mem_ctx)
+{
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "anonymous_shared");
+
+       torture_suite_add_simple_test(suite, "simple",
+                                     test_anonymous_shared_simple);
+
+       return suite;
+}
index d044c8f87722446af985190d9eeb9840b28f51ac..a8147daf0cde8b473bf3ad7fd195e1130b0b0d9f 100644 (file)
@@ -40,6 +40,7 @@
        torture_local_util_time, 
        torture_local_util_data_blob, 
        torture_local_util_asn1,
+       torture_local_util_anonymous_shared,
        torture_local_idtree, 
        torture_local_dlinklist,
        torture_local_genrand, 
index dff75bf02f93f136bd6085492114905ba3be52ab..19d74c72d8a311826b33b6b6938f7621dd9faaa0 100644 (file)
@@ -1,6 +1,21 @@
 #!/usr/bin/env python
 
-TORTURE_LOCAL_SOURCE = '../../../lib/util/charset/tests/iconv.c ../../../lib/talloc/testsuite.c ../../lib/messaging/tests/messaging.c ../../lib/messaging/tests/irpc.c ../../librpc/tests/binding_string.c ../../../lib/util/tests/idtree.c ../../../lib/util/tests/dlinklist.c ../../lib/socket/testsuite.c ../../libcli/resolve/testsuite.c ../../../lib/util/tests/strlist.c ../../../lib/util/tests/parmlist.c ../../../lib/util/tests/str.c ../../../lib/util/tests/time.c ../../../lib/util/tests/asn1_tests.c ../../../lib/util/tests/data_blob.c ../../../lib/util/tests/file.c ../../../lib/util/tests/genrand.c ../../../lib/compression/testsuite.c ../../../lib/util/charset/tests/charset.c ../../libcli/security/tests/sddl.c ../../../lib/tdr/testsuite.c ../../../lib/tevent/testsuite.c ../../param/tests/share.c ../../param/tests/loadparm.c ../../auth/credentials/tests/simple.c local.c dbspeed.c torture.c ../ldb/ldb.c ../../dsdb/common/tests/dsdb_dn.c ../../dsdb/schema/tests/schema_syntax.c'
+TORTURE_LOCAL_SOURCE = '''../../../lib/util/charset/tests/iconv.c
+       ../../../lib/talloc/testsuite.c ../../lib/messaging/tests/messaging.c
+       ../../lib/messaging/tests/irpc.c ../../librpc/tests/binding_string.c
+       ../../../lib/util/tests/idtree.c ../../../lib/util/tests/dlinklist.c
+       ../../lib/socket/testsuite.c ../../libcli/resolve/testsuite.c
+       ../../../lib/util/tests/strlist.c ../../../lib/util/tests/parmlist.c
+       ../../../lib/util/tests/str.c ../../../lib/util/tests/time.c
+       ../../../lib/util/tests/asn1_tests.c ../../../lib/util/tests/data_blob.c
+       ../../../lib/util/tests/file.c ../../../lib/util/tests/genrand.c
+       ../../../lib/compression/testsuite.c ../../../lib/util/charset/tests/charset.c
+       ../../libcli/security/tests/sddl.c ../../../lib/tdr/testsuite.c
+       ../../../lib/tevent/testsuite.c ../../param/tests/share.c
+       ../../param/tests/loadparm.c ../../auth/credentials/tests/simple.c local.c
+       dbspeed.c torture.c ../ldb/ldb.c ../../dsdb/common/tests/dsdb_dn.c
+       ../../dsdb/schema/tests/schema_syntax.c
+       ../../../lib/util/tests/anonymous_shared.c'''
 
 TORTURE_LOCAL_DEPS = 'RPC_NDR_ECHO TDR LIBCLI_SMB MESSAGING iconv POPT_CREDENTIALS TORTURE_AUTH TORTURE_UTIL TORTURE_NDR TORTURE_LIBCRYPTO share torture_registry PROVISION ldb samdb replace-test'