Skip to content

Commit

Permalink
Add net_unittests to test target (#2675)
Browse files Browse the repository at this point in the history
b/330748091
  • Loading branch information
sherryzy authored Mar 27, 2024
2 parents 658d285 + 13371f6 commit 1cd8a70
Show file tree
Hide file tree
Showing 13 changed files with 1,983 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cobalt/build/cobalt_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def GetTestTargets(self):
'memory_store_test',
'metrics_test',
'network_test',
'net_unittests',
'overlay_info_test',
'persistent_settings_test',
'png_utils_test',
Expand All @@ -157,7 +158,6 @@ def GetTestTargets(self):
]
# return [
# 'layout_tests',
# 'net_unittests',
# ]

def GetTestBlackBoxTargets(self):
Expand Down
1,928 changes: 1,928 additions & 0 deletions net/BUILD.gn

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions net/cert/pki/test_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ bool ReadVerifyCertChainTestFromFile(const std::string& file_path_ascii,
std::string ReadTestFileToString(const std::string& file_path_ascii) {
// Compute the full path, relative to the src/ directory.
base::FilePath src_root;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_TEST_DATA, &src_root);
#else
base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root);
#endif
base::FilePath filepath = src_root.AppendASCII(file_path_ascii);

// Read the full contents of the file.
Expand Down
4 changes: 4 additions & 0 deletions net/disk_cache/simple/simple_file_enumerator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ namespace {

base::FilePath GetRoot() {
base::FilePath root;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_TEST_DATA, &root);
#else
base::PathService::Get(base::DIR_SOURCE_ROOT, &root);
#endif
return root.AppendASCII("net")
.AppendASCII("data")
.AppendASCII("cache_tests")
Expand Down
4 changes: 4 additions & 0 deletions net/filter/brotli_source_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class BrotliSourceStreamTest : public PlatformTest {

// Get the path of data directory.
base::FilePath data_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_TEST_DATA, &data_dir);
#else
base::PathService::Get(base::DIR_SOURCE_ROOT, &data_dir);
#endif
data_dir = data_dir.AppendASCII("net");
data_dir = data_dir.AppendASCII("data");
data_dir = data_dir.AppendASCII("filter_unittests");
Expand Down
2 changes: 1 addition & 1 deletion net/spdy/fuzzing/hpack_fuzz_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ TEST(HpackFuzzUtilTest, ValidFuzzExamplesRegressionTest) {
base::FilePath source_root;
// TODO: b/330184432 Implement base::DIR_SOURCE_ROOT for Starboard.
#if defined(STARBOARD)
base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root);
ASSERT_TRUE(base::PathService::Get(base::DIR_TEST_DATA, &source_root));
#else
ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root));
#endif
Expand Down
4 changes: 2 additions & 2 deletions net/test/embedded_test_server/embedded_test_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ void EmbeddedTestServer::ServeFilesFromSourceDirectory(
base::StringPiece relative) {
base::FilePath test_data_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir);
CHECK(base::PathService::Get(base::DIR_TEST_DATA, &test_data_dir));
#else
CHECK(base::PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
#endif
Expand All @@ -850,7 +850,7 @@ base::FilePath EmbeddedTestServer::GetFullPathFromSourceDirectory(
const base::FilePath& relative) {
base::FilePath test_data_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir);
CHECK(base::PathService::Get(base::DIR_TEST_DATA, &test_data_dir));
#else
CHECK(base::PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ TEST_P(EmbeddedTestServerTest, RegisterRequestHandler) {
TEST_P(EmbeddedTestServerTest, ServeFilesFromDirectory) {
base::FilePath src_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir);
ASSERT_TRUE(base::PathService::Get(base::DIR_TEST_DATA, &src_dir));
#else
ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
#endif
Expand Down Expand Up @@ -275,7 +275,7 @@ TEST_P(EmbeddedTestServerTest, MockHeadersWithoutCRLF) {

base::FilePath src_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir);
ASSERT_TRUE(base::PathService::Get(base::DIR_TEST_DATA, &src_dir));
#else
ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
#endif
Expand Down Expand Up @@ -703,7 +703,7 @@ class EmbeddedTestServerThreadingTestDelegate
EmbeddedTestServer server(type_, protocol_);
base::FilePath src_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir);
ASSERT_TRUE(base::PathService::Get(base::DIR_TEST_DATA, &src_dir));
#else
ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
#endif
Expand Down
4 changes: 4 additions & 0 deletions net/test/test_data_directory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ base::FilePath GetTestNetDirectory() {
base::FilePath src_root;
{
base::ScopedAllowBlockingForTesting allow_blocking;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_TEST_DATA, &src_root);
#else
base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root);
#endif
}

return src_root.Append(kNetRelativePath);
Expand Down
24 changes: 23 additions & 1 deletion net/third_party/quiche/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,23 @@ if (!is_ios && false) {
}
}

