mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
tests: be more precise in jitmap tests
I want to make sure we have the right values in/out of there.
This commit is contained in:
@ -29,11 +29,24 @@
|
|||||||
|
|
||||||
#include "sysprof-platform.h"
|
#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
|
static void
|
||||||
test_reader_basic (void)
|
test_reader_basic (void)
|
||||||
{
|
{
|
||||||
SysprofCaptureReader *reader;
|
SysprofCaptureReader *reader;
|
||||||
SysprofCaptureWriter *writer;
|
SysprofCaptureWriter *writer;
|
||||||
|
g_autoptr(GHashTable) jmap = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gint64 t = SYSPROF_CAPTURE_CURRENT_TIME;
|
gint64 t = SYSPROF_CAPTURE_CURRENT_TIME;
|
||||||
guint i;
|
guint i;
|
||||||
@ -298,6 +311,8 @@ test_reader_basic (void)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
jmap = g_hash_table_new_full (NULL, NULL, NULL, g_free);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
SysprofCaptureFrameType type = -1;
|
SysprofCaptureFrameType type = -1;
|
||||||
@ -312,10 +327,22 @@ test_reader_basic (void)
|
|||||||
g_assert (ret != NULL);
|
g_assert (ret != NULL);
|
||||||
|
|
||||||
i += g_hash_table_size (ret);
|
i += g_hash_table_size (ret);
|
||||||
|
|
||||||
|
copy_into (ret, jmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert_cmpint (1000, ==, i);
|
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;
|
SysprofCaptureFrameType type = -1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user