Skip to content

Commit ebb27c2

Browse files
author
Kim Barrett
committed
8346139: test_memset_with_concurrent_readers.cpp should not use <sstream>
Reviewed-by: stefank, tschatzl
1 parent c2f0ef5 commit ebb27c2

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp

+17-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,7 @@
2424
#include "precompiled.hpp"
2525
#include "gc/shared/memset_with_concurrent_readers.hpp"
2626
#include "utilities/globalDefinitions.hpp"
27-
28-
#include "utilities/vmassert_uninstall.hpp"
29-
#include <iomanip>
30-
#include <string.h>
31-
#include <sstream>
32-
#include "utilities/vmassert_reinstall.hpp"
33-
27+
#include "utilities/ostream.hpp"
3428
#include "unittest.hpp"
3529

3630
static unsigned line_byte(const char* line, size_t i) {
@@ -71,29 +65,31 @@ TEST(gc, memset_with_concurrent_readers) {
7165
bool middle_set = !memcmp(set_block, block + set_start, set_size);
7266
bool tail_clear = !memcmp(clear_block, block + set_end, block_size - set_end);
7367
if (!(head_clear && middle_set && tail_clear)) {
74-
std::ostringstream err_stream;
75-
err_stream << "*** memset_with_concurrent_readers failed: set start "
76-
<< set_start << ", set end " << set_end << std::endl;
68+
stringStream err_stream{};
69+
err_stream.print_cr("*** memset_with_concurrent_readers failed: "
70+
"set start %zu, set end %zu",
71+
set_start, set_end);
7772
for (unsigned chunk = 0; chunk < (block_size / chunk_size); ++chunk) {
7873
for (unsigned line = 0; line < (chunk_size / BytesPerWord); ++line) {
7974

8075
const char* lp = &block[chunk * chunk_size + line * BytesPerWord];
8176

82-
err_stream << std::dec << chunk << "," << line << ": " << std::hex
83-
<< std::setw(2) << line_byte(lp, 0) << " "
84-
<< std::setw(2) << line_byte(lp, 1) << " "
85-
<< std::setw(2) << line_byte(lp, 2) << " "
86-
<< std::setw(2) << line_byte(lp, 3) << " "
87-
<< std::setw(2) << line_byte(lp, 4) << " "
88-
<< std::setw(2) << line_byte(lp, 5) << " "
89-
<< std::setw(2) << line_byte(lp, 6) << " "
90-
<< std::setw(2) << line_byte(lp, 7) << std::endl;
77+
err_stream.print_cr("%u, %u: "
78+
"%02x %02x "
79+
"%02x %02x "
80+
"%02x %02x "
81+
"%02x %02x",
82+
chunk, line,
83+
line_byte(lp, 0), line_byte(lp, 1),
84+
line_byte(lp, 2), line_byte(lp, 3),
85+
line_byte(lp, 4), line_byte(lp, 5),
86+
line_byte(lp, 6), line_byte(lp, 7));
9187
}
9288
}
9389
EXPECT_TRUE(head_clear) << "leading byte not clear";
9490
EXPECT_TRUE(middle_set) << "memset byte not set";
9591
EXPECT_TRUE(tail_clear) << "trailing bye not clear";
96-
ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.str();
92+
ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.freeze();
9793
}
9894
}
9995
}

0 commit comments

Comments
 (0)