]> git.saurik.com Git - apple/configd.git/blob - scutil.tproj/tests.c
703ef5ffd8a98acae4b33ef656dd072f13408bb8
[apple/configd.git] / scutil.tproj / tests.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 #include "scutil.h"
24 #include "SCDPrivate.h"
25
26 void
27 do_snapshot(int argc, char **argv)
28 {
29 SCDStatus status;
30
31 status = SCDSnapshot(session);
32 if (status != SCD_OK) {
33 printf("SCDSnapshot: %s\n", SCDError(status));
34 }
35 return;
36 }
37
38
39 #ifdef DEBUG
40
41 void
42 test_openCloseLeak(int argc, char **argv)
43 {
44 SCDStatus status;
45 int i, loopCnt;
46 SCDSessionRef *sessions;
47
48 if ((argc == 0) || (sscanf(argv[0], "%d", &loopCnt) != 1)) {
49 loopCnt = 100;
50 }
51
52 sessions = malloc(loopCnt * sizeof(SCDSessionRef));
53
54 /* open, close, open, close, open, close, ... */
55 for (i=0; i<loopCnt; i++) {
56 status = SCDOpen(&sessions[i], CFSTR("sc"));
57 if (status != SCD_OK) {
58 printf("SCDOpen: %s\n", SCDError(status));
59 break;
60 }
61
62 status = SCDClose(&sessions[i]);
63 if (status != SCD_OK) {
64 printf("SCDClose: %s\n", SCDError(status));
65 break;
66 }
67 }
68
69 /* open, open, open, close, close, close, ... */
70 for (i=0; i<loopCnt; i++) {
71 status = SCDOpen(&sessions[i], CFSTR("sc"));
72 if (status != SCD_OK) {
73 printf("SCDOpen: %s\n", SCDError(status));
74 break;
75 }
76 }
77 for (i=0; i<loopCnt; i++) {
78 status = SCDClose(&sessions[i]);
79 if (status != SCD_OK) {
80 printf("SCDClose: %s\n", SCDError(status));
81 break;
82 }
83 }
84
85 return;
86 }
87 #endif /* DEBUG */