[HarfBuzz] harfbuzz: Branch 'master' - 5 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Fri Sep 28 12:46:20 UTC 2018


 test/api/test-multithread.c |   75 ++++++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 30 deletions(-)

New commits:
commit 7e6e094abd27fd022fe9aea1872ef82f6a0cdcec
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Sep 28 08:45:57 2018 -0400

    [test-multithread] Install ot funcs before filling ref buffer

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 2dbecc9b..a75feffa 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -147,12 +147,13 @@ main (int argc, char **argv)
   hb_face_t *face = hb_face_create (blob, 0);
   font = hb_font_create (face);
 
+  hb_ot_font_set_funcs (font);
+
   ref_buffer = hb_buffer_create ();
   fill_the_buffer (ref_buffer);
 
-  hb_ft_font_set_funcs (font);
   test_body ();
-  hb_ot_font_set_funcs (font);
+  hb_ft_font_set_funcs (font);
   test_body ();
 
   hb_buffer_destroy (ref_buffer);
commit 21fbee831e0eab2c2f4513825c939158f4578156
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Sep 28 08:43:37 2018 -0400

    [test-multithread] Take num-threads and num-iters from command-line

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 898f19a0..2dbecc9b 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -134,6 +134,11 @@ test_body ()
 int
 main (int argc, char **argv)
 {
+  if (argc > 1)
+    num_threads = atoi (argv[1]);
+  if (argc > 2)
+    num_iters = atoi (argv[2]);
+
   // Dummy call to alleviate _guess_segment_properties thread safety-ness
   // https://github.com/harfbuzz/harfbuzz/issues/1191
   hb_language_get_default ();
commit 598be3bb38fd11a288f8155b8c27ffef4ebdd8b9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Sep 28 08:33:26 2018 -0400

    Minor

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 6881a00f..898f19a0 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -135,6 +135,7 @@ int
 main (int argc, char **argv)
 {
   // Dummy call to alleviate _guess_segment_properties thread safety-ness
+  // https://github.com/harfbuzz/harfbuzz/issues/1191
   hb_language_get_default ();
 
   hb_blob_t *blob = hb_blob_create_from_file (path);
commit c09bf3d50589c8eb95b322ef3e4eb8a288dacebe
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Fri Sep 28 16:13:01 2018 +0330

    test-multithread, check the results on every iteration (#1194)

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 65718825..6881a00f 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -43,9 +43,11 @@ const char *path =
 		"/Library/Fonts/Tahoma.ttf";
 #endif
 
+int num_threads = 30;
 int num_iters = 200;
 
 hb_font_t *font;
+hb_buffer_t *ref_buffer;
 
 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -57,6 +59,29 @@ fill_the_buffer (hb_buffer_t *buffer)
   hb_shape (font, buffer, NULL, 0);
 }
 
+static void
+validity_check (hb_buffer_t *buffer) {
+  if (hb_buffer_diff (ref_buffer, buffer, (hb_codepoint_t) -1, 0))
+  {
+    fprintf (stderr, "One of the buffers was different from the reference.\n");
+    char out[255];
+
+    hb_buffer_serialize_glyphs (buffer, 0, hb_buffer_get_length (ref_buffer),
+				out, sizeof (out), NULL,
+				font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
+				HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
+    fprintf (stderr, "Actual: %s\n", out);
+
+    hb_buffer_serialize_glyphs (ref_buffer, 0, hb_buffer_get_length (ref_buffer),
+				out, sizeof (out), NULL,
+				font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
+				HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
+    fprintf (stderr, "Expected: %s\n", out);
+
+    exit (1);
+  }
+}
+
 static void *
 thread_func (void *data)
 {
@@ -70,6 +95,7 @@ thread_func (void *data)
   {
     hb_buffer_clear_contents (buffer);
     fill_the_buffer (buffer);
+    validity_check (buffer);
   }
 
   return 0;
@@ -95,38 +121,12 @@ test_body ()
   /* Let them loose! */
   pthread_mutex_unlock (&mutex);
 
-  hb_buffer_t *ref_buffer = hb_buffer_create ();
-  fill_the_buffer (ref_buffer);
-
   for (i = 0; i < num_threads; i++)
   {
     pthread_join (threads[i], NULL);
-    hb_buffer_t *buffer = buffers[i];
-    hb_buffer_diff_flags_t diff = hb_buffer_diff (ref_buffer, buffer, (hb_codepoint_t) -1, 0);
-    if (diff)
-    {
-      fprintf (stderr, "One of the buffers (%d) was different from the reference.\n", i);
-      char out[255];
-
-      hb_buffer_serialize_glyphs (buffer, 0, hb_buffer_get_length (ref_buffer),
-				  out, sizeof (out), NULL,
-				  font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
-				  HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
-      fprintf (stderr, "Actual: %s\n", out);
-
-      hb_buffer_serialize_glyphs (ref_buffer, 0, hb_buffer_get_length (ref_buffer),
-				  out, sizeof (out), NULL,
-				  font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
-				  HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
-      fprintf (stderr, "Expected: %s\n", out);
-
-      exit (1);
-    }
-    hb_buffer_destroy (buffer);
+    hb_buffer_destroy (buffers[i]);
   }
 
-  hb_buffer_destroy (ref_buffer);
-
   free (buffers);
   free (threads);
 }
@@ -141,11 +141,16 @@ main (int argc, char **argv)
   hb_face_t *face = hb_face_create (blob, 0);
   font = hb_font_create (face);
 
+  ref_buffer = hb_buffer_create ();
+  fill_the_buffer (ref_buffer);
+
   hb_ft_font_set_funcs (font);
   test_body ();
   hb_ot_font_set_funcs (font);
   test_body ();
 
+  hb_buffer_destroy (ref_buffer);
+
   hb_font_destroy (font);
   hb_face_destroy (face);
   hb_blob_destroy (blob);
commit dbc3070a15290310bb5aade11d04eb24fe958094
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Fri Sep 28 16:01:15 2018 +0330

    Make test-multithread pass the tsan bot test (#1193)

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index c87da3c0..65718825 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -50,7 +50,7 @@ hb_font_t *font;
 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void
-fill_the_buffer(hb_buffer_t *buffer)
+fill_the_buffer (hb_buffer_t *buffer)
 {
   hb_buffer_add_utf8 (buffer, text, sizeof (text), 0, sizeof (text));
   hb_buffer_guess_segment_properties (buffer);
@@ -134,6 +134,9 @@ test_body ()
 int
 main (int argc, char **argv)
 {
+  // Dummy call to alleviate _guess_segment_properties thread safety-ness
+  hb_language_get_default ();
+
   hb_blob_t *blob = hb_blob_create_from_file (path);
   hb_face_t *face = hb_face_create (blob, 0);
   font = hb_font_create (face);


More information about the HarfBuzz mailing list