[sysprof] tests: be more precise in jitmap tests



commit 44fa9500dc29bdfd03bc61d493d4be10a875a493
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 5 17:47:36 2019 -0700

    tests: be more precise in jitmap tests
    
    I want to make sure we have the right values in/out of there.

 src/tests/test-capture.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/tests/test-capture.c b/src/tests/test-capture.c
index 1dbac61..22224e3 100644
--- a/src/tests/test-capture.c
+++ b/src/tests/test-capture.c
@@ -29,11 +29,24 @@
 
 #include "sysprof-platform.h"
 
+static void
+copy_into (GHashTable *src,
+           GHashTable *dst)
+{
+  GHashTableIter iter;
+  gpointer k, v;
+
+  g_hash_table_iter_init (&iter, src);
+  while (g_hash_table_iter_next (&iter, &k, &v))
+    g_hash_table_insert (dst, k, g_strdup ((gchar *)v));
+}
+
 static void
 test_reader_basic (void)
 {
   SysprofCaptureReader *reader;
   SysprofCaptureWriter *writer;
+  g_autoptr(GHashTable) jmap = NULL;
   GError *error = NULL;
   gint64 t = SYSPROF_CAPTURE_CURRENT_TIME;
   guint i;
@@ -298,6 +311,8 @@ test_reader_basic (void)
 
   i = 0;
 
+  jmap = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+
   for (;;)
     {
       SysprofCaptureFrameType type = -1;
@@ -312,10 +327,22 @@ test_reader_basic (void)
       g_assert (ret != NULL);
 
       i += g_hash_table_size (ret);
+
+      copy_into (ret, jmap);
     }
 
   g_assert_cmpint (1000, ==, i);
 
+  for (i = 0; i < 1000; i++)
+    {
+      SysprofCaptureAddress addr = ((SysprofCaptureAddress)i + 1L) | SYSPROF_CAPTURE_JITMAP_MARK;
+      const gchar *mapped = g_hash_table_lookup (jmap, (gpointer)addr);
+      gchar str[32];
+
+      g_snprintf (str, sizeof str, "jitstring-%d", i);
+      g_assert_cmpstr (str, ==, mapped);
+    }
+
   {
     SysprofCaptureFrameType type = -1;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]