From: Michael Sweet Date: Tue, 25 Jul 2017 22:18:14 +0000 (-0400) Subject: Add unit test that loops calling cupsGetDests. X-Git-Tag: v2.2.5~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86390cbf5721be7e19fedec97c6f736d9b67342c;p=thirdparty%2Fcups.git Add unit test that loops calling cupsGetDests. --- diff --git a/cups/Makefile b/cups/Makefile index 94fed7a9f8..96dd126722 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -89,6 +89,7 @@ TESTOBJS = \ testcups.o \ testdest.o \ testfile.o \ + testgetdests.o \ testhttp.o \ testi18n.o \ testipp.o \ @@ -158,6 +159,7 @@ UNITTARGETS = \ testcups \ testdest \ testfile \ + testgetdests \ testhttp \ testi18n \ testipp \ @@ -461,6 +463,16 @@ testfile: testfile.o $(LIBCUPSSTATIC) ./testfile +# +# testgetdests (dependency on static CUPS library is intentional) +# + +testgetdests: testgetdests.o $(LIBCUPSSTATIC) + echo Linking $@... + $(LD_CC) $(LDFLAGS) -o $@ testgetdests.o $(LIBCUPSSTATIC) \ + $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ) + + # # testhttp (dependency on static CUPS library is intentional) # diff --git a/cups/testgetdests.c b/cups/testgetdests.c new file mode 100644 index 0000000000..b28578f207 --- /dev/null +++ b/cups/testgetdests.c @@ -0,0 +1,29 @@ +#include +#include "cups.h" +#include + + +int main(void) +{ + int num_dests; + cups_dest_t *dests; + struct timeval start, end; + double secs; + + do + { + 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); + } + } + while (num_dests > 0); + + return (0); +}