From 0bc1a539f4ff5c796b263df165d99322b938e8d1 Mon Sep 17 00:00:00 2001 From: Michael Sweet Date: Tue, 25 Jul 2017 18:26:20 -0400 Subject: [PATCH] Clean up unit test. --- cups/testgetdests.c | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/cups/testgetdests.c b/cups/testgetdests.c index b28578f20..459998f92 100644 --- a/cups/testgetdests.c +++ b/cups/testgetdests.c @@ -1,29 +1,51 @@ +/* + * CUPS cupsGetDests API test program for CUPS. + * + * Copyright 2017 by Apple Inc. + * + * 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 + * missing or damaged, see the license at "http://www.cups.org/". + * + * This file is subject to the Apple OS-Developed Software exception. + */ + +/* + * Include necessary headers... + */ + #include #include "cups.h" #include -int main(void) +/* + * 'main()' - Loop calling cupsGetDests. + */ + +int /* O - Exit status */ +main(void) { - int num_dests; - cups_dest_t *dests; - struct timeval start, end; - double secs; + int num_dests; /* Number of destinations */ + cups_dest_t *dests; /* Destinations */ + struct timeval start, end; /* Start and stop time */ + double secs; /* Total seconds to run cupsGetDests */ - do + + for (;;) { gettimeofday(&start, NULL); num_dests = cupsGetDests(&dests); gettimeofday(&end, NULL); secs = end.tv_sec - start.tv_sec + 0.000001 * (end.tv_usec - start.tv_usec); + printf("Found %d printers in %.3f seconds...\n", num_dests, secs); - if (num_dests > 0) - { - cupsFreeDests(num_dests, dests); - sleep(1); - } + + cupsFreeDests(num_dests, dests); + sleep(1); } - while (num_dests > 0); return (0); } -- 2.39.2