summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2020-11-06 16:31:11 +0000
committerRobin Watts <Robin.Watts@artifex.com>2020-11-07 10:50:48 +0000
commitabe5348a1de7793a5d4d6ecfa4d054e5f94731de (patch)
treedb644675e7cd0364674550b8adf75da81a8fb60e
parent2f6d9adb2e1cf6d7043c1de6168fee42dcb2cb8f (diff)
downloadghostpdl-abe5348a1de7793a5d4d6ecfa4d054e5f94731de.tar.gz
apitest: Hide pointer values in output.
This should enable the runtests values to be consistent.
-rw-r--r--demos/c/api_test.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/demos/c/api_test.c b/demos/c/api_test.c
index 181e34003..33f38b47a 100644
--- a/demos/c/api_test.c
+++ b/demos/c/api_test.c
@@ -5,6 +5,11 @@
#define _WINDOWS_
#endif
+/* We can't have pointers displayed in the test output, as that will
+ * change the output between runs. The following definition hides
+ * them. */
+#define HIDE_POINTERS
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -73,6 +78,37 @@ typedef struct {
const char *fname;
} teststate_t;
+/* Some funky code for hiding pointers */
+#ifdef HIDE_POINTERS
+#define MAX_POINTERS 16384
+void *hidden_pointers[MAX_POINTERS] = { NULL };
+int num_hidden_pointers = 1;
+
+void *hide_pointer(void *p)
+{
+ int i;
+
+ for (i = 0; i < num_hidden_pointers; i++)
+ if (hidden_pointers[i] == p)
+ return (void *)(intptr_t)i;
+
+ if (i == MAX_POINTERS)
+ return (void *)(intptr_t)i;
+
+ hidden_pointers[num_hidden_pointers++] = p;
+
+ return (void *)(intptr_t)i;
+}
+
+#define PTR(p) hide_pointer(p)
+
+#else
+
+#define PTR(p) p
+
+#endif
+
+
/*--------------------------------------------------------------------*/
/* First off, we have a set of functions that cope with dumping lines
* of rendered data to file. We use pnm formats for their simplicity. */
@@ -337,7 +373,7 @@ size(void *handle, void *device, int width, int height,
SANITY_CHECK(ts);
printf("size: w=%d h=%d r=%d f=%x m=%p\n",
- width, height, raster, format, pimage);
+ width, height, raster, format, PTR(pimage));
ts->w = width;
ts->h = height;
ts->r = raster;
@@ -430,7 +466,7 @@ memalloc(void *handle, void *device, size_t size)
}
ret = aligned_malloc(size, 64);
- printf("memalloc: %"FMT_Z" -> %p\n", Z_CAST size, ret);
+ printf("memalloc: %"FMT_Z" -> %p\n", Z_CAST size, PTR(ret));
return ret;
}
@@ -441,7 +477,7 @@ memfree(void *handle, void *device, void *mem)
teststate_t *ts = (teststate_t *)handle;
SANITY_CHECK(ts);
- printf("memfree: %p\n", mem);
+ printf("memfree: %p\n", PTR(mem));
aligned_free(mem);
return 0;
@@ -554,7 +590,7 @@ rectangle_request(void *handle, void *device,
ts->mem = aligned_malloc(size, 64);
*memory = ts->mem;
- printf("x=%d y=%d w=%d h=%d mem=%p\n", *x, *y, *w, *h, *memory);
+ printf("x=%d y=%d w=%d h=%d mem=%p\n", *x, *y, *w, *h, PTR(*memory));
if (ts->mem == NULL)
return -1;