source: vendor/current/lib/util/tests/anonymous_shared.c@ 740

Last change on this file since 740 was 740, checked in by Silvan Scherrer, 12 years ago

Samba Server: update vendor to 3.6.0

File size: 2.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 anonymous_shared testing
5
6 Copyright (C) Stefan Metzmacher 2011
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "includes.h"
23#include "torture/torture.h"
24#include "torture/local/proto.h"
25
26static bool test_anonymous_shared_simple(struct torture_context *tctx)
27{
28 void *ptr;
29 size_t len;
30
31 torture_comment(tctx, "anonymous_shared_free(NULL)\n");
32 anonymous_shared_free(NULL);
33
34 len = 500;
35 torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
36 (unsigned long long)len);
37 ptr = anonymous_shared_allocate(len);
38 torture_assert(tctx, ptr, "valid pointer");
39 memset(ptr, 0xfe, len);
40 torture_comment(tctx, "anonymous_shared_free(ptr)\n");
41 anonymous_shared_free(ptr);
42
43 len = 50000;
44 torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
45 (unsigned long long)len);
46 ptr = anonymous_shared_allocate(len);
47 torture_assert(tctx, ptr, "valid pointer");
48 memset(ptr, 0xfe, len);
49 torture_comment(tctx, "anonymous_shared_free(ptr)\n");
50 anonymous_shared_free(ptr);
51
52 memset(&len, 0xFF, sizeof(len));
53 torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
54 (unsigned long long)len);
55 ptr = anonymous_shared_allocate(len);
56 torture_assert(tctx, ptr == NULL, "null pointer");
57
58 return true;
59}
60
61/* local.anonymous_shared test suite creation */
62struct torture_suite *torture_local_util_anonymous_shared(TALLOC_CTX *mem_ctx)
63{
64 struct torture_suite *suite = torture_suite_create(mem_ctx, "anonymous_shared");
65
66 torture_suite_add_simple_test(suite, "simple",
67 test_anonymous_shared_simple);
68
69 return suite;
70}
Note: See TracBrowser for help on using the repository browser.