X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=tests%2Fust-elf%2Fprog.c;h=da4f3963edbb30ce5b1664b5325a13366ad66e14;hb=0ce823281d505aada6ddeb56a84a556d1b483d36;hp=5090bcf75da26912f4972e86a606c581a8a79f4a;hpb=8d8a8c5c04302d2c33face8a9f8f4c5d9c6299fd;p=lttng-ust.git diff --git a/tests/ust-elf/prog.c b/tests/ust-elf/prog.c index 5090bcf7..da4f3963 100644 --- a/tests/ust-elf/prog.c +++ b/tests/ust-elf/prog.c @@ -26,16 +26,17 @@ #define NUM_ARCH 4 #define NUM_TESTS_PER_ARCH 11 -#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + 1 +#define NUM_TESTS_PIC 3 +#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + NUM_TESTS_PIC + 1 /* * Expected memsz were computed using libelf, build ID and debug link * were determined through readelf. */ -#define X86_MEMSZ 8192 -#define X86_64_MEMSZ 4194304 -#define ARMEB_MEMSZ 65536 -#define AARCH64_BE_MEMSZ 131072 +#define X86_MEMSZ 5732 +#define X86_64_MEMSZ 2099376 +#define ARMEB_MEMSZ 34196 +#define AARCH64_BE_MEMSZ 67632 #define X86_CRC 0x1531f73c #define X86_64_CRC 0xa048a98f @@ -103,7 +104,7 @@ void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz, &has_debug_link); ok(ret == 0, "lttng_ust_elf_get_debug_link returned successfully"); ok(has_debug_link == 1, "debug link marked as found"); - ok(strcmp(dbg_file, DBG_FILE) == 0, + ok(dbg_file && strcmp(dbg_file, DBG_FILE) == 0, "debug link filename - expected: %s, got: %s", DBG_FILE, dbg_file); ok(crc == exp_crc, @@ -115,6 +116,35 @@ void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz, lttng_ust_elf_destroy(elf); } +static +void test_pic(const char *test_dir) +{ + char exec_path[PATH_MAX]; + char pie_path[PATH_MAX]; + char pic_path[PATH_MAX]; + struct lttng_ust_elf *elf = NULL; + uint8_t is_pic; + + snprintf(exec_path, PATH_MAX, "%s/data/pic/hello.exec", test_dir); + snprintf(pie_path, PATH_MAX, "%s/data/pic/hello.pie", test_dir); + snprintf(pic_path, PATH_MAX, "%s/data/pic/hello.pic", test_dir); + + elf = lttng_ust_elf_create(exec_path); + is_pic = lttng_ust_elf_is_pic(elf); + ok(is_pic == 0, "hello.exec is not PIC"); + lttng_ust_elf_destroy(elf); + + elf = lttng_ust_elf_create(pie_path); + is_pic = lttng_ust_elf_is_pic(elf); + ok(is_pic == 1, "hello.pie is PIC"); + lttng_ust_elf_destroy(elf); + + elf = lttng_ust_elf_create(pic_path); + is_pic = lttng_ust_elf_is_pic(elf); + ok(is_pic == 1, "hello.pic is PIC"); + lttng_ust_elf_destroy(elf); +} + int main(int argc, char **argv) { const char *test_dir; @@ -133,6 +163,7 @@ int main(int argc, char **argv) test_elf(test_dir, "armeb", ARMEB_MEMSZ, armeb_build_id, ARMEB_CRC); test_elf(test_dir, "aarch64_be", AARCH64_BE_MEMSZ, aarch64_be_build_id, AARCH64_BE_CRC); + test_pic(test_dir); return EXIT_SUCCESS; }