From 3d1b3d429e24e8b9014f25010d88a8decf66c633 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 21 Oct 2024 12:35:31 -0400 Subject: [PATCH] Fix bug introduced in cupsRasterReadHeader* - was always returning 0. Add a raster error for I/O errors. Migrate testraster to the test-internal.h framework. --- cups/raster-stream.c | 9 +- cups/testraster.c | 419 +++++++++++++++++++------------------------ 2 files changed, 184 insertions(+), 244 deletions(-) diff --git a/cups/raster-stream.c b/cups/raster-stream.c index e2cf44bd0f..1a17b048b4 100644 --- a/cups/raster-stream.c +++ b/cups/raster-stream.c @@ -1017,7 +1017,7 @@ _cupsRasterReadHeader( DEBUG_printf("4_cupsRasterReadHeader: cupsHeight=%u", r->header.cupsHeight); DEBUG_printf("4_cupsRasterReadHeader: r->bpp=%d", r->bpp); - return (0); + return (1); } @@ -1561,13 +1561,12 @@ cups_raster_io(cups_raster_t *r, // I - Raster stream DEBUG_printf("6cups_raster_io: count=%d, total=%d", (int)count, (int)total); if (count == 0) + { break; -// { -// DEBUG_puts("6cups_raster_io: Returning 0."); -// return (0); -// } + } else if (count < 0) { + _cupsRasterAddError("I/O error"); DEBUG_puts("6cups_raster_io: Returning -1 on error."); return (-1); } diff --git a/cups/testraster.c b/cups/testraster.c index 5490c0f2f3..6de71089a7 100644 --- a/cups/testraster.c +++ b/cups/testraster.c @@ -1,40 +1,37 @@ -/* - * Raster test program routines for CUPS. - * - * Copyright © 2020-2024 by OpenPrinting. - * Copyright © 2007-2019 by Apple Inc. - * Copyright © 1997-2007 by Easy Software Products. - * - * Licensed under Apache License v2.0. See the file "LICENSE" for more - * information. - */ - -/* - * Include necessary headers... - */ - -#include +// +// Raster test program routines for CUPS. +// +// Copyright © 2020-2024 by OpenPrinting. +// Copyright © 2007-2019 by Apple Inc. +// Copyright © 1997-2007 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +#include "raster-private.h" +#include "test-internal.h" #include -/* - * Local functions... - */ +// +// Local functions... +// static int do_ras_file(const char *filename); static int do_raster_tests(cups_mode_t mode); static void print_changes(cups_page_header2_t *header, cups_page_header2_t *expected); -/* - * 'main()' - Test the raster functions. - */ +// +// 'main()' - Test the raster functions. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { - int errors = 0; /* Number of errors */ + int errors = 0; // Number of errors if (argc == 1) @@ -46,7 +43,7 @@ main(int argc, /* I - Number of command-line args */ } else { - int i; /* Looping var */ + int i; // Looping var for (i = 1; i < argc; i ++) errors += do_ras_file(argv[i]); @@ -56,20 +53,20 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'do_ras_file()' - Test reading of a raster file. - */ +// +// 'do_ras_file()' - Test reading of a raster file. +// -static int /* O - Number of errors */ -do_ras_file(const char *filename) /* I - Filename */ +static int // O - Number of errors +do_ras_file(const char *filename) // I - Filename { - unsigned y; /* Looping vars */ - int fd; /* File descriptor */ - cups_raster_t *ras; /* Raster stream */ - cups_page_header2_t header; /* Page header */ - unsigned char *data; /* Raster data */ - int errors = 0; /* Number of errors */ - unsigned pages = 0; /* Number of pages */ + unsigned y; // Looping vars + int fd; // File descriptor + cups_raster_t *ras; // Raster stream + cups_page_header2_t header; // Page header + unsigned char *data; // Raster data + int errors = 0; // Number of errors + unsigned pages = 0; // Number of pages if ((fd = open(filename, O_RDONLY)) < 0) @@ -95,7 +92,6 @@ do_ras_file(const char *filename) /* I - Filename */ printf(" Page %u: %ux%ux%u@%ux%udpi", pages, header.cupsWidth, header.cupsHeight, header.cupsBitsPerPixel, header.HWResolution[0], header.HWResolution[1]); - fflush(stdout); for (y = 0; y < header.cupsHeight; y ++) if (cupsRasterReadPixels(ras, data, header.cupsBytesPerLine) < @@ -119,47 +115,50 @@ do_ras_file(const char *filename) /* I - Filename */ } -/* - * 'do_raster_tests()' - Test reading and writing of raster data. - */ +// +// 'do_raster_tests()' - Test reading and writing of raster data. +// -static int /* O - Number of errors */ -do_raster_tests(cups_mode_t mode) /* O - Write mode */ +static int // O - Number of errors +do_raster_tests(cups_mode_t mode) // O - Write mode { - unsigned page, x, y, count;/* Looping vars */ - FILE *fp; /* Raster file */ - cups_raster_t *r; /* Raster stream */ - cups_page_header2_t header, /* Page header */ - expected; /* Expected page header */ - unsigned char data[2048]; /* Raster data */ - int errors = 0; /* Number of errors */ + unsigned page, x, y, count;// Looping vars + FILE *fp; // Raster file + cups_raster_t *r; // Raster stream + cups_page_header2_t header, // Page header + expected; // Expected page header + unsigned char data[2048]; // Raster data + int errors = 0; // Number of errors + static const char * const modes[] = // Open modes + { + "CUPS_RASTER_READ", + "CUPS_RASTER_WRITE", + "CUPS_RASTER_WRITE_COMPRESSED", + "CUPS_RASTER_WRITE_PWG", + "CUPS_RASTER_WRITE_APPLE" + }; /* * Test writing... */ - printf("cupsRasterOpen(%s): ", - mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE" : - mode == CUPS_RASTER_WRITE_COMPRESSED ? "CUPS_RASTER_WRITE_COMPRESSED" : - mode == CUPS_RASTER_WRITE_PWG ? "CUPS_RASTER_WRITE_PWG" : - "CUPS_RASTER_WRITE_APPLE"); - fflush(stdout); + testBegin("cupsRasterOpen(%s)", modes[mode]); if ((fp = fopen("test.raster", "wb")) == NULL) { - printf("FAIL (%s)\n", strerror(errno)); + testEndMessage(false, "%s", strerror(errno)); return (1); } if ((r = cupsRasterOpen(fileno(fp), mode)) == NULL) { - printf("FAIL (%s)\n", strerror(errno)); + testEndMessage(false, "%s", cupsRasterGetErrorString()); fclose(fp); return (1); } - puts("PASS"); + testEnd(true); for (page = 0; page < 4; page ++) { @@ -202,29 +201,30 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ header.cupsBitsPerPixel = (page & 1) ? 32 : 8; } - printf("cupsRasterWriteHeader2(page %d): ", page + 1); + testBegin("cupsRasterWriteHeader2(page %d)", page + 1); if (cupsRasterWriteHeader2(r, &header)) { - puts("PASS"); + testEnd(true); } else { - puts("FAIL"); + testEnd(false); errors ++; } - fputs("cupsRasterWritePixels: ", stdout); - fflush(stdout); + testBegin("cupsRasterWritePixels"); memset(data, 0, header.cupsBytesPerLine); for (y = 0; y < 64; y ++) + { if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) break; + } if (y < 64) { - puts("FAIL"); + testEnd(false); errors ++; } else @@ -233,24 +233,28 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ data[x] = (unsigned char)x; for (y = 0; y < 64; y ++) + { if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) break; + } if (y < 64) { - puts("FAIL"); + testEnd(false); errors ++; } else { memset(data, 255, header.cupsBytesPerLine); for (y = 0; y < 64; y ++) + { if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) break; + } if (y < 64) { - puts("FAIL"); + testEnd(false); errors ++; } else @@ -259,16 +263,18 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ data[x] = (unsigned char)(x / 4); for (y = 0; y < 64; y ++) + { if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) break; + } if (y < 64) { - puts("FAIL"); + testEnd(false); errors ++; } else - puts("PASS"); + testEnd(true); } } } @@ -281,23 +287,22 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ * Test reading... */ - fputs("cupsRasterOpen(CUPS_RASTER_READ): ", stdout); - fflush(stdout); + testBegin("cupsRasterOpen(CUPS_RASTER_READ)"); if ((fp = fopen("test.raster", "rb")) == NULL) { - printf("FAIL (%s)\n", strerror(errno)); + testEndMessage(false, "%s", strerror(errno)); return (1); } if ((r = cupsRasterOpen(fileno(fp), CUPS_RASTER_READ)) == NULL) { - printf("FAIL (%s)\n", strerror(errno)); + testEndMessage(false, "%s", cupsRasterGetErrorString()); fclose(fp); return (1); } - puts("PASS"); + testEnd(true); for (page = 0; page < 4; page ++) { @@ -350,39 +355,39 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ expected.cupsBitsPerPixel = (page & 1) ? 32 : 8; } - printf("cupsRasterReadHeader2(page %d): ", page + 1); - fflush(stdout); + testBegin("cupsRasterReadHeader2(page %d)", page + 1); if (!cupsRasterReadHeader2(r, &header)) { - puts("FAIL (read error)"); + testEndMessage(false, "%s", cupsRasterGetErrorString()); errors ++; break; } else if (memcmp(&header, &expected, sizeof(header))) { - puts("FAIL (bad page header)"); + testEndMessage(false, "bad page header"); errors ++; print_changes(&header, &expected); } else - puts("PASS"); + { + testEnd(true); + } - fputs("cupsRasterReadPixels: ", stdout); - fflush(stdout); + testBegin("cupsRasterReadPixels"); for (y = 0; y < 64; y ++) { if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) { - puts("FAIL (read error)"); + testEndMessage(false, "%s", cupsRasterGetErrorString()); errors ++; break; } if (data[0] != 0 || memcmp(data, data + 1, header.cupsBytesPerLine - 1)) { - printf("FAIL (raster line %d corrupt)\n", y); + testEndMessage(false, "raster line %d corrupt", y); for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) { @@ -391,9 +396,9 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ count ++; if (count == 10) - puts(" ..."); + testMessage(" ..."); else - printf(" %4u %02X (expected %02X)\n", x, data[x], 0); + testMessage(" %4u %02X (expected %02X)", x, data[x], 0); } } @@ -408,18 +413,20 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ { if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) { - puts("FAIL (read error)"); + testEndMessage(false, "%s", cupsRasterGetErrorString()); errors ++; break; } for (x = 0; x < header.cupsBytesPerLine; x ++) + { if (data[x] != (x & 255)) break; + } if (x < header.cupsBytesPerLine) { - printf("FAIL (raster line %d corrupt)\n", y + 64); + testEndMessage(false, "raster line %d corrupt", y + 64); for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) { @@ -428,9 +435,9 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ count ++; if (count == 10) - puts(" ..."); + testMessage(" ..."); else - printf(" %4u %02X (expected %02X)\n", x, data[x], x & 255); + testMessage(" %4u %02X (expected %02X)", x, data[x], x & 255); } } @@ -445,14 +452,14 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ { if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) { - puts("FAIL (read error)"); + testEndMessage(false, "%s", cupsRasterGetErrorString()); errors ++; break; } if (data[0] != 255 || memcmp(data, data + 1, header.cupsBytesPerLine - 1)) { - printf("fail (raster line %d corrupt)\n", y + 128); + testEndMessage(false, "raster line %d corrupt", y + 128); for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) { @@ -461,9 +468,9 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ count ++; if (count == 10) - puts(" ..."); + testMessage(" ..."); else - printf(" %4u %02X (expected %02X)\n", x, data[x], 255); + testMessage(" %4u %02X (expected %02X)", x, data[x], 255); } } @@ -478,18 +485,20 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ { if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) { - puts("FAIL (read error)"); + testEndMessage(false, "%s", cupsRasterGetErrorString()); errors ++; break; } for (x = 0; x < header.cupsBytesPerLine; x ++) + { if (data[x] != ((x / 4) & 255)) break; + } if (x < header.cupsBytesPerLine) { - printf("FAIL (raster line %d corrupt)\n", y + 192); + testEndMessage(false, "raster line %d corrupt", y + 192); for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) { @@ -498,9 +507,9 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ count ++; if (count == 10) - puts(" ..."); + testMessage(" ..."); else - printf(" %4u %02X (expected %02X)\n", x, data[x], (x / 4) & 255); + testMessage(" %4u %02X (expected %02X)", x, data[x], (x / 4) & 255); } } @@ -510,7 +519,7 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ } if (y == 64) - puts("PASS"); + testEnd(true); } } } @@ -523,239 +532,171 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ } -/* - * 'print_changes()' - Print differences in the page header. - */ +// +// 'print_changes()' - Print differences in the page header. +// static void print_changes( - cups_page_header2_t *header, /* I - Actual page header */ - cups_page_header2_t *expected) /* I - Expected page header */ + cups_page_header2_t *header, // I - Actual page header + cups_page_header2_t *expected) // I - Expected page header { - int i; /* Looping var */ + int i; // Looping var if (strcmp(header->MediaClass, expected->MediaClass)) - printf(" MediaClass (%s), expected (%s)\n", header->MediaClass, - expected->MediaClass); + testMessage(" MediaClass (%s), expected (%s)", header->MediaClass, expected->MediaClass); if (strcmp(header->MediaColor, expected->MediaColor)) - printf(" MediaColor (%s), expected (%s)\n", header->MediaColor, - expected->MediaColor); + testMessage(" MediaColor (%s), expected (%s)", header->MediaColor, expected->MediaColor); if (strcmp(header->MediaType, expected->MediaType)) - printf(" MediaType (%s), expected (%s)\n", header->MediaType, - expected->MediaType); + testMessage(" MediaType (%s), expected (%s)", header->MediaType, expected->MediaType); if (strcmp(header->OutputType, expected->OutputType)) - printf(" OutputType (%s), expected (%s)\n", header->OutputType, - expected->OutputType); + testMessage(" OutputType (%s), expected (%s)", header->OutputType, expected->OutputType); if (header->AdvanceDistance != expected->AdvanceDistance) - printf(" AdvanceDistance %d, expected %d\n", header->AdvanceDistance, - expected->AdvanceDistance); + testMessage(" AdvanceDistance %d, expected %d", header->AdvanceDistance, expected->AdvanceDistance); if (header->AdvanceMedia != expected->AdvanceMedia) - printf(" AdvanceMedia %d, expected %d\n", header->AdvanceMedia, - expected->AdvanceMedia); + testMessage(" AdvanceMedia %d, expected %d", header->AdvanceMedia, expected->AdvanceMedia); if (header->Collate != expected->Collate) - printf(" Collate %d, expected %d\n", header->Collate, - expected->Collate); + testMessage(" Collate %d, expected %d", header->Collate, expected->Collate); if (header->CutMedia != expected->CutMedia) - printf(" CutMedia %d, expected %d\n", header->CutMedia, - expected->CutMedia); + testMessage(" CutMedia %d, expected %d", header->CutMedia, expected->CutMedia); if (header->Duplex != expected->Duplex) - printf(" Duplex %d, expected %d\n", header->Duplex, - expected->Duplex); - - if (header->HWResolution[0] != expected->HWResolution[0] || - header->HWResolution[1] != expected->HWResolution[1]) - printf(" HWResolution [%d %d], expected [%d %d]\n", - header->HWResolution[0], header->HWResolution[1], - expected->HWResolution[0], expected->HWResolution[1]); - - if (memcmp(header->ImagingBoundingBox, expected->ImagingBoundingBox, - sizeof(header->ImagingBoundingBox))) - printf(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]\n", - header->ImagingBoundingBox[0], - header->ImagingBoundingBox[1], - header->ImagingBoundingBox[2], - header->ImagingBoundingBox[3], - expected->ImagingBoundingBox[0], - expected->ImagingBoundingBox[1], - expected->ImagingBoundingBox[2], - expected->ImagingBoundingBox[3]); + testMessage(" Duplex %d, expected %d", header->Duplex, expected->Duplex); + + if (header->HWResolution[0] != expected->HWResolution[0] || header->HWResolution[1] != expected->HWResolution[1]) + testMessage(" HWResolution [%d %d], expected [%d %d]", header->HWResolution[0], header->HWResolution[1], expected->HWResolution[0], expected->HWResolution[1]); + + if (memcmp(header->ImagingBoundingBox, expected->ImagingBoundingBox, sizeof(header->ImagingBoundingBox))) + testMessage(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]", header->ImagingBoundingBox[0], header->ImagingBoundingBox[1], header->ImagingBoundingBox[2], header->ImagingBoundingBox[3], expected->ImagingBoundingBox[0], expected->ImagingBoundingBox[1], expected->ImagingBoundingBox[2], expected->ImagingBoundingBox[3]); if (header->InsertSheet != expected->InsertSheet) - printf(" InsertSheet %d, expected %d\n", header->InsertSheet, - expected->InsertSheet); + testMessage(" InsertSheet %d, expected %d", header->InsertSheet, expected->InsertSheet); if (header->Jog != expected->Jog) - printf(" Jog %d, expected %d\n", header->Jog, - expected->Jog); + testMessage(" Jog %d, expected %d", header->Jog, expected->Jog); if (header->LeadingEdge != expected->LeadingEdge) - printf(" LeadingEdge %d, expected %d\n", header->LeadingEdge, - expected->LeadingEdge); + testMessage(" LeadingEdge %d, expected %d", header->LeadingEdge, expected->LeadingEdge); - if (header->Margins[0] != expected->Margins[0] || - header->Margins[1] != expected->Margins[1]) - printf(" Margins [%d %d], expected [%d %d]\n", - header->Margins[0], header->Margins[1], - expected->Margins[0], expected->Margins[1]); + if (header->Margins[0] != expected->Margins[0] || header->Margins[1] != expected->Margins[1]) + testMessage(" Margins [%d %d], expected [%d %d]", header->Margins[0], header->Margins[1], expected->Margins[0], expected->Margins[1]); if (header->ManualFeed != expected->ManualFeed) - printf(" ManualFeed %d, expected %d\n", header->ManualFeed, - expected->ManualFeed); + testMessage(" ManualFeed %d, expected %d", header->ManualFeed, expected->ManualFeed); if (header->MediaPosition != expected->MediaPosition) - printf(" MediaPosition %d, expected %d\n", header->MediaPosition, - expected->MediaPosition); + testMessage(" MediaPosition %d, expected %d", header->MediaPosition, expected->MediaPosition); if (header->MediaWeight != expected->MediaWeight) - printf(" MediaWeight %d, expected %d\n", header->MediaWeight, - expected->MediaWeight); + testMessage(" MediaWeight %d, expected %d", header->MediaWeight, expected->MediaWeight); if (header->MirrorPrint != expected->MirrorPrint) - printf(" MirrorPrint %d, expected %d\n", header->MirrorPrint, - expected->MirrorPrint); + testMessage(" MirrorPrint %d, expected %d", header->MirrorPrint, expected->MirrorPrint); if (header->NegativePrint != expected->NegativePrint) - printf(" NegativePrint %d, expected %d\n", header->NegativePrint, - expected->NegativePrint); + testMessage(" NegativePrint %d, expected %d", header->NegativePrint, expected->NegativePrint); if (header->NumCopies != expected->NumCopies) - printf(" NumCopies %d, expected %d\n", header->NumCopies, - expected->NumCopies); + testMessage(" NumCopies %d, expected %d", header->NumCopies, expected->NumCopies); if (header->Orientation != expected->Orientation) - printf(" Orientation %d, expected %d\n", header->Orientation, - expected->Orientation); + testMessage(" Orientation %d, expected %d", header->Orientation, expected->Orientation); if (header->OutputFaceUp != expected->OutputFaceUp) - printf(" OutputFaceUp %d, expected %d\n", header->OutputFaceUp, - expected->OutputFaceUp); + testMessage(" OutputFaceUp %d, expected %d", header->OutputFaceUp, expected->OutputFaceUp); - if (header->PageSize[0] != expected->PageSize[0] || - header->PageSize[1] != expected->PageSize[1]) - printf(" PageSize [%d %d], expected [%d %d]\n", - header->PageSize[0], header->PageSize[1], - expected->PageSize[0], expected->PageSize[1]); + if (header->PageSize[0] != expected->PageSize[0] || header->PageSize[1] != expected->PageSize[1]) + testMessage(" PageSize [%d %d], expected [%d %d]", header->PageSize[0], header->PageSize[1], expected->PageSize[0], expected->PageSize[1]); if (header->Separations != expected->Separations) - printf(" Separations %d, expected %d\n", header->Separations, - expected->Separations); + testMessage(" Separations %d, expected %d", header->Separations, expected->Separations); if (header->TraySwitch != expected->TraySwitch) - printf(" TraySwitch %d, expected %d\n", header->TraySwitch, - expected->TraySwitch); + testMessage(" TraySwitch %d, expected %d", header->TraySwitch, expected->TraySwitch); if (header->Tumble != expected->Tumble) - printf(" Tumble %d, expected %d\n", header->Tumble, - expected->Tumble); + testMessage(" Tumble %d, expected %d", header->Tumble, expected->Tumble); if (header->cupsWidth != expected->cupsWidth) - printf(" cupsWidth %d, expected %d\n", header->cupsWidth, - expected->cupsWidth); + testMessage(" cupsWidth %d, expected %d", header->cupsWidth, expected->cupsWidth); if (header->cupsHeight != expected->cupsHeight) - printf(" cupsHeight %d, expected %d\n", header->cupsHeight, - expected->cupsHeight); + testMessage(" cupsHeight %d, expected %d", header->cupsHeight, expected->cupsHeight); if (header->cupsMediaType != expected->cupsMediaType) - printf(" cupsMediaType %d, expected %d\n", header->cupsMediaType, - expected->cupsMediaType); + testMessage(" cupsMediaType %d, expected %d", header->cupsMediaType, expected->cupsMediaType); if (header->cupsBitsPerColor != expected->cupsBitsPerColor) - printf(" cupsBitsPerColor %d, expected %d\n", header->cupsBitsPerColor, - expected->cupsBitsPerColor); + testMessage(" cupsBitsPerColor %d, expected %d", header->cupsBitsPerColor, expected->cupsBitsPerColor); if (header->cupsBitsPerPixel != expected->cupsBitsPerPixel) - printf(" cupsBitsPerPixel %d, expected %d\n", header->cupsBitsPerPixel, - expected->cupsBitsPerPixel); + testMessage(" cupsBitsPerPixel %d, expected %d", header->cupsBitsPerPixel, expected->cupsBitsPerPixel); if (header->cupsBytesPerLine != expected->cupsBytesPerLine) - printf(" cupsBytesPerLine %d, expected %d\n", header->cupsBytesPerLine, - expected->cupsBytesPerLine); + testMessage(" cupsBytesPerLine %d, expected %d", header->cupsBytesPerLine, expected->cupsBytesPerLine); if (header->cupsColorOrder != expected->cupsColorOrder) - printf(" cupsColorOrder %d, expected %d\n", header->cupsColorOrder, - expected->cupsColorOrder); + testMessage(" cupsColorOrder %d, expected %d", header->cupsColorOrder, expected->cupsColorOrder); if (header->cupsColorSpace != expected->cupsColorSpace) - printf(" cupsColorSpace %d, expected %d\n", header->cupsColorSpace, - expected->cupsColorSpace); + testMessage(" cupsColorSpace %d, expected %d", header->cupsColorSpace, expected->cupsColorSpace); if (header->cupsCompression != expected->cupsCompression) - printf(" cupsCompression %d, expected %d\n", header->cupsCompression, - expected->cupsCompression); + testMessage(" cupsCompression %d, expected %d", header->cupsCompression, expected->cupsCompression); if (header->cupsRowCount != expected->cupsRowCount) - printf(" cupsRowCount %d, expected %d\n", header->cupsRowCount, - expected->cupsRowCount); + testMessage(" cupsRowCount %d, expected %d", header->cupsRowCount, expected->cupsRowCount); if (header->cupsRowFeed != expected->cupsRowFeed) - printf(" cupsRowFeed %d, expected %d\n", header->cupsRowFeed, - expected->cupsRowFeed); + testMessage(" cupsRowFeed %d, expected %d", header->cupsRowFeed, expected->cupsRowFeed); if (header->cupsRowStep != expected->cupsRowStep) - printf(" cupsRowStep %d, expected %d\n", header->cupsRowStep, - expected->cupsRowStep); + testMessage(" cupsRowStep %d, expected %d", header->cupsRowStep, expected->cupsRowStep); if (header->cupsNumColors != expected->cupsNumColors) - printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors, - expected->cupsNumColors); + testMessage(" cupsNumColors %d, expected %d", header->cupsNumColors, expected->cupsNumColors); if (fabs(header->cupsBorderlessScalingFactor - expected->cupsBorderlessScalingFactor) > 0.001) - printf(" cupsBorderlessScalingFactor %g, expected %g\n", - header->cupsBorderlessScalingFactor, - expected->cupsBorderlessScalingFactor); - - if (fabs(header->cupsPageSize[0] - expected->cupsPageSize[0]) > 0.001 || - fabs(header->cupsPageSize[1] - expected->cupsPageSize[1]) > 0.001) - printf(" cupsPageSize [%g %g], expected [%g %g]\n", - header->cupsPageSize[0], header->cupsPageSize[1], - expected->cupsPageSize[0], expected->cupsPageSize[1]); - - if (fabs(header->cupsImagingBBox[0] - expected->cupsImagingBBox[0]) > 0.001 || - fabs(header->cupsImagingBBox[1] - expected->cupsImagingBBox[1]) > 0.001 || - fabs(header->cupsImagingBBox[2] - expected->cupsImagingBBox[2]) > 0.001 || - fabs(header->cupsImagingBBox[3] - expected->cupsImagingBBox[3]) > 0.001) - printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n", - header->cupsImagingBBox[0], header->cupsImagingBBox[1], - header->cupsImagingBBox[2], header->cupsImagingBBox[3], - expected->cupsImagingBBox[0], expected->cupsImagingBBox[1], - expected->cupsImagingBBox[2], expected->cupsImagingBBox[3]); + testMessage(" cupsBorderlessScalingFactor %g, expected %g", header->cupsBorderlessScalingFactor, expected->cupsBorderlessScalingFactor); + + if (fabs(header->cupsPageSize[0] - expected->cupsPageSize[0]) > 0.001 || fabs(header->cupsPageSize[1] - expected->cupsPageSize[1]) > 0.001) + testMessage(" cupsPageSize [%g %g], expected [%g %g]", header->cupsPageSize[0], header->cupsPageSize[1], expected->cupsPageSize[0], expected->cupsPageSize[1]); + + if (fabs(header->cupsImagingBBox[0] - expected->cupsImagingBBox[0]) > 0.001 || fabs(header->cupsImagingBBox[1] - expected->cupsImagingBBox[1]) > 0.001 || fabs(header->cupsImagingBBox[2] - expected->cupsImagingBBox[2]) > 0.001 || fabs(header->cupsImagingBBox[3] - expected->cupsImagingBBox[3]) > 0.001) + testMessage(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]", header->cupsImagingBBox[0], header->cupsImagingBBox[1], header->cupsImagingBBox[2], header->cupsImagingBBox[3], expected->cupsImagingBBox[0], expected->cupsImagingBBox[1], expected->cupsImagingBBox[2], expected->cupsImagingBBox[3]); for (i = 0; i < 16; i ++) + { if (header->cupsInteger[i] != expected->cupsInteger[i]) - printf(" cupsInteger%d %d, expected %d\n", i, header->cupsInteger[i], - expected->cupsInteger[i]); + testMessage(" cupsInteger%d %d, expected %d", i, header->cupsInteger[i], expected->cupsInteger[i]); + } for (i = 0; i < 16; i ++) + { if (fabs(header->cupsReal[i] - expected->cupsReal[i]) > 0.001) - printf(" cupsReal%d %g, expected %g\n", i, header->cupsReal[i], - expected->cupsReal[i]); + testMessage(" cupsReal%d %g, expected %g", i, header->cupsReal[i], expected->cupsReal[i]); + } for (i = 0; i < 16; i ++) + { if (strcmp(header->cupsString[i], expected->cupsString[i])) - printf(" cupsString%d (%s), expected (%s)\n", i, - header->cupsString[i], expected->cupsString[i]); + testMessage(" cupsString%d (%s), expected (%s)", i, header->cupsString[i], expected->cupsString[i]); + } if (strcmp(header->cupsMarkerType, expected->cupsMarkerType)) - printf(" cupsMarkerType (%s), expected (%s)\n", header->cupsMarkerType, - expected->cupsMarkerType); + testMessage(" cupsMarkerType (%s), expected (%s)", header->cupsMarkerType, expected->cupsMarkerType); if (strcmp(header->cupsRenderingIntent, expected->cupsRenderingIntent)) - printf(" cupsRenderingIntent (%s), expected (%s)\n", - header->cupsRenderingIntent, - expected->cupsRenderingIntent); + testMessage(" cupsRenderingIntent (%s), expected (%s)", header->cupsRenderingIntent, expected->cupsRenderingIntent); if (strcmp(header->cupsPageSizeName, expected->cupsPageSizeName)) - printf(" cupsPageSizeName (%s), expected (%s)\n", - header->cupsPageSizeName, - expected->cupsPageSizeName); + testMessage(" cupsPageSizeName (%s), expected (%s)", header->cupsPageSizeName, expected->cupsPageSizeName); }