]> git.saurik.com Git - apple/security.git/blob - keychain/SecureObjectSync/Regressions/sc-42-circlegencount.c
Security-59306.11.20.tar.gz
[apple/security.git] / keychain / SecureObjectSync / Regressions / sc-42-circlegencount.c
1 //
2 // sc-42-circlegencount.c
3 // sec
4 //
5 // Created by Richard Murphy on 9/10/14.
6 //
7 //
8
9
10
11
12 #include <Security/SecBase.h>
13 #include <Security/SecItem.h>
14 #include <Security/SecKey.h>
15
16 #include "keychain/SecureObjectSync/SOSCircle.h"
17 #include <Security/SecureObjectSync/SOSCloudCircle.h>
18 #include <Security/SecureObjectSync/SOSPeerInfo.h>
19 #include "keychain/SecureObjectSync/SOSInternal.h"
20 #include "keychain/SecureObjectSync/SOSUserKeygen.h"
21
22 #include <utilities/SecCFWrappers.h>
23
24 #include <CoreFoundation/CoreFoundation.h>
25
26 #include <stdlib.h>
27 #include <unistd.h>
28
29 #include <securityd/SOSCloudCircleServer.h>
30
31 #include "SOSCircle_regressions.h"
32
33 #include "SOSRegressionUtilities.h"
34
35 static int kTestTestCount = 7;
36
37 static void tests(void)
38 {
39 uint64_t beginvalue;
40 uint64_t lastvalue;
41 uint64_t newvalue;
42
43 SOSCircleRef circle = SOSCircleCreate(NULL, CFSTR("TEST DOMAIN"), NULL);
44
45 ok(NULL != circle, "Circle creation");
46
47 ok(0 == SOSCircleCountPeers(circle), "Zero peers");
48
49 ok(0 != (beginvalue = SOSCircleGetGenerationSint(circle))); // New circles should never be 0
50
51 SOSCircleGenerationSetValue(circle, 0);
52
53 ok(0 == SOSCircleGetGenerationSint(circle)); // Know we're starting out with a zero value (forced)
54
55 SOSCircleGenerationIncrement(circle);
56
57 ok(beginvalue <= (newvalue = SOSCircleGetGenerationSint(circle))); // incremented value should be greater or equal than where we began quantum is 2 seconds
58 lastvalue = newvalue;
59
60 SOSCircleGenerationIncrement(circle);
61 ok(lastvalue < (newvalue = SOSCircleGetGenerationSint(circle))); // incremented value should be greater than last
62 lastvalue = newvalue;
63
64 SOSCircleResetToEmpty(circle, NULL);
65 ok(lastvalue < (newvalue = SOSCircleGetGenerationSint(circle))); // incremented value should be greater than last
66
67 CFReleaseNull(circle);
68 }
69
70 int sc_42_circlegencount(int argc, char *const *argv)
71 {
72 plan_tests(kTestTestCount);
73
74 tests();
75
76 return 0;
77 }