[cairo-commit] 3 commits - test/mime-unique-id.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 25 15:49:53 UTC 2021


 test/mime-unique-id.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

New commits:
commit f5a4ec8adabaa5429bc8fc2e98d4cdb314208969
Merge: 104dfd8b0 433d9eb10
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Mar 25 15:49:50 2021 +0000

    Merge branch 'mime-unique-id' into 'master'
    
    Fix the mime-unique-id test for me
    
    See merge request cairo/cairo!141

commit 433d9eb10937b2025c3dd2b63988bb01d470cc95
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Mar 8 16:30:33 2021 +0100

    Update the PDF size limit in mime-unique-id
    
    The test mime-unique-id checks that some images are only embedded once
    in a PDF. It does so by checking if the file size is within some
    expected bounds. However, the test fails for me because the file is too
    small. Yes, too *small*.
    
    Fix this by updating the test to expect my current file size.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/test/mime-unique-id.c b/test/mime-unique-id.c
index 81ab3f965..aab93164d 100755
--- a/test/mime-unique-id.c
+++ b/test/mime-unique-id.c
@@ -82,7 +82,7 @@
  */
 #define PS2_EXPECTED_SIZE 417510
 #define PS3_EXPECTED_SIZE 381554
-#define PDF_EXPECTED_SIZE 347182
+#define PDF_EXPECTED_SIZE 162923
 #define SIZE_TOLERANCE      5000
 
 static const char *png_filename = "romedalen.png";
commit 0fd2197e2b3e7deb1e5e1014e907dbeddac6f481
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Mar 8 16:28:51 2021 +0100

    test/mime-unique-id: Fix for out-of-tree builds
    
    Instead of failing because it did not find an image, this now fails for
    me since the PDF is too small (???).
    
    This new code is modelled after cairo_test_create_surface_from_png().
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/test/mime-unique-id.c b/test/mime-unique-id.c
index bdd056137..81ab3f965 100755
--- a/test/mime-unique-id.c
+++ b/test/mime-unique-id.c
@@ -48,6 +48,7 @@
 
 #include <math.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include <cairo.h>
 
@@ -87,6 +88,19 @@
 static const char *png_filename = "romedalen.png";
 static const char *jpeg_filename = "romedalen.jpg";
 
+static FILE *
+my_fopen (cairo_test_context_t *ctx, const char *pathname, const char *mode)
+{
+    FILE *f = fopen (pathname, mode);
+    if (f == NULL && errno == ENOENT && ctx->srcdir) {
+	char *srcdir_pathname;
+	xasprintf (&srcdir_pathname, "%s/%s", ctx->srcdir, pathname);
+	f = fopen (srcdir_pathname, mode);
+	free (srcdir_pathname);
+    }
+    return f;
+}
+
 static cairo_test_status_t
 create_image_surface (cairo_test_context_t *ctx, cairo_surface_t **surface)
 {
@@ -117,7 +131,7 @@ create_recording_surface_with_mime_jpg (cairo_test_context_t *ctx, cairo_surface
     cairo_rectangle_t extents = { 0, 0, 1, 1 };
 
     *surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, &extents);
-    f = fopen (jpeg_filename, "rb");
+    f = my_fopen (ctx, jpeg_filename, "rb");
     if (f == NULL) {
 	cairo_test_log (ctx, "Unable to open file %s\n", jpeg_filename);
 	return CAIRO_TEST_FAILURE;
@@ -372,7 +386,7 @@ check_file_size (cairo_test_context_t *ctx, const char *filename, long expected_
     FILE *f;
     long size;
 
-    f = fopen (filename, "rb");
+    f = my_fopen (ctx, filename, "rb");
     if (f == NULL) {
 	cairo_test_log (ctx, "Unable to open file %s\n", filename);
 	return CAIRO_TEST_FAILURE;


More information about the cairo-commit mailing list