mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[tests] adding some more coverage
This commit is contained in:
parent
b5406f2cee
commit
d3d527d290
@ -210,4 +210,10 @@ The following configuration options can be used to tune the internals of
|
||||
**lnav** to your liking. The options can be changed using the :code:`:config`
|
||||
command.
|
||||
|
||||
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/tuning
|
||||
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/tuning/properties/archive-manager
|
||||
|
||||
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/tuning/properties/file-vtab
|
||||
|
||||
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/tuning/properties/logfile
|
||||
|
||||
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/tuning/properties/remote/properties/ssh
|
||||
|
@ -335,7 +335,6 @@ add_library(diag STATIC
|
||||
state-extension-functions.cc
|
||||
styling.cc
|
||||
string_attr_type.cc
|
||||
strnatcmp.c
|
||||
text_format.cc
|
||||
textfile_highlighters.cc
|
||||
textfile_sub_source.cc
|
||||
|
@ -257,7 +257,6 @@ noinst_HEADERS = \
|
||||
styling.hh \
|
||||
statusview_curses.hh \
|
||||
string_attr_type.hh \
|
||||
strnatcmp.h \
|
||||
strong_int.hh \
|
||||
sysclip.hh \
|
||||
termios_guard.hh \
|
||||
@ -381,7 +380,6 @@ libdiag_a_SOURCES = \
|
||||
sql_commands.cc \
|
||||
sql_util.cc \
|
||||
state-extension-functions.cc \
|
||||
strnatcmp.c \
|
||||
sysclip.cc \
|
||||
textfile_highlighters.cc \
|
||||
textview_curses.cc \
|
||||
|
@ -15,6 +15,7 @@ add_library(base STATIC
|
||||
network.tcp.cc
|
||||
paths.cc
|
||||
string_util.cc
|
||||
strnatcmp.c
|
||||
time_util.cc
|
||||
|
||||
|
||||
@ -36,6 +37,7 @@ add_library(base STATIC
|
||||
network.tcp.hh
|
||||
paths.hh
|
||||
result.h
|
||||
strnatcmp.h
|
||||
time_util.hh
|
||||
)
|
||||
|
||||
@ -55,9 +57,10 @@ add_executable(test_base
|
||||
humanize.file_size.tests.cc
|
||||
humanize.network.tests.cc
|
||||
humanize.time.tests.cc
|
||||
lnav.gzip.tests.cc
|
||||
string_util.tests.cc
|
||||
network.tcp.tests.cc
|
||||
|
||||
test_base.cc)
|
||||
target_link_libraries(test_base base pcrepp)
|
||||
target_link_libraries(test_base base pcrepp ZLIB::zlib)
|
||||
add_test(NAME test_base COMMAND test_base)
|
||||
|
@ -42,6 +42,7 @@ noinst_HEADERS = \
|
||||
paths.hh \
|
||||
result.h \
|
||||
string_util.hh \
|
||||
strnatcmp.h \
|
||||
time_util.hh
|
||||
|
||||
libbase_a_SOURCES = \
|
||||
@ -58,6 +59,7 @@ libbase_a_SOURCES = \
|
||||
network.tcp.cc \
|
||||
paths.cc \
|
||||
string_util.cc \
|
||||
strnatcmp.c \
|
||||
time_util.cc
|
||||
|
||||
check_PROGRAMS = \
|
||||
@ -67,6 +69,7 @@ test_base_SOURCES = \
|
||||
humanize.file_size.tests.cc \
|
||||
humanize.network.tests.cc \
|
||||
humanize.time.tests.cc \
|
||||
lnav.gzip.tests.cc \
|
||||
string_util.tests.cc \
|
||||
test_base.cc
|
||||
|
||||
|
@ -363,11 +363,6 @@ public:
|
||||
return strcmp(this->get(), rhs) != 0;
|
||||
}
|
||||
|
||||
intern_string_t &operator=(const intern_string_t &rhs) {
|
||||
this->ist_interned_string = rhs.ist_interned_string;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
const intern_string *ist_interned_string;
|
||||
};
|
||||
|
55
src/base/lnav.gzip.tests.cc
Normal file
55
src/base/lnav.gzip.tests.cc
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright (c) 2021, Timothy Stack
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Timothy Stack nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <zlib.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "doctest.hh"
|
||||
|
||||
#include "base/lnav.gzip.hh"
|
||||
|
||||
TEST_CASE("lnav::gzip::uncompress") {
|
||||
{
|
||||
auto u_res = lnav::gzip::uncompress("empty", nullptr, 0);
|
||||
|
||||
CHECK(u_res.isErr());
|
||||
CHECK(u_res.unwrapErr() ==
|
||||
"unable to uncompress: empty -- buffer error");
|
||||
}
|
||||
|
||||
{
|
||||
auto u_res = lnav::gzip::uncompress("garbage", "abc", 3);
|
||||
|
||||
CHECK(u_res.isErr());
|
||||
CHECK(u_res.unwrapErr() ==
|
||||
"unable to uncompress: garbage -- incorrect header check");
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "doctest.hh"
|
||||
|
||||
#include "base/strnatcmp.h"
|
||||
#include "base/string_util.hh"
|
||||
|
||||
TEST_CASE ("endswith")
|
||||
@ -72,3 +73,18 @@ TEST_CASE ("truncate_to")
|
||||
truncate_to(str, 5);
|
||||
CHECK(str == "01\u22efyz");
|
||||
}
|
||||
|
||||
TEST_CASE("strnatcmp") {
|
||||
{
|
||||
constexpr const char *n1 = "010";
|
||||
constexpr const char *n2 = "020";
|
||||
|
||||
CHECK(strnatcmp(strlen(n1), n1, strlen(n2), n2) < 0);
|
||||
}
|
||||
{
|
||||
constexpr const char *n1 = "2";
|
||||
constexpr const char *n2 = "10";
|
||||
|
||||
CHECK(strnatcmp(strlen(n1), n1, strlen(n2), n2) < 0);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "log_level.hh"
|
||||
#include "strnatcmp.h"
|
||||
#include "base/strnatcmp.h"
|
||||
|
||||
#define MAX_ADDR_LEN 128
|
||||
|
||||
|
@ -1765,6 +1765,9 @@ static void looper()
|
||||
toggle_view(&lnav_data.ld_views[LNV_HELP]);
|
||||
initial_build = true;
|
||||
}
|
||||
if (!initial_build && lnav_data.ld_flags & LNF_NO_DEFAULT) {
|
||||
initial_build = true;
|
||||
}
|
||||
if (lnav_data.ld_log_source.text_line_count() > 0 ||
|
||||
lnav_data.ld_text_source.text_line_count() > 0 ||
|
||||
!lnav_data.ld_active_files.fc_other_files.empty()) {
|
||||
|
@ -61,4 +61,9 @@ target_include_directories(
|
||||
../fmtlib
|
||||
${CMAKE_CURRENT_BINARY_DIR}/..
|
||||
)
|
||||
target_link_libraries(drive_tailer base tailercommon tailerpp)
|
||||
target_link_libraries(drive_tailer
|
||||
base
|
||||
tailercommon
|
||||
tailerpp
|
||||
ZLIB::zlib
|
||||
)
|
||||
|
@ -872,7 +872,7 @@ static void usage()
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" To record a session for playback later:\n"
|
||||
" $ scripty -f output.0 -- myCursesApp\n"
|
||||
" $ scripty -a output.0 -- myCursesApp\n"
|
||||
"\n"
|
||||
" To replay the recorded session:\n"
|
||||
" $ scripty -e input.0 -- myCursesApp\n";
|
||||
|
@ -1,5 +1,15 @@
|
||||
#! /bin/bash
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":goto 1" \
|
||||
-c ":mark" \
|
||||
-c ":hide-unmarked-lines" \
|
||||
-c ":goto 0" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
check_output "hide-lines-before does not work?" <<EOF
|
||||
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":unix-time" \
|
||||
@ -1105,6 +1115,35 @@ Hello, World!
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -Nnv \
|
||||
-c ":hide-lines-before 2009-07-20T22:59:29" \
|
||||
-c ":hide-lines-before"
|
||||
|
||||
check_output "hide-lines-before with no args does not work?" <<EOF
|
||||
info: hiding lines before 2009-07-20 22:59:29.000
|
||||
info: hiding lines before 2009-07-20 22:59:29.000
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -Nnv \
|
||||
-c ":hide-lines-after 2009-07-20T22:59:29" \
|
||||
-c ":hide-lines-after"
|
||||
|
||||
check_output "hide-lines-after with no args does not work?" <<EOF
|
||||
info: hiding lines after 2009-07-20 22:59:29.000
|
||||
info: hiding lines after 2009-07-20 22:59:29.000
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -Nnv \
|
||||
-c ":hide-lines-before 2009-07-20T22:00:29" \
|
||||
-c ":hide-lines-after 2009-07-20T22:59:29" \
|
||||
-c ":hide-lines-before"
|
||||
|
||||
check_output "hide-lines-after with no args does not work?" <<EOF
|
||||
info: hiding lines before 2009-07-20 22:00:29.000
|
||||
info: hiding lines after 2009-07-20 22:59:29.000
|
||||
info: hiding lines before 2009-07-20 22:00:29.000 and after 2009-07-20 22:59:29.000
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":hide-lines-before 2009-07-20T22:59:29" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
Loading…
Reference in New Issue
Block a user