X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=tests%2Fust-elf%2Fprog.c;h=85b9c3474b7edcafb57ce709bff4d32aa674b5b6;hb=0d8ba43d97a857d06ed09327fbc115ef27730156;hp=bc36b32171c0f5b4ef6cc8e8ec4f3c18117da19d;hpb=22609c7a82c5c8ebc07c19cade9b4d6ff61bd0d0;p=lttng-ust.git diff --git a/tests/ust-elf/prog.c b/tests/ust-elf/prog.c index bc36b321..85b9c347 100644 --- a/tests/ust-elf/prog.c +++ b/tests/ust-elf/prog.c @@ -26,7 +26,7 @@ #define NUM_ARCH 4 #define NUM_TESTS_PER_ARCH 11 -#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) +#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + 1 /* * Expected memsz were computed using libelf, build ID and debug link @@ -45,9 +45,26 @@ #define BUILD_ID_LEN 20 #define DBG_FILE "main.elf.debug" +static const uint8_t x86_build_id[BUILD_ID_LEN] = { + 0x27, 0x79, 0x2a, 0xe7, 0xaa, 0xef, 0x72, 0x5c, 0x9c, 0x52, + 0x80, 0xec, 0x1e, 0x18, 0xd8, 0x09, 0x02, 0xba, 0xbc, 0x82 +}; +static const uint8_t x86_64_build_id[BUILD_ID_LEN] = { + 0x0f, 0x87, 0xb2, 0xe2, 0x24, 0x9c, 0xe1, 0xc2, 0x24, 0xb1, + 0xf8, 0xb6, 0x65, 0x83, 0xa3, 0xc1, 0xcb, 0x30, 0x5c, 0x63 +}; +static const uint8_t armeb_build_id[BUILD_ID_LEN] = { + 0x60, 0x5d, 0x26, 0xa0, 0x0e, 0x30, 0xa4, 0x29, 0xf4, 0xf1, + 0x85, 0x53, 0xda, 0x90, 0x68, 0xe1, 0xf5, 0x67, 0xbe, 0x42 +}; +static const uint8_t aarch64_be_build_id[BUILD_ID_LEN] = { + 0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85, + 0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60 +}; + static void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz, - uint8_t *exp_build_id, uint32_t exp_crc) + const uint8_t *exp_build_id, uint32_t exp_crc) { char path[PATH_MAX]; struct lttng_ust_elf *elf = NULL; @@ -86,7 +103,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, @@ -100,31 +117,22 @@ void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz, int main(int argc, char **argv) { - uint8_t X86_BUILD_ID[BUILD_ID_LEN] = { - 0x27, 0x79, 0x2a, 0xe7, 0xaa, 0xef, 0x72, 0x5c, 0x9c, 0x52, - 0x80, 0xec, 0x1e, 0x18, 0xd8, 0x09, 0x02, 0xba, 0xbc, 0x82 - }; - uint8_t X86_64_BUILD_ID[BUILD_ID_LEN] = { - 0x0f, 0x87, 0xb2, 0xe2, 0x24, 0x9c, 0xe1, 0xc2, 0x24, 0xb1, - 0xf8, 0xb6, 0x65, 0x83, 0xa3, 0xc1, 0xcb, 0x30, 0x5c, 0x63 - }; - uint8_t ARMEB_BUILD_ID[BUILD_ID_LEN] = { - 0x60, 0x5d, 0x26, 0xa0, 0x0e, 0x30, 0xa4, 0x29, 0xf4, 0xf1, - 0x85, 0x53, 0xda, 0x90, 0x68, 0xe1, 0xf5, 0x67, 0xbe, 0x42 - }; - uint8_t AARCH64_BE_BUILD_ID[BUILD_ID_LEN] = { - 0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85, - 0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60 - }; - const char *TEST_DIR = argv[1]; + const char *test_dir; plan_tests(NUM_TESTS); - test_elf(TEST_DIR, "x86", X86_MEMSZ, X86_BUILD_ID, X86_CRC); - test_elf(TEST_DIR, "x86_64", X86_64_MEMSZ, X86_64_BUILD_ID, X86_64_CRC); - 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, + ok(argc == 2, "Invoke as: %s ", argv[0]); + if (argc != 2) { + return EXIT_FAILURE; + } else { + test_dir = argv[1]; + } + + test_elf(test_dir, "x86", X86_MEMSZ, x86_build_id, X86_CRC); + test_elf(test_dir, "x86_64", X86_64_MEMSZ, x86_64_build_id, X86_64_CRC); + 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); - return 0; + return EXIT_SUCCESS; }