mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibCore: Propagate errors from Stream::*_entire_buffer
This commit is contained in:
parent
6c7c5a6786
commit
9a3e95785e
17 changed files with 43 additions and 49 deletions
|
@ -87,17 +87,17 @@ TEST_CASE(file_seeking_around)
|
|||
|
||||
EXPECT(!file->seek(500, Core::Stream::SeekMode::SetPosition).is_error());
|
||||
EXPECT_EQ(file->tell().release_value(), 500);
|
||||
EXPECT(file->read_entire_buffer(buffer));
|
||||
EXPECT(!file->read_entire_buffer(buffer).is_error());
|
||||
EXPECT_EQ(buffer_contents, expected_seek_contents1);
|
||||
|
||||
EXPECT(!file->seek(234, Core::Stream::SeekMode::FromCurrentPosition).is_error());
|
||||
EXPECT_EQ(file->tell().release_value(), 750);
|
||||
EXPECT(file->read_entire_buffer(buffer));
|
||||
EXPECT(!file->read_entire_buffer(buffer).is_error());
|
||||
EXPECT_EQ(buffer_contents, expected_seek_contents2);
|
||||
|
||||
EXPECT(!file->seek(-105, Core::Stream::SeekMode::FromEndPosition).is_error());
|
||||
EXPECT_EQ(file->tell().release_value(), 8597);
|
||||
EXPECT(file->read_entire_buffer(buffer));
|
||||
EXPECT(!file->read_entire_buffer(buffer).is_error());
|
||||
EXPECT_EQ(buffer_contents, expected_seek_contents3);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ TEST_CASE(file_adopt_fd)
|
|||
|
||||
EXPECT(!file->seek(500, Core::Stream::SeekMode::SetPosition).is_error());
|
||||
EXPECT_EQ(file->tell().release_value(), 500);
|
||||
EXPECT(file->read_entire_buffer(buffer));
|
||||
EXPECT(!file->read_entire_buffer(buffer).is_error());
|
||||
EXPECT_EQ(buffer_contents, expected_seek_contents1);
|
||||
|
||||
// A single seek & read test should be fine for now.
|
||||
|
@ -218,7 +218,7 @@ TEST_CASE(tcp_socket_write)
|
|||
auto server_socket = maybe_server_socket.release_value();
|
||||
EXPECT(!server_socket->set_blocking(true).is_error());
|
||||
|
||||
EXPECT(client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }));
|
||||
EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error());
|
||||
client_socket->close();
|
||||
|
||||
auto maybe_receive_buffer = ByteBuffer::create_uninitialized(64);
|
||||
|
@ -282,7 +282,7 @@ TEST_CASE(udp_socket_read_write)
|
|||
auto client_socket = maybe_client_socket.release_value();
|
||||
|
||||
EXPECT(client_socket->is_open());
|
||||
EXPECT(client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }));
|
||||
EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error());
|
||||
|
||||
// FIXME: UDPServer::receive sadly doesn't give us a way to block on it,
|
||||
// currently.
|
||||
|
@ -400,7 +400,7 @@ TEST_CASE(local_socket_write)
|
|||
EXPECT(!maybe_client_socket.is_error());
|
||||
auto client_socket = maybe_client_socket.release_value();
|
||||
|
||||
EXPECT(client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }));
|
||||
EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error());
|
||||
client_socket->close();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -18,8 +18,7 @@ static DeprecatedString read_all(DeprecatedString const& path)
|
|||
auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
if (!file->read_entire_buffer(content.bytes()))
|
||||
VERIFY_NOT_REACHED();
|
||||
MUST(file->read_entire_buffer(content.bytes()));
|
||||
return DeprecatedString { content.bytes() };
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@ static DeprecatedString read_all(DeprecatedString const& path)
|
|||
auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
if (!file->read_entire_buffer(content.bytes()))
|
||||
VERIFY_NOT_REACHED();
|
||||
MUST(file->read_entire_buffer(content.bytes()));
|
||||
return DeprecatedString { content.bytes() };
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
}
|
||||
|
||||
for (DeprecatedString const& line : lines) {
|
||||
if (!m_output->write_entire_buffer(DeprecatedString::formatted("{}\n", line).bytes()))
|
||||
if (m_output->write_entire_buffer(DeprecatedString::formatted("{}\n", line).bytes()).is_error())
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<Deprec
|
|||
complete_results.set("duration", time_taken_in_ms / 1000.);
|
||||
complete_results.set("results", result_object);
|
||||
|
||||
if (!file->write_entire_buffer(complete_results.to_deprecated_string().bytes()))
|
||||
if (file->write_entire_buffer(complete_results.to_deprecated_string().bytes()).is_error())
|
||||
warnln("Failed to write per-file");
|
||||
file->close();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ TEST_SETUP
|
|||
auto file = file_or_error.release_value();
|
||||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
if (!file->read_entire_buffer(content.bytes()))
|
||||
VERIFY_NOT_REACHED();
|
||||
MUST(file->read_entire_buffer(content.bytes()));
|
||||
DeprecatedString test_data { content.bytes() };
|
||||
|
||||
auto tests = JsonParser(test_data).parse().value().as_array();
|
||||
|
|
|
@ -96,17 +96,17 @@ TEST_CASE(test_TLS_hello_handshake)
|
|||
loop.quit(0);
|
||||
};
|
||||
|
||||
if (!tls->write_entire_buffer("GET / HTTP/1.1\r\nHost: "_b)) {
|
||||
if (tls->write_entire_buffer("GET / HTTP/1.1\r\nHost: "_b).is_error()) {
|
||||
FAIL("write(0) failed");
|
||||
return;
|
||||
}
|
||||
|
||||
auto the_server = DEFAULT_SERVER;
|
||||
if (!tls->write_entire_buffer(the_server.bytes())) {
|
||||
if (tls->write_entire_buffer(the_server.bytes()).is_error()) {
|
||||
FAIL("write(1) failed");
|
||||
return;
|
||||
}
|
||||
if (!tls->write_entire_buffer("\r\nConnection : close\r\n\r\n"_b)) {
|
||||
if (tls->write_entire_buffer("\r\nConnection : close\r\n\r\n"_b).is_error()) {
|
||||
FAIL("write(2) failed");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue