X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=scheduler%2Ftestspeed.c;h=2034016c84029af0ab2ccfa8843ecadd54ac36f8;hb=503b54c9302c8de6207e079a80a89a787eb612ea;hp=4b740675eca755c5bb4449ee5f4389b7d50f7934;hpb=dd1abb6b5f145c5e5f279d8848b5f3ec161fd227;p=thirdparty%2Fcups.git diff --git a/scheduler/testspeed.c b/scheduler/testspeed.c index 4b740675e..2034016c8 100644 --- a/scheduler/testspeed.c +++ b/scheduler/testspeed.c @@ -1,39 +1,27 @@ /* - * "$Id: testspeed.c 6649 2007-07-11 21:46:42Z mike $" + * Scheduler speed test for CUPS. * - * Scheduler speed test for the Common UNIX Printing System (CUPS). + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2005 by Easy Software Products. * - * Copyright 2007-2008 by Apple Inc. - * Copyright 1997-2005 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Send multiple IPP requests and report on the average response - * time. - * do_test() - Run a test on a specific host... - * usage() - Show program usage... + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* * Include necessary headers... */ -#include -#include -#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include /* @@ -42,8 +30,8 @@ static int do_test(const char *server, int port, http_encryption_t encryption, int requests, - int verbose); -static void usage(void); + const char *opstring, int verbose); +static void usage(void) __attribute__((noreturn)); /* @@ -69,6 +57,7 @@ main(int argc, /* I - Number of command-line arguments */ end; /* End time */ double elapsed; /* Elapsed time */ int verbose; /* Verbosity */ + const char *opstring; /* Operation name */ /* @@ -81,6 +70,7 @@ main(int argc, /* I - Number of command-line arguments */ port = ippPort(); encryption = HTTP_ENCRYPT_IF_REQUESTED; verbose = 0; + opstring = NULL; for (i = 1; i < argc; i ++) if (argv[i][0] == '-') @@ -88,6 +78,10 @@ main(int argc, /* I - Number of command-line arguments */ for (ptr = argv[i] + 1; *ptr; ptr ++) switch (*ptr) { + case 'E' : /* Enable encryption */ + encryption = HTTP_ENCRYPT_REQUIRED; + break; + case 'c' : /* Number of children */ i ++; if (i >= argc) @@ -96,16 +90,20 @@ main(int argc, /* I - Number of command-line arguments */ children = atoi(argv[i]); break; - case 'r' : /* Number of requests */ + case 'o' : /* Operation */ i ++; if (i >= argc) usage(); - requests = atoi(argv[i]); + opstring = argv[i]; break; - case 'E' : /* Enable encryption */ - encryption = HTTP_ENCRYPT_REQUIRED; + case 'r' : /* Number of requests */ + i ++; + if (i >= argc) + usage(); + + requests = atoi(argv[i]); break; case 'v' : /* Verbose logging */ @@ -142,9 +140,10 @@ main(int argc, /* I - Number of command-line arguments */ start = time(NULL); if (children < 1) - return (do_test(server, port, encryption, requests, verbose)); + return (do_test(server, port, encryption, requests, opstring, verbose)); else if (children == 1) - good_children = do_test(server, port, encryption, requests, verbose) ? 0 : 1; + good_children = do_test(server, port, encryption, requests, opstring, + verbose) ? 0 : 1; else { char options[255], /* Command-line options for child */ @@ -177,7 +176,12 @@ main(int argc, /* I - Number of command-line arguments */ * Child goes here... */ - execlp(argv[0], argv[0], options, "0", reqstr, serverstr, (char *)NULL); + if (opstring) + execlp(argv[0], argv[0], options, "0", reqstr, "-o", opstring, + serverstr, (char *)NULL); + else + execlp(argv[0], argv[0], options, "0", reqstr, serverstr, (char *)NULL); + exit(errno); } else if (pid < 0) @@ -240,6 +244,7 @@ do_test(const char *server, /* I - Server to use */ int port, /* I - Port number to use */ http_encryption_t encryption, /* I - Encryption to use */ int requests, /* I - Number of requests to send */ + const char *opstring, /* I - Operation string */ int verbose) /* I - Verbose output? */ { int i; /* Looping var */ @@ -250,9 +255,10 @@ do_test(const char *server, /* I - Server to use */ double reqtime, /* Time for this request */ elapsed; /* Elapsed time */ int op; /* Current operation */ - static ipp_op_t ops[4] = /* Operations to test... */ + static ipp_op_t ops[5] = /* Operations to test... */ { IPP_PRINT_JOB, + CUPS_GET_DEFAULT, CUPS_GET_PRINTERS, CUPS_GET_CLASSES, IPP_GET_JOBS @@ -285,7 +291,11 @@ do_test(const char *server, /* I - Server to use */ * In addition, IPP_GET_JOBS needs a printer-uri attribute. */ - op = ops[i & 3]; + if (opstring) + op = ippOpValue(opstring); + else + op = ops[i % (int)(sizeof(ops) / sizeof(ops[0]))]; + request = ippNewRequest(op); gettimeofday(&start, NULL); @@ -307,8 +317,6 @@ do_test(const char *server, /* I - Server to use */ case IPP_PRINT_JOB : ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "ipp://localhost/printers/test"); - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until", - NULL, "indefinite"); ippDelete(cupsDoFileRequest(http, request, "/printers/test", "../data/testprint.ps")); break; @@ -358,13 +366,7 @@ do_test(const char *server, /* I - Server to use */ static void usage(void) { - puts("Usage: testspeed [-c children] [-h] [-r requests] [-v] [-E] " - "hostname[:port]"); + puts("Usage: testspeed [-c children] [-h] [-o operation] [-r requests] [-v] " + "[-E] hostname[:port]"); exit(0); } - - - -/* - * End of "$Id: testspeed.c 6649 2007-07-11 21:46:42Z mike $". - */