libs: $(LIBTARGETS)
+#
+# Run unit tests...
+#
+
+test: unittests
+ echo "Tests started at $(date)..." >test.log
+ echo Running array API tests...
+ ./testarray >>test.log
+ echo Running file API tests...
+ ./testfile >>test.log
+ echo Running HTTP API tests...
+ ./testhttp >>test.log
+ echo Running IPP API tests...
+ ./testipp >>test.log
+ echo Running internationalization API tests...
+ ./testi18n >>test.log
+ echo Creating locale directory structure...
+ $(RM) -r locale
+ for po in ../locale/cups_*.po; do \
+ lang=`basename $$po .po | sed -e '1,$$s/^cups_//'`; \
+ $(MKDIR) locale/$$lang; \
+ $(LN) ../../$$po locale/$$lang; \
+ done
+ echo Running language API tests...
+ echo ls -al locale >>test.log
+ ls -al locale >>test.log
+ LOCALEDIR=locale ./testlang >>test.log
+ echo Running option API tests...
+ ./testoptions >>test.log
+ echo Running PPD API tests...
+ ./testppd >>test.log
+ echo Running PWG API tests...
+ ./testpwg test.ppd >>test.log
+ echo Running raster API tests...
+ ./testraster >>test.log
+# echo Fuzzing IPP API...
+# ./fuzzipp >>test.log
+ echo "Tests finished at $(date)..." >>test.log
+
+
#
# Make unit tests...
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ fuzzipp.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Fuzzing IPP API...
- ./fuzzipp
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testarray.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running array API tests...
- ./testarray
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testfile.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running file API tests...
- ./testfile
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testhttp.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running HTTP API tests...
- ./testhttp
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testipp.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running IPP API tests...
- ./testipp
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testi18n.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running internationalization API tests...
- ./testi18n
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testlang.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Creating locale directory structure...
- $(RM) -r locale
- for po in ../locale/cups_*.po; do \
- lang=`basename $$po .po | sed -e '1,$$s/^cups_//'`; \
- $(MKDIR) locale/$$lang; \
- $(LN) ../../$$po locale/$$lang; \
- done
- echo Running language API tests...
- echo ls -al locale
- ls -al locale
- LOCALEDIR=locale ./testlang
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testoptions.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running option API tests...
- ./testoptions
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testppd.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running PPD API tests...
- ./testppd
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testpwg.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running PWG API tests...
- ./testpwg test.ppd
#
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testraster.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running raster API tests...
- ./testraster
#
cupspm.xml \
array.[ch] auth.c cups.h dest*.c dir.[ch] encode.c file.[ch] \
http.h http*.c ipp.h ipp*.c options.c pwg.[ch] \
- raster.h raster-stubs.c tls-darwin.c usersys.c util.c \
+ raster.h raster-stubs.c string.c tempfile.c thread.[ch] tls.c tls-openssl.c usersys.c util.c \
--coverimage cupspm.png \
--epub ../doc/help/cupspm.epub
codedoc --section "Programming" --body cupspm.md \
-/*
- * CUPS cupsGetDests API test program for CUPS.
- *
- * Copyright 2017 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// CUPS cupsGetDests API test program for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2017 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#include <stdio.h>
-#include "cups.h"
+#include <stdlib.h>
#include <sys/time.h>
+#include "cups.h"
+#include "test-internal.h"
-/*
- * 'main()' - Loop calling cupsGetDests.
- */
+//
+// 'main()' - Loop calling cupsGetDests.
+//
-int /* O - Exit status */
-main(void)
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- 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 */
+ size_t count = 1; // Number of times
+ size_t 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
+
+
+ // Parse command-line...
+ if (argc > 2 || (argc == 2 && (argv[1][0] < '1' || argv[1][0] > '9')))
+ {
+ fputs("Usage: ./testgetdests [COUNT]\n", stderr);
+ return (1);
+ }
+ if (argc == 2)
+ count = strtoul(argv[1], NULL, 10);
+ else
+ count = 5;
- for (;;)
+ // Run tests...
+ while (count > 0)
{
+ testBegin("cupsGetDests");
gettimeofday(&start, NULL);
- num_dests = cupsGetDests(&dests);
+ num_dests = cupsGetDests2(CUPS_HTTP_DEFAULT, &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 (cupsGetError() != IPP_STATUS_OK)
+ testEndMessage(false, "%s", cupsGetErrorString());
+ else
+ testEndMessage(secs < 2.0, "%u printers in %.3f seconds", (unsigned)num_dests, secs);
cupsFreeDests(num_dests, dests);
- sleep(1);
+
+ count --;
+
+ if (count > 0)
+ sleep(1);
}
- return (0);
+ return (testsPassed ? 0 : 1);
}