Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/api/InkAPITest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6022,6 +6022,9 @@ REGRESSION_TEST(SDK_API_TSMimeHdrParse)(RegressionTest *test, int /* atype ATS_U
if (TSMBufferDestroy(bufp1) == TS_ERROR) {
SDK_RPRINT(test, "TSMimeHdrParse", "TestCase1", TC_FAIL, "Error in Destroying MBuffer");
}
TSMimeParserDestroy(parser);
*pstatus = REGRESSION_TEST_FAILED;
return;
} else {
start = parse_string;
end = parse_string + strlen(parse_string) + 1;
Expand Down Expand Up @@ -6087,7 +6090,9 @@ REGRESSION_TEST(SDK_API_TSMimeHdrParse)(RegressionTest *test, int /* atype ATS_U
}

field_loc2 = TSMimeHdrFieldNextDup(bufp1, mime_hdr_loc1, field_loc1);
if (compare_field_names(test, bufp1, mime_hdr_loc1, field_loc1, bufp1, mime_hdr_loc1, field_loc2) == TS_ERROR) {
if (field_loc2 == TS_NULL_MLOC) {
SDK_RPRINT(test, "TSMimeHdrFieldNextDup", "TestCase1", TC_FAIL, "TSMimeHdrFieldNextDup returns TS_NULL_MLOC");
} else if (compare_field_names(test, bufp1, mime_hdr_loc1, field_loc1, bufp1, mime_hdr_loc1, field_loc2) == TS_ERROR) {
SDK_RPRINT(test, "TSMimeHdrFieldNextDup", "TestCase1", TC_FAIL, "Incorrect Pointer");
} else {
SDK_RPRINT(test, "TSMimeHdrFieldNextDup", "TestCase1", TC_PASS, "ok");
Expand Down Expand Up @@ -6401,6 +6406,7 @@ REGRESSION_TEST(SDK_API_TSUrlParse)(RegressionTest *test, int /* atype ATS_UNUSE
if (TSMBufferDestroy(bufp) == TS_ERROR) {
SDK_RPRINT(test, "TSUrlParse", url, TC_FAIL, "Error in Destroying MBuffer");
}
continue;
} else {
start = url;
end = url + strlen(url);
Expand Down
38 changes: 23 additions & 15 deletions src/iocore/aio/test_AIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ dump_summary()
double total_secs = 0.0;
for (int i = 0; i < orig_n_accessors; i++) {
double secs = (dev[i]->time_end - dev[i]->time_start) / 1000000000.0;
double ops_sec = (dev[i]->seq_reads + dev[i]->seq_writes + dev[i]->rand_reads) / secs;
double ops_sec = secs > 0.0 ? (dev[i]->seq_reads + dev[i]->seq_writes + dev[i]->rand_reads) / secs : 0.0;
printf("%s: #sr:%d #sw:%d #rr:%d %0.1f secs %0.1f ops/sec\n", dev[i]->path, dev[i]->seq_reads, dev[i]->seq_writes,
dev[i]->rand_reads, secs, ops_sec);
total_secs += secs;
Expand All @@ -198,20 +198,28 @@ dump_summary()
printf("-----------------\n");
printf("aggregate results\n");
printf("-----------------\n");
total_secs /= orig_n_accessors;
float sr = (total_seq_reads * seq_read_size) / total_secs;
sr /= 1024.0 * 1024.0;
float sw = (total_seq_writes * seq_write_size) / total_secs;
sw /= 1024.0 * 1024.0;
float rr = (total_rand_reads * rand_read_size) / total_secs;
rr /= 1024.0 * 1024.0;
printf("%f ops %0.2f mbytes/sec %0.1f ops/sec %0.1f ops/sec/disk seq_read\n", total_seq_reads, sr, total_seq_reads / total_secs,
total_seq_reads / total_secs / n_disk_path);
printf("%f ops %0.2f mbytes/sec %0.1f ops/sec %0.1f ops/sec/disk seq_write\n", total_seq_writes, sw,
total_seq_writes / total_secs, total_seq_writes / total_secs / n_disk_path);
printf("%f ops %0.2f mbytes/sec %0.1f ops/sec %0.1f ops/sec/disk rand_read\n", total_rand_reads, rr,
total_rand_reads / total_secs, total_rand_reads / total_secs / n_disk_path);
printf("%0.2f total mbytes/sec\n", sr + sw + rr);
if (orig_n_accessors > 0) {
total_secs /= orig_n_accessors;
}

if (total_secs > 0.0 && n_disk_path > 0) {
float sr = (total_seq_reads * seq_read_size) / total_secs;
sr /= 1024.0 * 1024.0;
float sw = (total_seq_writes * seq_write_size) / total_secs;
sw /= 1024.0 * 1024.0;
float rr = (total_rand_reads * rand_read_size) / total_secs;
rr /= 1024.0 * 1024.0;

printf("%f ops %0.2f mbytes/sec %0.1f ops/sec %0.1f ops/sec/disk seq_read\n", total_seq_reads, sr, total_seq_reads / total_secs,
total_seq_reads / total_secs / n_disk_path);
printf("%f ops %0.2f mbytes/sec %0.1f ops/sec %0.1f ops/sec/disk seq_write\n", total_seq_writes, sw,
total_seq_writes / total_secs, total_seq_writes / total_secs / n_disk_path);
printf("%f ops %0.2f mbytes/sec %0.1f ops/sec %0.1f ops/sec/disk rand_read\n", total_rand_reads, rr,
total_rand_reads / total_secs, total_rand_reads / total_secs / n_disk_path);
printf("%0.2f total mbytes/sec\n", sr + sw + rr);
} else {
printf("no measurable elapsed time, skipping aggregate rates\n");
}
printf("----------------------------------------------------------\n");

#if TS_USE_LINUX_IO_URING
Expand Down
10 changes: 8 additions & 2 deletions src/iocore/net/unit_tests/test_OCSPStapling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ TEST_CASE("OCSP stapling keeps SSL_CTX certificate map after later init failure"

REQUIRE(SSL_CTX_use_certificate(ctx.get(), good.get()) == 1);

REQUIRE(SSL_CTX_add_extra_chain_cert(ctx.get(), issuer.get()) == 1);
issuer.release();
// SSL_CTX_add_extra_chain_cert() takes ownership of the certificate only when it succeeds, so
// hand the raw pointer over and give it back to the unique_ptr if the call fails.
X509 *issuer_raw = issuer.release();

if (SSL_CTX_add_extra_chain_cert(ctx.get(), issuer_raw) != 1) {
issuer.reset(issuer_raw);
FAIL("SSL_CTX_add_extra_chain_cert failed");
}

REQUIRE(ssl_stapling_init_cert(ctx.get(), good.get(), "server.ocsp.pem", nullptr));
CHECK_FALSE(ssl_stapling_init_cert(ctx.get(), bad.get(), "signed-foo.pem", nullptr));
Expand Down
5 changes: 3 additions & 2 deletions src/proxy/hdrs/unit_tests/test_Huffmancode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ TEST_CASE("values_test", "[proxy][huffman]")
REQUIRE(bytes == -1);
continue;
}
REQUIRE(dst_start[0] == ascii_value);
REQUIRE(bytes == 1);
REQUIRE(dst_start[0] == ascii_value);
}
}

Expand Down Expand Up @@ -336,10 +336,11 @@ TEST_CASE("decoder_roundtrip_fuzz", "[proxy][huffman]")
std::vector<uint8_t> encoded(src_len * 4 + 8);
int64_t enc_len = huffman_encode(encoded.data(), encoded.size(), src.data(), src_len);
REQUIRE(enc_len >= 0);
REQUIRE(enc_len <= static_cast<int64_t>(encoded.size()));

// One byte of headroom guarantees success (see require_decoder_parity).
std::vector<char> decoded(src_len + 1);
int64_t dec_len = huffman_decode(decoded.data(), src_len + 1, encoded.data(), enc_len);
int64_t dec_len = huffman_decode(decoded.data(), src_len + 1, encoded.data(), static_cast<uint32_t>(enc_len));
REQUIRE(dec_len == static_cast<int64_t>(src_len));
REQUIRE(memcmp(decoded.data(), src.data(), src_len) == 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ build_request(int64_t sm_id, HttpSM *sm, sockaddr_in *ip, const char *os_hostnam
}
sm->t_state.request_data.api_info = new HttpApiInfo();
if (ip != nullptr) {
memcpy(&sm->t_state.request_data.src_ip.sa, ip, sizeof(sm->t_state.request_data.src_ip.sa));
memcpy(&sm->t_state.request_data.src_ip.sin, ip, sizeof(*ip));
}
sm->t_state.request_data.xact_start = time(0);

Expand Down
5 changes: 3 additions & 2 deletions src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ SCENARIO("unloading the plugin", "[plugin][core]")
{
REQUIRE_FALSE(sandboxDir.empty());

std::string error;
PluginDebugObject *debugObject = nullptr;
std::string error;

GIVEN("a 'done' function")
{
fs::path pluginConfigPath = fs::path("plugin_testing_calls.so");
RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
PluginDebugObject *debugObject = nullptr;

bool result = loadPlugin(plugin.get(), error, debugObject);
CHECK(true == result);
Expand All @@ -387,6 +387,7 @@ SCENARIO("unloading the plugin", "[plugin][core]")
{
fs::path pluginConfigPath = fs::path("plugin_testing_calls.so");
RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
PluginDebugObject *debugObject = nullptr;

bool result = loadPlugin(plugin.get(), error, debugObject);
CHECK(true == result);
Expand Down
12 changes: 6 additions & 6 deletions src/proxy/http2/test_HPACK.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,13 @@ prepare()
cerr << "Cannot open " << input_dir << endl;
return 1;
}
struct stat st;
char name[PATH_MAX + 1] = "";
strcat(name, input_dir.c_str());
while ((d = readdir(dir)) != nullptr) {
name[input_dir.length()] = '\0';
ink_strlcat(name, d->d_name, sizeof(name));
stat(name, &st);
struct stat st;
string name = input_dir + d->d_name;

if (stat(name.c_str(), &st) != 0) {
continue;
}
if (!S_ISDIR(st.st_mode)) {
++last;
}
Expand Down
19 changes: 15 additions & 4 deletions src/proxy/http2/unit_tests/test_HpackIndexingTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ TEST_CASE("HPACK low level APIs", "[hpack]")
uint8_t buf[BUFSIZE_FOR_REGRESSION_TEST];
int64_t encoded_len = encode_oversized_hpack_index(buf, sizeof(buf), 7, 0x80);

REQUIRE(encoded_len > 0);
REQUIRE(encoded_len <= static_cast<int64_t>(sizeof(buf)));

size_t const block_len = static_cast<size_t>(encoded_len);

HpackIndexingTable indexing_table(4096);
std::unique_ptr<HTTPHdr, void (*)(HTTPHdr *)> headers(new HTTPHdr, destroy_http_hdr);
headers->create(HTTPType::REQUEST);
MIMEField *field = mime_field_create(headers->m_heap, headers->m_http->m_fields_impl);
MIMEFieldWrapper header(field, headers->m_heap, headers->m_http->m_fields_impl);

int64_t len = decode_indexed_header_field(header, buf, buf + encoded_len, indexing_table);
int64_t len = decode_indexed_header_field(header, buf, buf + block_len, indexing_table);

REQUIRE(len == HPACK_ERROR_COMPRESSION_ERROR);
}
Expand Down Expand Up @@ -286,16 +291,22 @@ TEST_CASE("HPACK low level APIs", "[hpack]")
uint8_t buf[BUFSIZE_FOR_REGRESSION_TEST];
int64_t encoded_len = encode_oversized_hpack_index(buf, sizeof(buf), i.prefix, i.flag);
uint8_t value[] = {0x05, 'v', 'a', 'l', 'u', 'e'};
memcpy(buf + encoded_len, value, sizeof(value));
encoded_len += sizeof(value);

REQUIRE(encoded_len > 0);
REQUIRE(encoded_len <= static_cast<int64_t>(sizeof(buf) - sizeof(value)));

size_t block_len = static_cast<size_t>(encoded_len);

memcpy(buf + block_len, value, sizeof(value));
block_len += sizeof(value);

HpackIndexingTable indexing_table(4096);
std::unique_ptr<HTTPHdr, void (*)(HTTPHdr *)> headers(new HTTPHdr, destroy_http_hdr);
headers->create(HTTPType::REQUEST);
MIMEField *field = mime_field_create(headers->m_heap, headers->m_http->m_fields_impl);
MIMEFieldWrapper header(field, headers->m_heap, headers->m_http->m_fields_impl);

int64_t len = decode_literal_header_field(header, buf, buf + encoded_len, indexing_table, MAX_FIELD_SIZE);
int64_t len = decode_literal_header_field(header, buf, buf + block_len, indexing_table, MAX_FIELD_SIZE);

REQUIRE(len == HPACK_ERROR_COMPRESSION_ERROR);
}
Expand Down
12 changes: 9 additions & 3 deletions src/proxy/http2/unit_tests/test_Http2Frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ TEST_CASE("Http2Frame", "[http2][Http2Frame]")
Http2PushPromiseFrame frame(id, flags, pp, hdr_block, hdr_block_len);
int64_t written = frame.write_to(miob);

REQUIRE(written != -1);
REQUIRE(written > 0);
CHECK(written == static_cast<int64_t>(HTTP2_FRAME_HEADER_LEN + sizeof(Http2StreamId) + hdr_block_len));
CHECK(written == miob_r->read_avail());

uint8_t buf[32] = {0};
int64_t read = miob_r->read(buf, written);

REQUIRE(written <= static_cast<int64_t>(sizeof(buf)));

size_t const frame_len = static_cast<size_t>(written);
int64_t read = miob_r->read(buf, written);

CHECK(read == written);

uint8_t expected[] = {
Expand All @@ -58,7 +63,8 @@ TEST_CASE("Http2Frame", "[http2][Http2Frame]")
0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef ///< Header Block Fragment
};

CHECK(memcmp(buf, expected, written) == 0);
REQUIRE(frame_len == sizeof(expected));
CHECK(memcmp(buf, expected, frame_len) == 0);
}

free_MIOBuffer(miob);
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/logging/unit-tests/test_LogAccess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ populate_non_http_sm_data(NonHttpSmLogData &data, std::string_view method, std::
data.owned_path.assign(path.data(), path.size());
data.owned_url = synthesize_target(method, scheme, authority, path);
set_socket_address(data.owned_client_addr, "192.0.2.10:4321"sv);
ats_ip_copy(&data.owned_client_src_addr.sa, &data.owned_client_addr.sa);
ats_ip_copy(&data.owned_client_src_addr, &data.owned_client_addr);
data.m_client_port = ats_ip_port_host_order(&data.owned_client_addr.sa);

add_header_field(data.owned_client_request, PSEUDO_HEADER_METHOD, method);
Expand Down