From: Marek VavrusÌŒa Date: Mon, 8 Jun 2015 00:02:53 +0000 (+0200) Subject: tests/test_cache: dladdr is broken for local syms X-Git-Tag: v1.0.0-beta1~120^2~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fbb4e0cfb36214f814b50218cfc1ffcdfd8fa426;p=thirdparty%2Fknot-resolver.git tests/test_cache: dladdr is broken for local syms this relies on a lot of things (intrinsic), frame pointer and symbol dynamic symbol table --- diff --git a/tests/test_cache.c b/tests/test_cache.c index b94fc660f..be5bc04a0 100644 --- a/tests/test_cache.c +++ b/tests/test_cache.c @@ -45,10 +45,7 @@ int (*original_knot_rdataset_add)(knot_rdataset_t *rrs, const knot_rdata_t *rr, void *malloc(size_t __size) { - Dl_info dli = {0}; - char insert_name[] = "kr_cache_insert"; - int err_mock = KNOT_EOK, insert_namelen = strlen(insert_name); - + int err_mock = KNOT_EOK; if (original_malloc == NULL) { original_malloc = dlsym(RTLD_NEXT,"malloc"); @@ -56,9 +53,7 @@ void *malloc(size_t __size) } if (is_malloc_mocked) { - dladdr (__builtin_return_address (0), &dli); - if (dli.dli_sname && (strncmp(insert_name,dli.dli_sname,insert_namelen) == 0)) - err_mock = mock(); + err_mock = mock(); } return (err_mock != KNOT_EOK) ? NULL : original_malloc (__size); } @@ -235,8 +230,8 @@ static void test_fake_insert(void **state) test_randstr((char *)&global_fake_ce,sizeof(global_fake_ce)); test_randstr((char *)namedb_data,NAMEDB_DATA_SIZE); - is_malloc_mocked = true; will_return(malloc,KNOT_EINVAL); + is_malloc_mocked = true; ret_cache_lowmem = kr_cache_insert(txn, KR_CACHE_USER, dname, KNOT_RRTYPE_TSIG, &global_fake_ce, global_namedb_data); is_malloc_mocked = false;