Skip to content

Commit

Permalink
add gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
MBaesken committed Aug 6, 2024
1 parent a81d1a3 commit e034769
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/hotspot/gtest/runtime/test_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ static void do_test_print_hex_dump(const_address from, const_address to, int uni
EXPECT_STREQ(buf, expected);
}

// version with a highlighted pc location
static void do_test_print_hex_dump_highlighted(const_address from, const_address to, int unitsize, int bytes_per_line,
const_address logical_start, const char* expected, const_address highlight) {
char buf[2048];
buf[0] = '\0';
stringStream ss(buf, sizeof(buf));
os::print_hex_dump(&ss, from, to, unitsize, /* print_ascii=*/true, bytes_per_line, logical_start, highlight);
EXPECT_STREQ(buf, expected);
}

TEST_VM(os, test_print_hex_dump) {

#ifdef _LP64
Expand All @@ -197,6 +207,15 @@ TEST_VM(os, test_print_hex_dump) {
ADDRESS2 ": ff ff e0 dc 23 00 6a 64 6b 2f 69 6e 74 65 72 6e 61 6c 2f 6c 6f 61 64 65 72 2f 4e 61 74 69 76 65 " ASCII_1 "\n" \
ADDRESS3 ": 4c 69 62 72 61 72 69 65 73 00 00 00 00 00 00 00 " ASCII_2 "\n"

#define PAT_HL_1A "=>" ADDRESS1 ": ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??\n" \
" " ADDRESS2 ": ff ff e0 dc 23 00 6a 64 6b 2f 69 6e 74 65 72 6e 61 6c 2f 6c 6f 61 64 65 72 2f 4e 61 74 69 76 65 " ASCII_1 "\n" \
" " ADDRESS3 ": 4c 69 62 72 61 72 69 65 73 00 00 00 00 00 00 00 " ASCII_2 "\n"

#define PAT_HL_1B " " ADDRESS1 ": ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??\n" \
"=>" ADDRESS2 ": ff ff e0 dc 23 00 6a 64 6b 2f 69 6e 74 65 72 6e 61 6c 2f 6c 6f 61 64 65 72 2f 4e 61 74 69 76 65 " ASCII_1 "\n" \
" " ADDRESS3 ": 4c 69 62 72 61 72 69 65 73 00 00 00 00 00 00 00 " ASCII_2 "\n"


#ifdef VM_LITTLE_ENDIAN
#define PAT_2 ADDRESS1 ": ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ????\n" \
ADDRESS2 ": ffff dce0 0023 646a 2f6b 6e69 6574 6e72 6c61 6c2f 616f 6564 2f72 614e 6974 6576 " ASCII_1 "\n" \
Expand Down Expand Up @@ -252,6 +271,11 @@ TEST_VM(os, test_print_hex_dump) {
do_test_print_hex_dump(from + 1, to, 4, 32, logical_start, PAT_4);
do_test_print_hex_dump(from + 1, to, 8, 32, logical_start, PAT_8);

// print with highlighted address
do_test_print_hex_dump_highlighted(from, to, 1, 32, logical_start, PAT_HL_1A, from+5);
do_test_print_hex_dump_highlighted(from, to, 1, 32, logical_start, PAT_HL_1B, from+32);
do_test_print_hex_dump_highlighted(from, to, 1, 32, logical_start, PAT_HL_1B, from+60);

os::release_memory(two_pages, ps * 2);
}
#endif // not AIX
Expand Down

0 comments on commit e034769

Please sign in to comment.