secd-74-engine-beer-servers.c [plain text]
#include <SOSCircle/Regressions/SOSTestDevice.h>
#include "secd_regressions.h"
#include "SecdTestKeychainUtilities.h"
static int kTestTestCount = 646;
static void beer_servers(void) {
__block int iteration=0;
__block int objectix=0;
__block CFMutableArrayRef objectNames = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
const size_t itemDataSize = 1024;
const int peerCount = 4;
const int edgeCount = peerCount * (peerCount - 1);
const int itemsPerPeer = 1000;
const int itemsPerIteration = 100;
const int itemChunkCount = (itemsPerPeer / itemsPerIteration);
const int deleteIteration = edgeCount * (itemChunkCount + 30);
const int idleIteration = 616;
CFMutableDataRef itemData = CFDataCreateMutable(kCFAllocatorDefault, itemDataSize);
CFDataSetLength(itemData, itemDataSize);
SOSTestDeviceListTestSync("beer_servers", test_directive, test_reason, 0, false, ^bool(SOSTestDeviceRef source, SOSTestDeviceRef dest) {
bool result = false;
if (iteration <= edgeCount * itemChunkCount) {
if (iteration % (peerCount - 1) == 0) {
for (int j = 0; j < itemsPerIteration; ++j) {
CFStringRef name = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@-pre-%d"), SOSTestDeviceGetID(source), objectix++);
CFArrayAppendValue(objectNames, name);
SOSTestDeviceAddGenericItemWithData(source, name, name, itemData);
CFReleaseNull(name);
}
}
result = true;
} else if (iteration == deleteIteration) {
} else if (deleteIteration < iteration && iteration <= deleteIteration + edgeCount * itemChunkCount) {
if (iteration % (peerCount - 1) == 0) {
for (int j = 0; j < itemsPerIteration; ++j) {
CFStringRef name = CFArrayGetValueAtIndex(objectNames, --objectix);
SOSTestDeviceAddGenericItemTombstone(source, name, name);
}
result = true;
}
} else if (idleIteration == iteration) {
} else if (617 == iteration) {
}
iteration++;
return result || iteration < deleteIteration;
}, ^bool(SOSTestDeviceRef source, SOSTestDeviceRef dest, SOSMessageRef message) {
return false;
}, CFSTR("becks"), CFSTR("corona"), CFSTR("heineken"), CFSTR("spaten"), NULL);
CFRelease(objectNames);
CFRelease(itemData);
}
int secd_74_engine_beer_servers(int argc, char *const *argv)
{
plan_tests(kTestTestCount);
secd_test_setup_temp_keychain(__FUNCTION__, NULL);
beer_servers();
return 0;
}