]> git.saurik.com Git - apple/security.git/blob - keychain/SecureObjectSync/Regressions/sc-42-circlegencount.c
Security-59754.41.1.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 "keychain/securityd/SOSCloudCircleServer.h"
30
31 #include "SOSCircle_regressions.h"
32
33 #include "SOSRegressionUtilities.h"
34 #if SOS_ENABLED
35
36 static void tests(void)
37 {
38 uint64_t beginvalue;
39 uint64_t lastvalue;
40 uint64_t newvalue;
41
42 SOSCircleRef circle = SOSCircleCreate(NULL, CFSTR("TEST DOMAIN"), NULL);
43
44 ok(NULL != circle, "Circle creation");
45
46 ok(0 == SOSCircleCountPeers(circle), "Zero peers");
47
48 ok(0 != (beginvalue = SOSCircleGetGenerationSint(circle))); // New circles should never be 0
49
50 SOSCircleGenerationSetValue(circle, 0);
51
52 ok(0 == SOSCircleGetGenerationSint(circle)); // Know we're starting out with a zero value (forced)
53
54 SOSCircleGenerationIncrement(circle);
55
56 ok(beginvalue <= (newvalue = SOSCircleGetGenerationSint(circle))); // incremented value should be greater or equal than where we began quantum is 2 seconds
57 lastvalue = newvalue;
58
59 SOSCircleGenerationIncrement(circle);
60 ok(lastvalue < (newvalue = SOSCircleGetGenerationSint(circle))); // incremented value should be greater than last
61 lastvalue = newvalue;
62
63 SOSCircleResetToEmpty(circle, NULL);
64 ok(lastvalue < (newvalue = SOSCircleGetGenerationSint(circle))); // incremented value should be greater than last
65
66 CFReleaseNull(circle);
67 }
68 #endif
69
70 int sc_42_circlegencount(int argc, char *const *argv)
71 {
72 #if SOS_ENABLED
73 plan_tests(7);
74 tests();
75 #else
76 plan_tests(0);
77 #endif
78 return 0;
79 }