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
24 changes: 4 additions & 20 deletions proxy/logging/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,37 +69,21 @@ liblogging_a_SOURCES = \

check_PROGRAMS = \
test_LogUtils \
test_LogUtils2 \
test_RolledLogDeleter

TESTS = \
test_LogUtils \
test_LogUtils2 \
test_RolledLogDeleter
TESTS = $(check_PROGRAMS)

test_LogUtils_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DTEST_LOG_UTILS

test_LogUtils_SOURCES = \
test_LogUtils.cc

test_LogUtils_LDADD = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/iocore/eventsystem/libinkevent.a

test_LogUtils2_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DTEST_LOG_UTILS \
-I$(abs_top_srcdir)/tests/include

test_LogUtils2_SOURCES = \
test_LogUtils_SOURCES = \
LogUtils.cc \
unit-tests/BufferWriterFormat.cc \
unit-tests/test_LogUtils2.cc
unit-tests/test_LogUtils.cc

test_LogUtils2_LDADD = \
test_LogUtils_LDADD = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/iocore/eventsystem/libinkevent.a
Expand Down
104 changes: 0 additions & 104 deletions proxy/logging/test_LogUtils.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
limitations under the License.
*/

#include <string_view>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <cstdio>

#include <tscore/ink_assert.h>
#include <tscore/ink_align.h>

#include <LogUtils.h>

#include "test_LogUtils.h"
Comment thread
masaori335 marked this conversation as resolved.
Resolved
#include "unit-tests/test_LogUtils.h"

#define CATCH_CONFIG_MAIN
#include "catch.hpp"

#include <cstring>

using namespace LogUtils;

namespace
Expand Down Expand Up @@ -115,9 +119,6 @@ TEST_CASE("LogUtilsHttp", "[LUHP]")
test(nullptr, 0, "", 1);
}

#include <cstdlib>
#include <iostream>

void
_ink_assert(const char *a, const char *f, int line)
{
Expand All @@ -129,6 +130,7 @@ _ink_assert(const char *a, const char *f, int line)
void
RecSignalManager(int, char const *, std::size_t)
{
ink_release_assert(false);
}

TEST_CASE("get_unrolled_filename parses possible log files as expected", "[get_unrolled_filename]")
Expand All @@ -153,3 +155,51 @@ TEST_CASE("get_unrolled_filename parses possible log files as expected", "[get_u
constexpr ts::TextView no_dot = "logging_yaml";
REQUIRE(get_unrolled_filename(no_dot) == no_dot);
}

TEST_CASE("LogUtils pure escapify url", "[pure_esc_url]")
{
char input[][32] = {
" ",
"%",
"% ",
"%20",
};
const char *expected[] = {
"%20",
"%25",
"%25%20",
"%2520",
};
char output[128];
int output_len;

int n = sizeof(input) / sizeof(input[0]);
for (int i = 0; i < n; ++i) {
LogUtils::pure_escapify_url(NULL, input[i], std::strlen(input[i]), &output_len, output, 128);
CHECK(std::string_view(output) == expected[i]);
}
}

TEST_CASE("LogUtils escapify url", "[esc_url]")
{
char input[][32] = {
" ",
"%",
"% ",
"%20",
};
const char *expected[] = {
"%20",
"%25",
"%25%20",
"%20",
};
char output[128];
int output_len;

int n = sizeof(input) / sizeof(input[0]);
for (int i = 0; i < n; ++i) {
LogUtils::escapify_url(NULL, input[i], std::strlen(input[i]), &output_len, output, 128);
CHECK(std::string_view(output) == expected[i]);
}
}
2 changes: 1 addition & 1 deletion proxy/logging/unit-tests/test_LogUtils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file

Header file for shared declarations/definitions for test_LogUtils2.cc and LogUtils.h for unit testing.
Header file for shared declarations/definitions for test_LogUtils.cc and LogUtils.h for unit testing.

@section license License

Expand Down