2 #include <Security/Security.h>
3 #include <CoreFoundation/CoreFoundation.h>
4 #include <dispatch/dispatch.h>
11 const double kTestLength
= 10.0; // length of a test
13 #define MAXIMUM_NUMBER_OF_THREADS 100
18 gettimeofday(&tv
, NULL
);
20 return (double) tv
.tv_sec
+ (double) tv
.tv_usec
/ 1000000.0;
25 void* CopyDefaultAndReleaseInSingleThread(void* arg
)
29 double endTime
= GetTimeOfDay() + kTestLength
;
33 result
= SecKeychainCopyDefault(&kc
);
41 } while (GetTimeOfDay() < endTime
);
48 int CopyDefaultAndDeleteInMultipleThreadsTest()
50 const int gMax
= MAXIMUM_NUMBER_OF_THREADS
;
51 pthread_t threads
[gMax
];
55 for (i
= 0; i
< gMax
; ++i
)
57 pthread_create(&threads
[i
], NULL
, CopyDefaultAndReleaseInSingleThread
, NULL
);
60 // wait for them to complete
61 for (i
= 0; i
< gMax
; ++i
)
63 pthread_join(threads
[i
], NULL
);
71 int main(int argc
, char* const argv
[])
74 ok(CopyDefaultAndDeleteInMultipleThreadsTest(), "CopyDefaultAndDeleteInMultipleThreadsTest");
75 ok_leaks("kc-50-thread");