Gitweb links:
...log
http://git.netsurf-browser.org/librufl.git/shortlog/a1735a1171f484e9828029576c99cff12448060f
...commit
http://git.netsurf-browser.org/librufl.git/commit/a1735a1171f484e9828029576c99cff12448060f
...tree
http://git.netsurf-browser.org/librufl.git/tree/a1735a1171f484e9828029576c99cff12448060f
The branch, jmb/ac has been updated
via a1735a1171f484e9828029576c99cff12448060f (commit)
via 06fae32a7ae53ad113376befbc78414374f9326b (commit)
via deb692c00afecca0d73394feef6e99e51606b9b4 (commit)
via ce3664d296b9b2459c4251321cb3f90adc32972d (commit)
via 0358488cc592f217158a8c4ea9adacf652ee85ce (commit)
from d4468833b85b8c8f340bc9c3bb6572a245fd5982 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=a1735a1171f484e9828029576c99cff12448060f
commit a1735a1171f484e9828029576c99cff12448060f
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Introduce test infrastructure
Mock out every OS call made by the library (they all return an
unimplemented error for the timebeing). Add a trivial test case
that verifies that rufl_init() fails.
diff --git a/Makefile b/Makefile
index 1653ee9..bfaf61e 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ PREFIX ?= /opt/netsurf
NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem
include $(NSSHARED)/makefiles/Makefile.tools
-TESTRUNNER := $(ECHO)
+TESTRUNNER := $(PERL) $(NSTESTTOOLS)/testrunner.pl
# Toolchain flags
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
diff --git a/test/INDEX b/test/INDEX
new file mode 100644
index 0000000..bd46e96
--- /dev/null
+++ b/test/INDEX
@@ -0,0 +1,4 @@
+# Index for testcases
+#
+# Test Description DataDir
+simple Trivial test to prove harness works
diff --git a/test/Makefile b/test/Makefile
index 2bfa58b..1ce2936 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,10 @@
# Tests
-DIR_TEST_ITEMS := rufl_test:rufl_test.c rufl_chars:rufl_chars.c
+DIR_TEST_ITEMS := simple:simple.c;mocks.c
+
+ifeq ($(HOST),arm-unknown-riscos)
+ DIR_TEST_ITEMS := $(DIR_TEST_ITEMS) \
+ rufl_test:rufl_test.c \
+ rufl_chars:rufl_chars.c
+endif
include $(NSBUILD)/Makefile.subdir
diff --git a/test/mocks.c b/test/mocks.c
new file mode 100644
index 0000000..28cdf41
--- /dev/null
+++ b/test/mocks.c
@@ -0,0 +1,304 @@
+#include <oslib/font.h>
+#include <oslib/hourglass.h>
+#include <oslib/os.h>
+#include <oslib/osfscontrol.h>
+#include <oslib/taskwindow.h>
+#include <oslib/wimp.h>
+#include <oslib/wimpreadsysinfo.h>
+
+static os_error unimplemented = { error_UNIMPLEMENTED, "Not implemented" };
+
+/****************************************************************************/
+
+os_error *xfont_cache_addr (int *version, int *cache_size, int *cache_used)
+{
+ (void) version;
+ (void) cache_size;
+ (void) cache_used;
+
+ return &unimplemented;
+}
+
+os_error *xfont_find_font (char const *font_name, int xsize, int ysize,
+ int xres, int yres, font_f *font, int *xres_out, int *yres_out)
+{
+ (void) font_name;
+ (void) xsize;
+ (void) ysize;
+ (void) xres;
+ (void) yres;
+ (void) font;
+ (void) xres_out;
+ (void) yres_out;
+
+ return &unimplemented;
+}
+
+os_error *xfont_lose_font (font_f font)
+{
+ (void) font;
+
+ return &unimplemented;
+}
+
+os_error *xfont_read_info (font_f font, int *x0, int *y0, int *x1, int *y1)
+{
+ (void) font;
+ (void) x0;
+ (void) y0;
+ (void) x1;
+ (void) y1;
+
+ return &unimplemented;
+}
+
+os_error *xfont_read_encoding_filename (font_f font, char *buffer, int size,
+ char **end)
+{
+ (void) font;
+ (void) buffer;
+ (void) size;
+ (void) end;
+
+ return &unimplemented;
+}
+
+os_error *xfont_list_fonts (byte *buffer1, font_list_context context,
+ int size1, byte *buffer2, int size2, char const *tick_font,
+ font_list_context *context_out, int *used1, int *used2)
+{
+ (void) buffer1;
+ (void) context;
+ (void) size1;
+ (void) buffer2;
+ (void) size2;
+ (void) tick_font;
+ (void) context_out;
+ (void) used1;
+ (void) used2;
+
+ return &unimplemented;
+}
+
+os_error *xfont_set_font (font_f font)
+{
+ (void) font;
+
+ return &unimplemented;
+}
+
+os_error *xfont_paint (font_f font, char const *string,
+ font_string_flags flags, int xpos, int ypos,
+ font_paint_block const *block, os_trfm const *trfm, int length)
+{
+ (void) font;
+ (void) string;
+ (void) flags;
+ (void) xpos;
+ (void) ypos;
+ (void) block;
+ (void) trfm;
+ (void) length;
+
+ return &unimplemented;
+}
+
+os_error *xfont_scan_string (font_f font, char const *s,
+ font_string_flags flags, int x, int y, font_scan_block *block,
+ os_trfm const *trfm, int length, char **split_point,
+ int *x_out, int *y_out, int *num_split_chars)
+{
+ (void) font;
+ (void) s;
+ (void) flags;
+ (void) x;
+ (void) y;
+ (void) block;
+ (void) trfm;
+ (void) length;
+ (void) split_point;
+ (void) x_out;
+ (void) y_out;
+ (void) num_split_chars;
+
+ return &unimplemented;
+}
+
+os_error *xfont_switch_output_to_buffer (font_output_flags flags,
+ byte *buffer, char **end)
+{
+ (void) flags;
+ (void) buffer;
+ (void) end;
+
+ return &unimplemented;
+}
+
+os_error *xfont_enumerate_characters (font_f font, int character,
+ int *next_character, int *internal_character_code)
+{
+ (void) font;
+ (void) character;
+ (void) next_character;
+ (void) internal_character_code;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xhourglass_on (void)
+{
+ return &unimplemented;
+}
+
+os_error *xhourglass_off (void)
+{
+ return &unimplemented;
+}
+
+os_error *xhourglass_percentage (int percent)
+{
+ (void) percent;
+
+ return &unimplemented;
+}
+
+os_error *xhourglass_leds (bits eor_mask, bits and_mask, bits *old_leds)
+{
+ (void) eor_mask;
+ (void) and_mask;
+ (void) old_leds;
+
+ return &unimplemented;
+}
+
+os_error *xhourglass_colours (os_colour sand, os_colour glass,
+ os_colour *old_sand, os_colour *old_glass)
+{
+ (void) sand;
+ (void) glass;
+ (void) old_sand;
+ (void) old_glass;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xos_read_monotonic_time (os_t *t)
+{
+ (void) t;
+
+ return &unimplemented;
+}
+
+os_error *xos_read_mode_variable (os_mode mode, os_mode_var var, int *var_val,
+ bits *psr)
+{
+ (void) mode;
+ (void) var;
+ (void) var_val;
+ (void) psr;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xosfscontrol_canonicalise_path (char const *path_name, char *buffer,
+ char const *var, char const *path, int size, int *spare)
+{
+ (void) path_name;
+ (void) buffer;
+ (void) var;
+ (void) path;
+ (void) size;
+ (void) spare;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xtaskwindowtaskinfo_window_task (osbool *window_task)
+{
+ (void) window_task;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xwimp_create_window (wimp_window const *window, wimp_w *w)
+{
+ (void) window;
+ (void) w;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_delete_window (wimp_w w)
+{
+ (void) w;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_get_window_state (wimp_window_state *state)
+{
+ (void) state;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_open_window (wimp_open *open)
+{
+ (void) open;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_set_icon_state (wimp_w w, wimp_i i, wimp_icon_flags eor_bits,
+ wimp_icon_flags clear_bits)
+{
+ (void) w;
+ (void) i;
+ (void) eor_bits;
+ (void) clear_bits;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_resize_icon (wimp_w w, wimp_i i, int x0, int y0, int x1, int
y1)
+{
+ (void) w;
+ (void) i;
+ (void) x0;
+ (void) y0;
+ (void) x1;
+ (void) y1;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_poll (wimp_poll_flags mask, wimp_block *block, int *pollword,
+ wimp_event_no *event)
+{
+ (void) mask;
+ (void) block;
+ (void) pollword;
+ (void) event;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xwimpreadsysinfo_task (wimp_t *task, wimp_version_no *version)
+{
+ (void) task;
+ (void) version;
+
+ return &unimplemented;
+}
diff --git a/test/simple.c b/test/simple.c
new file mode 100644
index 0000000..44d668f
--- /dev/null
+++ b/test/simple.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+#include "rufl.h"
+
+#include "testutils.h"
+
+int main(int argc, const char **argv)
+{
+ UNUSED(argc);
+ UNUSED(argv);
+
+ assert(rufl_FONT_MANAGER_ERROR == rufl_init());
+
+ printf("PASS\n");
+
+ return 0;
+}
diff --git a/test/testutils.h b/test/testutils.h
new file mode 100644
index 0000000..7fe6333
--- /dev/null
+++ b/test/testutils.h
@@ -0,0 +1,123 @@
+#ifndef test_testutils_h_
+#define test_testutils_h_
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef UNUSED
+#define UNUSED(x) ((void) (x))
+#endif
+
+/* Redefine assert, so we can simply use the standard assert mechanism
+ * within testcases and exit with the right output for the testrunner
+ * to do the right thing. */
+void __assert2(const char *expr, const char *function,
+ const char *file, int line);
+
+void __assert2(const char *expr, const char *function,
+ const char *file, int line)
+{
+ UNUSED(function);
+ UNUSED(file);
+
+ printf("FAIL - %s at line %d\n", expr, line);
+
+ exit(EXIT_FAILURE);
+}
+
+#define assert(expr) \
+ ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
+
+
+typedef bool (*line_func)(const char *data, size_t datalen, void *pw);
+
+static size_t parse_strlen(const char *str, size_t limit);
+bool parse_testfile(const char *filename, line_func callback, void *pw);
+size_t parse_filesize(const char *filename);
+
+/**
+ * Testcase datafile parser driver
+ *
+ * \param filename Name of file to parse
+ * \param callback Pointer to function to handle each line of input data
+ * \param pw Pointer to client-specific private data
+ * \return true on success, false otherwise.
+ */
+bool parse_testfile(const char *filename, line_func callback, void *pw)
+{
+ FILE *fp;
+ char buf[300];
+
+ fp = fopen(filename, "rb");
+ if (fp == NULL) {
+ printf("Failed opening %s\n", filename);
+ return false;
+ }
+
+ while (fgets(buf, sizeof buf, fp)) {
+ if (buf[0] == '\n')
+ continue;
+
+ if (!callback(buf, parse_strlen(buf, sizeof buf - 1), pw)) {
+ fclose(fp);
+ return false;
+ }
+ }
+
+ fclose(fp);
+
+ return true;
+}
+
+/**
+ * Utility string length measurer; assumes strings are '\n' terminated
+ *
+ * \param str String to measure length of
+ * \param limit Upper bound on string length
+ * \return String length
+ */
+size_t parse_strlen(const char *str, size_t limit)
+{
+ size_t len = 0;
+
+ if (str == NULL)
+ return 0;
+
+ while (len < limit - 1 && *str != '\n') {
+ len++;
+ str++;
+ }
+
+ len++;
+
+ return len;
+}
+
+/**
+ * Read the size of a file
+ *
+ * \param filename Name of file to read size of
+ * \return File size (in bytes), or 0 on error
+ */
+size_t parse_filesize(const char *filename)
+{
+ FILE *fp;
+ size_t len = 0;
+
+ fp = fopen(filename, "rb");
+ if (fp == NULL) {
+ printf("Failed opening %s\n", filename);
+ return 0;
+ }
+
+ fseek(fp, 0, SEEK_END);
+ len = ftell(fp);
+
+ fclose(fp);
+
+ return len;
+}
+
+
+#endif
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=06fae32a7ae53ad113376befbc78414374f9326b
commit 06fae32a7ae53ad113376befbc78414374f9326b
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
RUfl_chars: fix undersized buffer
Compiling for other platforms has its benefits. The first of which
is x86_64 gcc rightly complaining that the buffer to receive the
error message is too small. Make it big enough.
diff --git a/test/rufl_chars.c b/test/rufl_chars.c
index fd0365c..0559d4e 100644
--- a/test/rufl_chars.c
+++ b/test/rufl_chars.c
@@ -302,7 +302,7 @@ rufl_code redraw(int x, int y, int y0, int y1)
void try(rufl_code code, const char *context)
{
- char s[200];
+ char s[400];
if (code == rufl_OK)
return;
else if (code == rufl_OUT_OF_MEMORY)
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=deb692c00afecca0d73394feef6e99e51606b9b4
commit deb692c00afecca0d73394feef6e99e51606b9b4
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Make it possible to build for non-RISC OS hosts
Linking fails, and the path to the OSLib headers is hard-coded,
but it's a start.
diff --git a/Makefile b/Makefile
index 75b49f2..1653ee9 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,10 @@ TESTRUNNER := $(ECHO)
# Toolchain flags
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
- -Wmissing-declarations -Wnested-externs -pedantic
+ -Wmissing-declarations -Wnested-externs
+ifeq ($(HOST),arm-unknown-riscos)
+ WARNFLAGS := $(WARNFLAGS) -pedantic
+endif
# BeOS/Haiku/AmigaOS4 standard library headers create warnings
ifneq ($(BUILD),i586-pc-haiku)
ifneq ($(findstring amigaos,$(BUILD)),amigaos)
@@ -35,6 +38,12 @@ ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
LDFLAGS := $(LDFLAGS) -lOSLib32
TESTLDFLAGS := $(TESTLDFLAGS) -static
+ else
+ # Regardless of the host platform we're building for, we
+ # still need the RISC OS build environment because we need the
+ # OSLib headers.
+ # XXX: is there a way to avoid this path being hard-coded?
+ CFLAGS := $(CFLAGS) -I/opt/netsurf/arm-unknown-riscos/env/include
endif
endif
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=ce3664d296b9b2459c4251321cb3f90adc32972d
commit ce3664d296b9b2459c4251321cb3f90adc32972d
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Link RISC OS test binaries statically
diff --git a/Makefile b/Makefile
index 562cc5c..75b49f2 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,7 @@ ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
ifeq ($(HOST),arm-unknown-riscos)
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
LDFLAGS := $(LDFLAGS) -lOSLib32
+ TESTLDFLAGS := $(TESTLDFLAGS) -static
endif
endif
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=0358488cc592f217158a8c4ea9adacf652ee85ce
commit 0358488cc592f217158a8c4ea9adacf652ee85ce
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Don't assume pointers are 32bits wide
Use uintptr_t to cast between pointers and integers, instead of
assuming that uint32_t will suffice.
diff --git a/src/rufl_init.c b/src/rufl_init.c
index 4005203..7915b9a 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -1045,7 +1045,7 @@ rufl_code rufl_init_scan_font_in_encoding(const char
*font_name,
* a reset. As there are no "good" outcomes here, and we do
* not have a time machine to go back and fix long-ago released
* Font Managers, ensure we ignore UCS fonts here. */
- if ((uint32_t) umap->encoding > 256) {
+ if ((uintptr_t) umap->encoding > 256) {
static os_error err = {
error_FONT_TOO_MANY_CHUNKS, "Rejecting UCS font"};
LOG("%s", "Rejecting UCS font");
@@ -1131,7 +1131,7 @@ static rufl_code rufl_init_umap_cb(void *pw, uint32_t
glyph_idx, uint32_t ucs4)
/* Stash the total number of encoding file entries so that
* rufl_init_scan_font_in_encoding can detect the presence of a
* UCS font on a non-UCS capable system. It will clean up for us. */
- umap->encoding = (void *) (((uint32_t) umap->encoding) + 1);
+ umap->encoding = (void *) (((uintptr_t) umap->encoding) + 1);
return result;
}
-----------------------------------------------------------------------
Summary of changes:
Makefile | 14 ++-
src/rufl_init.c | 4 +-
test/INDEX | 4 +
test/Makefile | 8 +-
test/mocks.c | 304 +++++++++++++++++++++++++++++++++++++++++++++++++++++
test/rufl_chars.c | 2 +-
test/simple.c | 17 +++
test/testutils.h | 123 ++++++++++++++++++++++
8 files changed, 470 insertions(+), 6 deletions(-)
create mode 100644 test/INDEX
create mode 100644 test/mocks.c
create mode 100644 test/simple.c
create mode 100644 test/testutils.h
diff --git a/Makefile b/Makefile
index 562cc5c..bfaf61e 100644
--- a/Makefile
+++ b/Makefile
@@ -9,12 +9,15 @@ PREFIX ?= /opt/netsurf
NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem
include $(NSSHARED)/makefiles/Makefile.tools
-TESTRUNNER := $(ECHO)
+TESTRUNNER := $(PERL) $(NSTESTTOOLS)/testrunner.pl
# Toolchain flags
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
- -Wmissing-declarations -Wnested-externs -pedantic
+ -Wmissing-declarations -Wnested-externs
+ifeq ($(HOST),arm-unknown-riscos)
+ WARNFLAGS := $(WARNFLAGS) -pedantic
+endif
# BeOS/Haiku/AmigaOS4 standard library headers create warnings
ifneq ($(BUILD),i586-pc-haiku)
ifneq ($(findstring amigaos,$(BUILD)),amigaos)
@@ -34,6 +37,13 @@ ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
ifeq ($(HOST),arm-unknown-riscos)
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
LDFLAGS := $(LDFLAGS) -lOSLib32
+ TESTLDFLAGS := $(TESTLDFLAGS) -static
+ else
+ # Regardless of the host platform we're building for, we
+ # still need the RISC OS build environment because we need the
+ # OSLib headers.
+ # XXX: is there a way to avoid this path being hard-coded?
+ CFLAGS := $(CFLAGS) -I/opt/netsurf/arm-unknown-riscos/env/include
endif
endif
diff --git a/src/rufl_init.c b/src/rufl_init.c
index 4005203..7915b9a 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -1045,7 +1045,7 @@ rufl_code rufl_init_scan_font_in_encoding(const char
*font_name,
* a reset. As there are no "good" outcomes here, and we do
* not have a time machine to go back and fix long-ago released
* Font Managers, ensure we ignore UCS fonts here. */
- if ((uint32_t) umap->encoding > 256) {
+ if ((uintptr_t) umap->encoding > 256) {
static os_error err = {
error_FONT_TOO_MANY_CHUNKS, "Rejecting UCS font"};
LOG("%s", "Rejecting UCS font");
@@ -1131,7 +1131,7 @@ static rufl_code rufl_init_umap_cb(void *pw, uint32_t
glyph_idx, uint32_t ucs4)
/* Stash the total number of encoding file entries so that
* rufl_init_scan_font_in_encoding can detect the presence of a
* UCS font on a non-UCS capable system. It will clean up for us. */
- umap->encoding = (void *) (((uint32_t) umap->encoding) + 1);
+ umap->encoding = (void *) (((uintptr_t) umap->encoding) + 1);
return result;
}
diff --git a/test/INDEX b/test/INDEX
new file mode 100644
index 0000000..bd46e96
--- /dev/null
+++ b/test/INDEX
@@ -0,0 +1,4 @@
+# Index for testcases
+#
+# Test Description DataDir
+simple Trivial test to prove harness works
diff --git a/test/Makefile b/test/Makefile
index 2bfa58b..1ce2936 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,10 @@
# Tests
-DIR_TEST_ITEMS := rufl_test:rufl_test.c rufl_chars:rufl_chars.c
+DIR_TEST_ITEMS := simple:simple.c;mocks.c
+
+ifeq ($(HOST),arm-unknown-riscos)
+ DIR_TEST_ITEMS := $(DIR_TEST_ITEMS) \
+ rufl_test:rufl_test.c \
+ rufl_chars:rufl_chars.c
+endif
include $(NSBUILD)/Makefile.subdir
diff --git a/test/mocks.c b/test/mocks.c
new file mode 100644
index 0000000..28cdf41
--- /dev/null
+++ b/test/mocks.c
@@ -0,0 +1,304 @@
+#include <oslib/font.h>
+#include <oslib/hourglass.h>
+#include <oslib/os.h>
+#include <oslib/osfscontrol.h>
+#include <oslib/taskwindow.h>
+#include <oslib/wimp.h>
+#include <oslib/wimpreadsysinfo.h>
+
+static os_error unimplemented = { error_UNIMPLEMENTED, "Not implemented" };
+
+/****************************************************************************/
+
+os_error *xfont_cache_addr (int *version, int *cache_size, int *cache_used)
+{
+ (void) version;
+ (void) cache_size;
+ (void) cache_used;
+
+ return &unimplemented;
+}
+
+os_error *xfont_find_font (char const *font_name, int xsize, int ysize,
+ int xres, int yres, font_f *font, int *xres_out, int *yres_out)
+{
+ (void) font_name;
+ (void) xsize;
+ (void) ysize;
+ (void) xres;
+ (void) yres;
+ (void) font;
+ (void) xres_out;
+ (void) yres_out;
+
+ return &unimplemented;
+}
+
+os_error *xfont_lose_font (font_f font)
+{
+ (void) font;
+
+ return &unimplemented;
+}
+
+os_error *xfont_read_info (font_f font, int *x0, int *y0, int *x1, int *y1)
+{
+ (void) font;
+ (void) x0;
+ (void) y0;
+ (void) x1;
+ (void) y1;
+
+ return &unimplemented;
+}
+
+os_error *xfont_read_encoding_filename (font_f font, char *buffer, int size,
+ char **end)
+{
+ (void) font;
+ (void) buffer;
+ (void) size;
+ (void) end;
+
+ return &unimplemented;
+}
+
+os_error *xfont_list_fonts (byte *buffer1, font_list_context context,
+ int size1, byte *buffer2, int size2, char const *tick_font,
+ font_list_context *context_out, int *used1, int *used2)
+{
+ (void) buffer1;
+ (void) context;
+ (void) size1;
+ (void) buffer2;
+ (void) size2;
+ (void) tick_font;
+ (void) context_out;
+ (void) used1;
+ (void) used2;
+
+ return &unimplemented;
+}
+
+os_error *xfont_set_font (font_f font)
+{
+ (void) font;
+
+ return &unimplemented;
+}
+
+os_error *xfont_paint (font_f font, char const *string,
+ font_string_flags flags, int xpos, int ypos,
+ font_paint_block const *block, os_trfm const *trfm, int length)
+{
+ (void) font;
+ (void) string;
+ (void) flags;
+ (void) xpos;
+ (void) ypos;
+ (void) block;
+ (void) trfm;
+ (void) length;
+
+ return &unimplemented;
+}
+
+os_error *xfont_scan_string (font_f font, char const *s,
+ font_string_flags flags, int x, int y, font_scan_block *block,
+ os_trfm const *trfm, int length, char **split_point,
+ int *x_out, int *y_out, int *num_split_chars)
+{
+ (void) font;
+ (void) s;
+ (void) flags;
+ (void) x;
+ (void) y;
+ (void) block;
+ (void) trfm;
+ (void) length;
+ (void) split_point;
+ (void) x_out;
+ (void) y_out;
+ (void) num_split_chars;
+
+ return &unimplemented;
+}
+
+os_error *xfont_switch_output_to_buffer (font_output_flags flags,
+ byte *buffer, char **end)
+{
+ (void) flags;
+ (void) buffer;
+ (void) end;
+
+ return &unimplemented;
+}
+
+os_error *xfont_enumerate_characters (font_f font, int character,
+ int *next_character, int *internal_character_code)
+{
+ (void) font;
+ (void) character;
+ (void) next_character;
+ (void) internal_character_code;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xhourglass_on (void)
+{
+ return &unimplemented;
+}
+
+os_error *xhourglass_off (void)
+{
+ return &unimplemented;
+}
+
+os_error *xhourglass_percentage (int percent)
+{
+ (void) percent;
+
+ return &unimplemented;
+}
+
+os_error *xhourglass_leds (bits eor_mask, bits and_mask, bits *old_leds)
+{
+ (void) eor_mask;
+ (void) and_mask;
+ (void) old_leds;
+
+ return &unimplemented;
+}
+
+os_error *xhourglass_colours (os_colour sand, os_colour glass,
+ os_colour *old_sand, os_colour *old_glass)
+{
+ (void) sand;
+ (void) glass;
+ (void) old_sand;
+ (void) old_glass;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xos_read_monotonic_time (os_t *t)
+{
+ (void) t;
+
+ return &unimplemented;
+}
+
+os_error *xos_read_mode_variable (os_mode mode, os_mode_var var, int *var_val,
+ bits *psr)
+{
+ (void) mode;
+ (void) var;
+ (void) var_val;
+ (void) psr;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xosfscontrol_canonicalise_path (char const *path_name, char *buffer,
+ char const *var, char const *path, int size, int *spare)
+{
+ (void) path_name;
+ (void) buffer;
+ (void) var;
+ (void) path;
+ (void) size;
+ (void) spare;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xtaskwindowtaskinfo_window_task (osbool *window_task)
+{
+ (void) window_task;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xwimp_create_window (wimp_window const *window, wimp_w *w)
+{
+ (void) window;
+ (void) w;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_delete_window (wimp_w w)
+{
+ (void) w;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_get_window_state (wimp_window_state *state)
+{
+ (void) state;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_open_window (wimp_open *open)
+{
+ (void) open;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_set_icon_state (wimp_w w, wimp_i i, wimp_icon_flags eor_bits,
+ wimp_icon_flags clear_bits)
+{
+ (void) w;
+ (void) i;
+ (void) eor_bits;
+ (void) clear_bits;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_resize_icon (wimp_w w, wimp_i i, int x0, int y0, int x1, int
y1)
+{
+ (void) w;
+ (void) i;
+ (void) x0;
+ (void) y0;
+ (void) x1;
+ (void) y1;
+
+ return &unimplemented;
+}
+
+os_error *xwimp_poll (wimp_poll_flags mask, wimp_block *block, int *pollword,
+ wimp_event_no *event)
+{
+ (void) mask;
+ (void) block;
+ (void) pollword;
+ (void) event;
+
+ return &unimplemented;
+}
+
+/****************************************************************************/
+
+os_error *xwimpreadsysinfo_task (wimp_t *task, wimp_version_no *version)
+{
+ (void) task;
+ (void) version;
+
+ return &unimplemented;
+}
diff --git a/test/rufl_chars.c b/test/rufl_chars.c
index fd0365c..0559d4e 100644
--- a/test/rufl_chars.c
+++ b/test/rufl_chars.c
@@ -302,7 +302,7 @@ rufl_code redraw(int x, int y, int y0, int y1)
void try(rufl_code code, const char *context)
{
- char s[200];
+ char s[400];
if (code == rufl_OK)
return;
else if (code == rufl_OUT_OF_MEMORY)
diff --git a/test/simple.c b/test/simple.c
new file mode 100644
index 0000000..44d668f
--- /dev/null
+++ b/test/simple.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+#include "rufl.h"
+
+#include "testutils.h"
+
+int main(int argc, const char **argv)
+{
+ UNUSED(argc);
+ UNUSED(argv);
+
+ assert(rufl_FONT_MANAGER_ERROR == rufl_init());
+
+ printf("PASS\n");
+
+ return 0;
+}
diff --git a/test/testutils.h b/test/testutils.h
new file mode 100644
index 0000000..7fe6333
--- /dev/null
+++ b/test/testutils.h
@@ -0,0 +1,123 @@
+#ifndef test_testutils_h_
+#define test_testutils_h_
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef UNUSED
+#define UNUSED(x) ((void) (x))
+#endif
+
+/* Redefine assert, so we can simply use the standard assert mechanism
+ * within testcases and exit with the right output for the testrunner
+ * to do the right thing. */
+void __assert2(const char *expr, const char *function,
+ const char *file, int line);
+
+void __assert2(const char *expr, const char *function,
+ const char *file, int line)
+{
+ UNUSED(function);
+ UNUSED(file);
+
+ printf("FAIL - %s at line %d\n", expr, line);
+
+ exit(EXIT_FAILURE);
+}
+
+#define assert(expr) \
+ ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
+
+
+typedef bool (*line_func)(const char *data, size_t datalen, void *pw);
+
+static size_t parse_strlen(const char *str, size_t limit);
+bool parse_testfile(const char *filename, line_func callback, void *pw);
+size_t parse_filesize(const char *filename);
+
+/**
+ * Testcase datafile parser driver
+ *
+ * \param filename Name of file to parse
+ * \param callback Pointer to function to handle each line of input data
+ * \param pw Pointer to client-specific private data
+ * \return true on success, false otherwise.
+ */
+bool parse_testfile(const char *filename, line_func callback, void *pw)
+{
+ FILE *fp;
+ char buf[300];
+
+ fp = fopen(filename, "rb");
+ if (fp == NULL) {
+ printf("Failed opening %s\n", filename);
+ return false;
+ }
+
+ while (fgets(buf, sizeof buf, fp)) {
+ if (buf[0] == '\n')
+ continue;
+
+ if (!callback(buf, parse_strlen(buf, sizeof buf - 1), pw)) {
+ fclose(fp);
+ return false;
+ }
+ }
+
+ fclose(fp);
+
+ return true;
+}
+
+/**
+ * Utility string length measurer; assumes strings are '\n' terminated
+ *
+ * \param str String to measure length of
+ * \param limit Upper bound on string length
+ * \return String length
+ */
+size_t parse_strlen(const char *str, size_t limit)
+{
+ size_t len = 0;
+
+ if (str == NULL)
+ return 0;
+
+ while (len < limit - 1 && *str != '\n') {
+ len++;
+ str++;
+ }
+
+ len++;
+
+ return len;
+}
+
+/**
+ * Read the size of a file
+ *
+ * \param filename Name of file to read size of
+ * \return File size (in bytes), or 0 on error
+ */
+size_t parse_filesize(const char *filename)
+{
+ FILE *fp;
+ size_t len = 0;
+
+ fp = fopen(filename, "rb");
+ if (fp == NULL) {
+ printf("Failed opening %s\n", filename);
+ return 0;
+ }
+
+ fseek(fp, 0, SEEK_END);
+ len = ftell(fp);
+
+ fclose(fp);
+
+ return len;
+}
+
+
+#endif
--
RISC OS Unicode Font Library
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]