X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/SecurityTests/testclient/testclient.cpp diff --git a/SecurityTests/testclient/testclient.cpp b/SecurityTests/testclient/testclient.cpp new file mode 100644 index 00000000..affb5116 --- /dev/null +++ b/SecurityTests/testclient/testclient.cpp @@ -0,0 +1,132 @@ +// +// Test driver program for cdsa_client library +// +#include "csptests.h" +#include "dltests.h" + +#include +#include +#include +#include +#include + +using namespace CssmClient; +extern "C" void malloc_debug(int); + +static void usage(); + +static const char *progname; + +// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ +// ¥ main +// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ +int main(int argc, char *argv[]) +{ + extern char *optarg; + extern int optind; + bool didWork = false; + bool autoCommit = true; + bool printSchema = false; + int ch; + + progname = strrchr(argv[0], '/'); + progname = progname ? progname + 1 : argv[0]; + + try + { + while ((ch = getopt(argc, argv, "?haAbcdM:D:smwg:")) != -1) + { + switch(ch) + { + case 'a': + autoCommit=true; + break; + case 'A': + autoCommit=false; + break; + case 'b': + setbuf(stdout, NULL); + break; + case 'c': + csptests(); + didWork = true; + break; + case 'm': + testmac(); + didWork = true; + break; + case 'w': + testwrap(); + didWork = true; + break; + case 'd': + dltests(autoCommit); + didWork = true; + break; + case 's': + printSchema = true; + break; + case 'g': + if (strcmp (optarg, "AppleFileDL") == 0) + { + gSelectedFileGuid = &gGuidAppleFileDL; + } + else if (strcmp (optarg, "LDAPDL") == 0) + { + gSelectedFileGuid = &gGuidAppleLDAPDL; + } + else + { + didWork = false; + } + break; + case 'D': + dumpDb(optarg, printSchema); + didWork = true; + break; + case 'M': + malloc_debug(atoi(optarg)); + break; + case '?': + case 'h': + default: + usage(); + } + } + + if (argc != optind) + usage(); + + if (!didWork) + usage(); + + Cssm::standard()->terminate(); + } + catch (CommonError &error) + { + cssmPerror("Tester abort", error.osStatus()); + } + + return 0; +} + +// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ +// ¥ usage +// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ +static void +usage() +{ + printf("usage: %s [-M] [-b] [-c] [[-a|-A] -d] [[-s ] [-g AppleFileDL | LDAPDL] -D ]\n", progname); + printf(" -M debug_level Call malloc_debug(debug_level) to enable malloc debugging.\n"); + printf(" -b turn off stdout buffering.\n"); + printf(" -c run csp (rotty) tests.\n"); + printf(" -m Test Mac\n"); + printf(" -w Test Wrap\n"); + printf(" -d run dl tests.\n"); + printf(" -a Enable AutoCommit for dl modifications (default).\n"); + printf(" -A Disable AutoCommit for dl modifications.\n"); + printf(" -D dbname Dump a db into a human readable format.\n"); + printf(" -s Dump out schema info (use with -D).\n"); + exit(1); +} +