7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2024-11-24 15:55:02 +00:00
kicad/thirdparty/sentry-native/tests/unit/test_symbolizer.c
2022-08-15 20:48:53 -04:00

42 lines
1.2 KiB
C

#include "sentry_symbolizer.h"
#include "sentry_testsupport.h"
TEST_VISIBLE void
test_function(void)
{
printf("Something here\n");
}
static void
asserter(const sentry_frame_info_t *info, void *data)
{
int *called = data;
TEST_CHECK(!!info->symbol);
TEST_CHECK(!!info->object_name);
TEST_CHECK(info->symbol && strstr(info->symbol, "test_function") != 0);
TEST_CHECK(info->object_name
&& strstr(info->object_name, "sentry_test_unit") != 0);
#ifdef SENTRY_PLATFORM_AIX
// Again, function descriptors. Should be enabled for ELFv1 PPC too.
TEST_CHECK(info->symbol_addr == *(void **)&test_function);
TEST_CHECK(
info->instruction_addr == ((char *)*(void **)&test_function) + 1);
#else
TEST_CHECK(info->symbol_addr == &test_function);
TEST_CHECK(info->instruction_addr == ((char *)(void *)&test_function) + 1);
#endif
*called += 1;
}
SENTRY_TEST(symbolizer)
{
int called = 0;
#ifdef SENTRY_PLATFORM_AIX
sentry__symbolize(
((char *)*(void **)&test_function) + 1, asserter, &called);
#else
sentry__symbolize(((char *)(void *)&test_function) + 1, asserter, &called);
#endif
TEST_CHECK_INT_EQUAL(called, 1);
}