if (use_hacky_cobalt_changes) {
copy("test_data") {
if (is_starboard) {
install_content = true
}
visibility = [ ":quiche_tests" ]
testonly = true
sources = [
"src/quiche/common/platform/api/testdir/README.md",
"src/quiche/common/platform/api/testdir/a/b/c/d/e",
"src/quiche/common/platform/api/testdir/a/subdir/testfile",
"src/quiche/common/platform/api/testdir/a/z",
"src/quiche/common/platform/api/testdir/testfile",
]
outputs = [ "$sb_static_contents_output_data_dir/test/{{source_root_relative_dir}}/{{source_file_part}}" ]
}
} else {
bundle_data("test_data") {
visibility = [ ":quiche_tests" ]
testonly = true
Expand All @@ -1413,6 +1430,7 @@ bundle_data("test_data") {
outputs = [ "{{bundle_resources_dir}}/" +
"{{source_root_relative_dir}}/{{source_file_part}}" ]
}
}

source_set("quiche_tests") {
check_includes = false
Expand Down Expand Up @@ -1668,6 +1686,7 @@ source_set("quiche_tests") {
public_configs = [ ":quiche_config" ]

deps = [
":test_data",
"//net",
"//net:quic_test_tools",
"//net:simple_quic_tools",
Expand Down Expand Up @@ -1709,9 +1728,12 @@ source_set("quiche_tests") {
"src/quiche/quic/core/congestion_control/send_algorithm_test.cc",
"src/quiche/quic/core/crypto/quic_client_session_cache_test.cc",
"src/quiche/quic/core/quic_trace_visitor_test.cc",
"src/quiche/quic/core/tls_client_handshaker_test.cc",
"src/quiche/quic/test_tools/simulator/quic_endpoint_test.cc",

# TODO: b/331437821
"src/quiche/common/platform/api/quiche_file_utils_test.cc",
"src/quiche/quic/tools/quic_memory_cache_backend_test.cc",

# Re-enable once we use c++20.
"src/quiche/common/capsule_test.cc",
"src/quiche/http2/adapter/oghttp2_adapter_test.cc",
Expand Down
4 changes: 4 additions & 0 deletions net/third_party/quiche/src/quiche/quic/core/tls_handshaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ void TlsHandshaker::AdvanceHandshake() {
!is_connection_closed()) {
QUIC_VLOG(1) << "SSL_do_handshake failed; SSL_get_error returns "
<< ssl_error;
#if defined(STARBOARD)
ERR_print_errors_fp(nullptr);
#else
ERR_print_errors_fp(stderr);
#endif
if (dont_close_connection_in_tls_alert_callback_ &&
last_tls_alert_.has_value()) {
QUIC_RELOADABLE_FLAG_COUNT_N(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

#include <memory>
#include <sstream>
#if defined(USE_HACKY_COBALT_CHANGES)
#include <unistd.h>
#endif

#include "quiche/quic/platform/api/quic_ip_address.h"
#include "quiche/quic/platform/api/quic_test.h"
Expand Down Expand Up @@ -96,7 +93,7 @@ TEST(QuicSocketAddress, Normalize) {

// TODO(vasilvv): either ensure this works on all platforms, or deprecate and
// remove this API.
#if defined(__linux__) && !defined(ANDROID)
#if defined(__linux__) && !defined(ANDROID) && !defined(STARBOARD)
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class ContentDecoderToolTest : public PlatformTest {

// Get the path of data directory.
base::FilePath data_dir;
#if defined(STARBOARD)
base::PathService::Get(base::DIR_TEST_DATA, &data_dir);
#else
base::PathService::Get(base::DIR_SOURCE_ROOT, &data_dir);
#endif
data_dir = data_dir.AppendASCII("net");
data_dir = data_dir.AppendASCII("data");
data_dir = data_dir.AppendASCII("filter_unittests");
Expand Down

0 comments on commit 1cd8a70

Please sign in to comment.