mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[tests] add some tests that use headless mode
This commit is contained in:
parent
10eb9617b1
commit
5a04a44381
@ -5,7 +5,10 @@ export top_srcdir
|
|||||||
|
|
||||||
# The top build directory, derived from the path to this script.
|
# The top build directory, derived from the path to this script.
|
||||||
top_builddir=`dirname $0`
|
top_builddir=`dirname $0`
|
||||||
|
export top_builddir
|
||||||
|
|
||||||
|
test_dir="@abssrcdir@/test"
|
||||||
|
export test_dir
|
||||||
|
|
||||||
# The full path of the test case
|
# The full path of the test case
|
||||||
test_file=$1
|
test_file=$1
|
||||||
@ -52,8 +55,8 @@ run_test() {
|
|||||||
check_output() {
|
check_output() {
|
||||||
diff -u ${test_file_base}_${test_num}.tmp - > ${test_file_base}_${test_num}.diff
|
diff -u ${test_file_base}_${test_num}.tmp - > ${test_file_base}_${test_num}.diff
|
||||||
if test $? -ne 0; then
|
if test $? -ne 0; then
|
||||||
echo $LAST_TEST
|
echo $LAST_TEST
|
||||||
echo $1
|
echo $1
|
||||||
cat ${test_file_base}_${test_num}.diff
|
cat ${test_file_base}_${test_num}.diff
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -414,6 +414,10 @@ COMMANDS
|
|||||||
Delete an SQL table created by the 'create-logline-table'
|
Delete an SQL table created by the 'create-logline-table'
|
||||||
command.
|
command.
|
||||||
|
|
||||||
|
switch-to-view <view-name>
|
||||||
|
Switch the display to the given view, which can be one of:
|
||||||
|
help, log, text, histogram, db, and schema.
|
||||||
|
|
||||||
|
|
||||||
SQL QUERIES (experimental)
|
SQL QUERIES (experimental)
|
||||||
-----------
|
-----------
|
||||||
|
71
src/lnav.cc
71
src/lnav.cc
@ -135,7 +135,7 @@ static const int HIST_ZOOM_LEVELS = sizeof(HIST_ZOOM_VALUES) /
|
|||||||
static bookmark_type_t BM_EXAMPLE;
|
static bookmark_type_t BM_EXAMPLE;
|
||||||
static bookmark_type_t BM_QUERY;
|
static bookmark_type_t BM_QUERY;
|
||||||
|
|
||||||
const char *lnav_view_strings[LNV__MAX] = {
|
const char *lnav_view_strings[LNV__MAX + 1] = {
|
||||||
"log",
|
"log",
|
||||||
"text",
|
"text",
|
||||||
"help",
|
"help",
|
||||||
@ -144,6 +144,8 @@ const char *lnav_view_strings[LNV__MAX] = {
|
|||||||
"db",
|
"db",
|
||||||
"example",
|
"example",
|
||||||
"schema",
|
"schema",
|
||||||
|
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *view_titles[LNV__MAX] = {
|
static const char *view_titles[LNV__MAX] = {
|
||||||
@ -1040,6 +1042,28 @@ void redo_search(lnav_view_t view_index)
|
|||||||
lnav_data.ld_scroll_broadcaster.invoke(tc);
|
lnav_data.ld_scroll_broadcaster.invoke(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void open_schema_view(void)
|
||||||
|
{
|
||||||
|
textview_curses *schema_tc = &lnav_data.ld_views[LNV_SCHEMA];
|
||||||
|
string schema;
|
||||||
|
|
||||||
|
dump_sqlite_schema(lnav_data.ld_db, schema);
|
||||||
|
|
||||||
|
schema += "\n\n-- Virtual Table Definitions --\n\n";
|
||||||
|
for (log_vtab_manager::iterator vtab_iter =
|
||||||
|
lnav_data.ld_vtab_manager->begin();
|
||||||
|
vtab_iter != lnav_data.ld_vtab_manager->end();
|
||||||
|
++vtab_iter) {
|
||||||
|
schema += vtab_iter->second->get_table_statement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (schema_tc->get_sub_source() != NULL) {
|
||||||
|
delete schema_tc->get_sub_source();
|
||||||
|
}
|
||||||
|
|
||||||
|
schema_tc->set_sub_source(new plain_text_source(schema));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that the view is on the top of the view stack.
|
* Ensure that the view is on the top of the view stack.
|
||||||
*
|
*
|
||||||
@ -1050,6 +1074,10 @@ void ensure_view(textview_curses *expected_tc)
|
|||||||
textview_curses *tc = lnav_data.ld_view_stack.top();
|
textview_curses *tc = lnav_data.ld_view_stack.top();
|
||||||
|
|
||||||
if (tc != expected_tc) {
|
if (tc != expected_tc) {
|
||||||
|
if (expected_tc == &lnav_data.ld_views[LNV_SCHEMA]) {
|
||||||
|
open_schema_view();
|
||||||
|
}
|
||||||
|
|
||||||
toggle_view(expected_tc);
|
toggle_view(expected_tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2008,29 +2036,6 @@ string execute_command(string cmdline)
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void open_schema_view(void)
|
|
||||||
{
|
|
||||||
textview_curses *schema_tc = &lnav_data.ld_views[LNV_SCHEMA];
|
|
||||||
string schema;
|
|
||||||
|
|
||||||
dump_sqlite_schema(lnav_data.ld_db, schema);
|
|
||||||
|
|
||||||
schema += "\n\n-- Virtual Table Definitions --\n\n";
|
|
||||||
for (log_vtab_manager::iterator vtab_iter =
|
|
||||||
lnav_data.ld_vtab_manager->begin();
|
|
||||||
vtab_iter != lnav_data.ld_vtab_manager->end();
|
|
||||||
++vtab_iter) {
|
|
||||||
schema += vtab_iter->second->get_table_statement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (schema_tc->get_sub_source() != NULL) {
|
|
||||||
delete schema_tc->get_sub_source();
|
|
||||||
}
|
|
||||||
|
|
||||||
schema_tc->set_sub_source(new plain_text_source(schema));
|
|
||||||
ensure_view(schema_tc);
|
|
||||||
}
|
|
||||||
|
|
||||||
string execute_sql(string sql, string &alt_msg)
|
string execute_sql(string sql, string &alt_msg)
|
||||||
{
|
{
|
||||||
db_label_source & dls = lnav_data.ld_db_rows;
|
db_label_source & dls = lnav_data.ld_db_rows;
|
||||||
@ -2047,7 +2052,7 @@ string execute_sql(string sql, string &alt_msg)
|
|||||||
if (stmt_str == ".schema") {
|
if (stmt_str == ".schema") {
|
||||||
alt_msg = "";
|
alt_msg = "";
|
||||||
|
|
||||||
open_schema_view();
|
ensure_view(&lnav_data.ld_views[LNV_SCHEMA]);
|
||||||
|
|
||||||
lnav_data.ld_mode = LNM_PAGING;
|
lnav_data.ld_mode = LNM_PAGING;
|
||||||
return "";
|
return "";
|
||||||
@ -3123,10 +3128,13 @@ static void looper(void)
|
|||||||
|
|
||||||
lnav_data.ld_rl_view = &rlc;
|
lnav_data.ld_rl_view = &rlc;
|
||||||
|
|
||||||
lnav_data.ld_rl_view->
|
lnav_data.ld_rl_view->add_possibility(
|
||||||
add_possibility(LNM_COMMAND, "graph", "\\d+(?:\\.\\d+)?");
|
LNM_COMMAND, "graph", "\\d+(?:\\.\\d+)?");
|
||||||
lnav_data.ld_rl_view->
|
lnav_data.ld_rl_view->add_possibility(
|
||||||
add_possibility(LNM_COMMAND, "graph", "([:= \\t]\\d+(?:\\.\\d+)?)");
|
LNM_COMMAND, "graph", "([:= \\t]\\d+(?:\\.\\d+)?)");
|
||||||
|
|
||||||
|
lnav_data.ld_rl_view->add_possibility(
|
||||||
|
LNM_COMMAND, "viewname", lnav_view_strings);
|
||||||
|
|
||||||
(void)signal(SIGINT, sigint);
|
(void)signal(SIGINT, sigint);
|
||||||
(void)signal(SIGTERM, sigint);
|
(void)signal(SIGTERM, sigint);
|
||||||
@ -3277,7 +3285,7 @@ static void looper(void)
|
|||||||
if (!initial_build &&
|
if (!initial_build &&
|
||||||
lnav_data.ld_log_source.text_line_count() == 0 &&
|
lnav_data.ld_log_source.text_line_count() == 0 &&
|
||||||
!lnav_data.ld_other_files.empty()) {
|
!lnav_data.ld_other_files.empty()) {
|
||||||
open_schema_view();
|
ensure_view(&lnav_data.ld_views[LNV_SCHEMA]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initial_build && lnav_data.ld_flags & LNF_HELP) {
|
if (!initial_build && lnav_data.ld_flags & LNF_HELP) {
|
||||||
@ -4102,7 +4110,8 @@ int main(int argc, char *argv[])
|
|||||||
for (vis_line_t vl = tc->get_top();
|
for (vis_line_t vl = tc->get_top();
|
||||||
vl < tc->get_inner_height();
|
vl < tc->get_inner_height();
|
||||||
++vl, ++y) {
|
++vl, ++y) {
|
||||||
while (los->list_value_for_overlay(*tc, y, al)) {
|
while (los != NULL &&
|
||||||
|
los->list_value_for_overlay(*tc, y, al)) {
|
||||||
printf("%s\n", line.c_str());
|
printf("%s\n", line.c_str());
|
||||||
++y;
|
++y;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ typedef enum {
|
|||||||
LNV__MAX
|
LNV__MAX
|
||||||
} lnav_view_t;
|
} lnav_view_t;
|
||||||
|
|
||||||
extern const char *lnav_view_strings[LNV__MAX];
|
extern const char *lnav_view_strings[LNV__MAX + 1];
|
||||||
|
|
||||||
/** The status bars. */
|
/** The status bars. */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -1178,6 +1178,31 @@ static string com_add_test(string cmdline, vector<string> &args)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string com_switch_to_view(string cmdline, vector<string> &args)
|
||||||
|
{
|
||||||
|
string retval = "";
|
||||||
|
|
||||||
|
if (args.size() == 0) {
|
||||||
|
args.push_back("viewname");
|
||||||
|
}
|
||||||
|
else if (args.size() > 1) {
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
for (int lpc = 0; lnav_view_strings[lpc] && !found; lpc++) {
|
||||||
|
if (strcasecmp(args[1].c_str(), lnav_view_strings[lpc]) == 0) {
|
||||||
|
ensure_view(&lnav_data.ld_views[lpc]);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
retval = "error: invalid view name -- " + args[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
void init_lnav_commands(readline_context::command_map_t &cmd_map)
|
void init_lnav_commands(readline_context::command_map_t &cmd_map)
|
||||||
{
|
{
|
||||||
cmd_map["adjust-log-time"] = com_adjust_log_time;
|
cmd_map["adjust-log-time"] = com_adjust_log_time;
|
||||||
@ -1203,6 +1228,7 @@ void init_lnav_commands(readline_context::command_map_t &cmd_map)
|
|||||||
cmd_map["partition-name"] = com_partition_name;
|
cmd_map["partition-name"] = com_partition_name;
|
||||||
cmd_map["session"] = com_session;
|
cmd_map["session"] = com_session;
|
||||||
cmd_map["summarize"] = com_summarize;
|
cmd_map["summarize"] = com_summarize;
|
||||||
|
cmd_map["switch-to-view"] = com_switch_to_view;
|
||||||
|
|
||||||
if (getenv("LNAV_SRC") != NULL) {
|
if (getenv("LNAV_SRC") != NULL) {
|
||||||
cmd_map["add-test"] = com_add_test;
|
cmd_map["add-test"] = com_add_test;
|
||||||
|
@ -209,8 +209,6 @@ static void sigabrt(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lnav_log_orig_termios != NULL) {
|
if (lnav_log_orig_termios != NULL) {
|
||||||
char *bp, buf[1024];
|
|
||||||
|
|
||||||
tcsetattr(STDOUT_FILENO, TCSAFLUSH, lnav_log_orig_termios);
|
tcsetattr(STDOUT_FILENO, TCSAFLUSH, lnav_log_orig_termios);
|
||||||
}
|
}
|
||||||
fprintf(stderr, CRASH_MSG, crash_path);
|
fprintf(stderr, CRASH_MSG, crash_path);
|
||||||
|
@ -616,6 +616,7 @@ void external_log_format::annotate(shared_buffer_ref &line,
|
|||||||
for (size_t lpc = 0; lpc < pat.p_value_by_index.size(); lpc++) {
|
for (size_t lpc = 0; lpc < pat.p_value_by_index.size(); lpc++) {
|
||||||
const value_def &vd = pat.p_value_by_index[lpc];
|
const value_def &vd = pat.p_value_by_index[lpc];
|
||||||
const struct scaling_factor *scaling = NULL;
|
const struct scaling_factor *scaling = NULL;
|
||||||
|
pcre_context::capture_t *cap = pc[vd.vd_index];
|
||||||
shared_buffer_ref field;
|
shared_buffer_ref field;
|
||||||
|
|
||||||
if (vd.vd_unit_field_index >= 0) {
|
if (vd.vd_unit_field_index >= 0) {
|
||||||
@ -634,7 +635,8 @@ void external_log_format::annotate(shared_buffer_ref &line,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
field.subset(line, pc[vd.vd_index]->c_begin, pc[vd.vd_index]->length());
|
log_info("field %s %s", vd.vd_name.c_str(), string(&line.get_data()[cap->c_begin], cap->length()).c_str());
|
||||||
|
field.subset(line, cap->c_begin, cap->length());
|
||||||
|
|
||||||
values.push_back(logline_value(vd.vd_name,
|
values.push_back(logline_value(vd.vd_name,
|
||||||
vd.vd_kind,
|
vd.vd_kind,
|
||||||
@ -642,8 +644,8 @@ void external_log_format::annotate(shared_buffer_ref &line,
|
|||||||
vd.vd_identifier,
|
vd.vd_identifier,
|
||||||
scaling,
|
scaling,
|
||||||
vd.vd_column,
|
vd.vd_column,
|
||||||
pc[vd.vd_index]->c_begin,
|
cap->c_begin,
|
||||||
pc[vd.vd_index]->c_end));
|
cap->c_end));
|
||||||
|
|
||||||
if (pc[vd.vd_index]->c_begin != -1 && vd.vd_identifier) {
|
if (pc[vd.vd_index]->c_begin != -1 && vd.vd_identifier) {
|
||||||
lr.lr_start = pc[vd.vd_index]->c_begin;
|
lr.lr_start = pc[vd.vd_index]->c_begin;
|
||||||
|
@ -248,6 +248,9 @@ public:
|
|||||||
|
|
||||||
if (next_line == this->end()) {
|
if (next_line == this->end()) {
|
||||||
retval = this->lf_index_size - ll->get_offset();
|
retval = this->lf_index_size - ll->get_offset();
|
||||||
|
if (retval > 0) {
|
||||||
|
retval -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
retval = next_line->get_offset() - ll->get_offset() - 1;
|
retval = next_line->get_offset() - ll->get_offset() - 1;
|
||||||
|
@ -192,6 +192,7 @@ TESTS = \
|
|||||||
test_grep_proc2 \
|
test_grep_proc2 \
|
||||||
test_hist_source \
|
test_hist_source \
|
||||||
test_pcrepp \
|
test_pcrepp \
|
||||||
|
test_sql.sh \
|
||||||
test_sql_coll_func.sh \
|
test_sql_coll_func.sh \
|
||||||
test_sql_fs_func.sh \
|
test_sql_fs_func.sh \
|
||||||
test_sql_str_func.sh \
|
test_sql_str_func.sh \
|
||||||
|
@ -95,7 +95,7 @@ TESTS = test_ansi_scrubber$(EXEEXT) test_auto_fd$(EXEEXT) \
|
|||||||
test_auto_mem$(EXEEXT) test_bookmarks$(EXEEXT) \
|
test_auto_mem$(EXEEXT) test_bookmarks$(EXEEXT) \
|
||||||
test_line_buffer.sh test_line_buffer2$(EXEEXT) \
|
test_line_buffer.sh test_line_buffer2$(EXEEXT) \
|
||||||
test_listview.sh test_grep_proc.sh test_grep_proc2$(EXEEXT) \
|
test_listview.sh test_grep_proc.sh test_grep_proc2$(EXEEXT) \
|
||||||
test_hist_source$(EXEEXT) test_pcrepp$(EXEEXT) \
|
test_hist_source$(EXEEXT) test_pcrepp$(EXEEXT) test_sql.sh \
|
||||||
test_sql_coll_func.sh test_sql_fs_func.sh test_sql_str_func.sh \
|
test_sql_coll_func.sh test_sql_fs_func.sh test_sql_str_func.sh \
|
||||||
test_view_colors.sh test_vt52_curses.sh \
|
test_view_colors.sh test_vt52_curses.sh \
|
||||||
test_top_status$(EXEEXT) test_data_parser.sh \
|
test_top_status$(EXEEXT) test_data_parser.sh \
|
||||||
@ -1187,6 +1187,13 @@ test_pcrepp.log: test_pcrepp$(EXEEXT)
|
|||||||
--log-file $$b.log --trs-file $$b.trs \
|
--log-file $$b.log --trs-file $$b.trs \
|
||||||
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
|
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
|
||||||
"$$tst" $(AM_TESTS_FD_REDIRECT)
|
"$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||||
|
test_sql.sh.log: test_sql.sh
|
||||||
|
@p='test_sql.sh'; \
|
||||||
|
b='test_sql.sh'; \
|
||||||
|
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
|
||||||
|
--log-file $$b.log --trs-file $$b.trs \
|
||||||
|
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
|
||||||
|
"$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||||
test_sql_coll_func.sh.log: test_sql_coll_func.sh
|
test_sql_coll_func.sh.log: test_sql_coll_func.sh
|
||||||
@p='test_sql_coll_func.sh'; \
|
@p='test_sql_coll_func.sh'; \
|
||||||
b='test_sql_coll_func.sh'; \
|
b='test_sql_coll_func.sh'; \
|
||||||
|
104
test/test_sql.sh
Normal file
104
test/test_sql.sh
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
lnav_test="${top_builddir}/src/lnav-test"
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ";select * from access_log" \
|
||||||
|
-c ':write-csv-to -' \
|
||||||
|
${test_dir}/logfile_access_log.0
|
||||||
|
|
||||||
|
check_output "access_log table is not working" <<EOF
|
||||||
|
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,c_ip,cs_method,cs_referer,cs_uri_query,cs_uri_stem,cs_user_agent,cs_username,cs_version,sc_bytes,sc_status
|
||||||
|
0,p.0,2009-07-20 22:59:26.000,0,info,0,192.168.202.254,GET,-,<NULL>,/vmw/cgi/tramp,gPXE/0.9.7,-,HTTP/1.0,134,200
|
||||||
|
1,p.0,2009-07-20 22:59:29.000,3000,error,0,192.168.202.254,GET,-,<NULL>,/vmw/vSphere/default/vmkboot.gz,gPXE/0.9.7,-,HTTP/1.0,46210,404
|
||||||
|
2,p.0,2009-07-20 22:59:29.000,0,info,0,192.168.202.254,GET,-,<NULL>,/vmw/vSphere/default/vmkernel.gz,gPXE/0.9.7,-,HTTP/1.0,78929,200
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ";select * from access_log where log_level >= 'warning'" \
|
||||||
|
-c ':write-csv-to -' \
|
||||||
|
${test_dir}/logfile_access_log.0
|
||||||
|
|
||||||
|
check_output "loglevel collator is not working" <<EOF
|
||||||
|
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,c_ip,cs_method,cs_referer,cs_uri_query,cs_uri_stem,cs_user_agent,cs_username,cs_version,sc_bytes,sc_status
|
||||||
|
1,p.0,2009-07-20 22:59:29.000,3000,error,0,192.168.202.254,GET,-,<NULL>,/vmw/vSphere/default/vmkboot.gz,gPXE/0.9.7,-,HTTP/1.0,46210,404
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ";select * from syslog_log" \
|
||||||
|
-c ':write-csv-to -' \
|
||||||
|
${test_dir}/logfile_syslog.0
|
||||||
|
|
||||||
|
check_output "syslog_log table is not working" <<EOF
|
||||||
|
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,log_hostname,log_pid,log_procname
|
||||||
|
0,p.0,2013-11-03 09:23:38.000,0,error,0,veridian,7998,automount
|
||||||
|
1,p.0,2013-11-03 09:23:38.000,0,info,0,veridian,16442,automount
|
||||||
|
2,p.0,2013-11-03 09:23:38.000,0,error,0,veridian,7999,automount
|
||||||
|
3,p.0,2013-11-03 09:47:02.000,1404000,info,0,veridian,<NULL>,sudo
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ";select * from syslog_log where log_time >= datetime('2013-11-03T09:47:02.000')" \
|
||||||
|
-c ':write-csv-to -' \
|
||||||
|
${test_dir}/logfile_syslog.0
|
||||||
|
|
||||||
|
check_output "log_time collation is wrong" <<EOF
|
||||||
|
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,log_hostname,log_pid,log_procname
|
||||||
|
3,p.0,2013-11-03 09:47:02.000,1404000,info,0,veridian,<NULL>,sudo
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ':filter-in sudo' \
|
||||||
|
-c ";select * from logline" \
|
||||||
|
-c ':write-csv-to -' \
|
||||||
|
${test_dir}/logfile_syslog.0
|
||||||
|
|
||||||
|
check_output "logline table is not working" <<EOF
|
||||||
|
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,log_hostname,log_pid,log_procname,col_0,TTY,PWD,USER,COMMAND
|
||||||
|
0,p.0,2013-11-03 09:47:02.000,0,info,0,veridian,<NULL>,sudo,timstack,pts/6,/auto/wstimstack/rpms/lbuild/test,root,/usr/bin/tail /var/log/messages
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ";update access_log set log_mark = 1 where sc_bytes > 60000" \
|
||||||
|
-c ':write-to -' \
|
||||||
|
${test_dir}/logfile_access_log.0
|
||||||
|
|
||||||
|
check_output "setting log_mark is not working" <<EOF
|
||||||
|
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
export SQL_ENV_VALUE="foo bar,baz"
|
||||||
|
|
||||||
|
|
||||||
|
run_test ${lnav_test} -n \
|
||||||
|
-c ';select $SQL_ENV_VALUE as val' \
|
||||||
|
-c ':write-csv-to -' \
|
||||||
|
${test_dir}/logfile_access_log.0
|
||||||
|
|
||||||
|
check_output "env vars are not working in SQL" <<EOF
|
||||||
|
val
|
||||||
|
"foo bar,baz"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
schema_dump() {
|
||||||
|
${lnav_test} -n -c ';.schema' ${test_dir}/logfile_access_log.0 | head -n7
|
||||||
|
}
|
||||||
|
|
||||||
|
run_test schema_dump
|
||||||
|
|
||||||
|
check_output "schema view is not working" <<EOF
|
||||||
|
ATTACH DATABASE '' AS 'main';
|
||||||
|
CREATE TABLE http_status_codes (
|
||||||
|
status integer PRIMARY KEY,
|
||||||
|
message text,
|
||||||
|
|
||||||
|
FOREIGN KEY(status) REFERENCES access_log(sc_status)
|
||||||
|
);
|
||||||
|
EOF
|
Loading…
Reference in New Issue
Block a user