Test freetype funcs on test-multithread (#1187)
authorEbrahim Byagowi <ebrahim@gnu.org>
Wed, 26 Sep 2018 20:02:45 +0000 (23:32 +0330)
committerGitHub <noreply@github.com>
Wed, 26 Sep 2018 20:02:45 +0000 (23:32 +0330)
test/api/Makefile.am
test/api/test-multithread.c

index 1c0f92c..466d56f 100644 (file)
@@ -77,9 +77,11 @@ TEST_PROGS += \
        $(NULL)
 
 if HAVE_PTHREAD
+if HAVE_FREETYPE
 TEST_PROGS += test-multithread
-test_multithread_CFLAGS = $(CFLAGS) $(PTHREAD_CFLAGS)
-test_multithread_LDADD = $(LDADD) $(PTHREAD_LIBS)
+test_multithread_CFLAGS = $(CFLAGS) $(PTHREAD_CFLAGS) $(FREETYPE_CFLAGS)
+test_multithread_LDADD = $(LDADD) $(PTHREAD_LIBS) $(FREETYPE_LIBS)
+endif
 endif
 
 if HAVE_FREETYPE
index 4570da1..c87da3c 100644 (file)
@@ -30,6 +30,7 @@
 #include <pthread.h>
 
 #include <hb.h>
+#include <hb-ft.h>
 #include <hb-ot.h>
 
 const char *text = "طرح‌نَما";
@@ -74,8 +75,8 @@ thread_func (void *data)
   return 0;
 }
 
-int
-main (int argc, char **argv)
+void
+test_body ()
 {
   int i;
   int num_threads = 30;
@@ -84,11 +85,6 @@ main (int argc, char **argv)
 
   pthread_mutex_lock (&mutex);
 
-  hb_blob_t *blob = hb_blob_create_from_file (path);
-  hb_face_t *face = hb_face_create (blob, 0);
-  font = hb_font_create (face);
-  hb_ot_font_set_funcs (font);
-
   for (i = 0; i < num_threads; i++)
   {
     hb_buffer_t *buffer = hb_buffer_create ();
@@ -124,7 +120,7 @@ main (int argc, char **argv)
                                  HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
       fprintf (stderr, "Expected: %s\n", out);
 
-      return 1;
+      exit (1);
     }
     hb_buffer_destroy (buffer);
   }
@@ -133,6 +129,19 @@ main (int argc, char **argv)
 
   free (buffers);
   free (threads);
+}
+
+int
+main (int argc, char **argv)
+{
+  hb_blob_t *blob = hb_blob_create_from_file (path);
+  hb_face_t *face = hb_face_create (blob, 0);
+  font = hb_font_create (face);
+
+  hb_ft_font_set_funcs (font);
+  test_body ();
+  hb_ot_font_set_funcs (font);
+  test_body ();
 
   hb_font_destroy (font);
   hb_face_destroy (face);