]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add unit test that loops calling cupsGetDests.
authorMichael Sweet <michael.r.sweet@gmail.com>
Tue, 25 Jul 2017 22:18:14 +0000 (18:18 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Tue, 25 Jul 2017 22:18:14 +0000 (18:18 -0400)
cups/Makefile
cups/testgetdests.c [new file with mode: 0644]

index 94fed7a9f8178e87699929903875abd53910324f..96dd126722266d6d2c2945e840af9824430029f7 100644 (file)
@@ -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 (file)
index 0000000..b28578f
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include "cups.h"
+#include <sys/time.h>
+
+
+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);
+}