#! /bin/bash export TZ=UTC export YES_COLOR=1 lnav_test="${top_builddir}/src/lnav-test" unset XDG_CONFIG_HOME run_cap_test ${lnav_test} -nN \ -c ";SELECT 1 = ?" run_cap_test ${lnav_test} -n \ -c ";.read nonexistent-file" \ ${test_dir}/logfile_empty.0 run_test ${lnav_test} -n \ -c ";.read ${test_dir}/file_for_dot_read.sql" \ -c ':write-csv-to -' \ ${test_dir}/logfile_syslog.0 check_output ".read did not work?" < logfile_json.json.gz dd if=logfile_json.json.gz of=logfile_json-trunc.json.gz bs=64 count=2 # TODO re-enable this #run_test ${lnav_test} -n \ # -c ";SELECT content FROM lnav_file" \ # logfile_json-trunc.json.gz #check_error_output "invalid gzip file working?" < 100000' \ -c ':switch-to-view db' \ ${test_dir}/logfile_access_log.0 check_output "out-of-range query failed?" < -100000' \ ${test_dir}/logfile_access_log.0 run_test ${lnav_test} -n \ -c ';select log_time from access_log where log_line < -10000' \ -c ':switch-to-view db' \ ${test_dir}/logfile_access_log.0 check_output "out-of-range query failed?" < -10000' \ ${test_dir}/logfile_access_log.0 run_test ${lnav_test} -n \ -c ';select log_time from access_log where log_line < 0' \ -c ':switch-to-view db' \ ${test_dir}/logfile_access_log.0 check_output "out-of-range query failed?" <= 0' \ -c ':switch-to-view db' \ ${test_dir}/logfile_access_log.0 run_cap_test ${lnav_test} -n \ -c ';select sc_bytes from access_log' \ -c ':spectrogram sc_bytes' \ ${test_dir}/logfile_access_log.0 run_cap_test ${lnav_test} -n \ -c ';select log_time,sc_bytes from access_log' \ -c ':spectrogram sc_byes' \ ${test_dir}/logfile_access_log.0 run_cap_test ${lnav_test} -n \ -c ';select log_time,c_ip from access_log' \ -c ':spectrogram c_ip' \ ${test_dir}/logfile_access_log.0 run_cap_test env TZ=UTC LC_ALL=C ${lnav_test} -n \ -c ':spectrogram bro_response_body_len' \ ${test_dir}/logfile_bro_http.log.0 run_cap_test ${lnav_test} -n \ -c ';select log_time,sc_bytes from access_log order by log_time desc' \ -c ':spectrogram sc_bytes' \ ${test_dir}/logfile_access_log.0 cp ${srcdir}/logfile_syslog_with_mixed_times.0 logfile_syslog_with_mixed_times_test.0 touch -t 201511030923 logfile_syslog_with_mixed_times_test.0 run_test ${lnav_test} -n \ -c ";select log_time,log_actual_time from syslog_log" \ -c ':write-csv-to -' \ logfile_syslog_with_mixed_times_test.0 check_output "log_actual_time column not working" < 1,middle 2,middle EOF run_test ${lnav_test} -n \ -c ";update access_log set log_part = 'middle' where log_line = 1" \ -c ";update access_log set log_part = NULL where log_line = 1" \ -c ';select log_line, log_part from access_log' \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 check_output "setting log_part is not working" < 1, 2, EOF run_test ${lnav_test} -n \ -c ";update access_log set log_part = 'middle' where log_line = 1" \ -c ";update access_log set log_part = NULL where log_line = 2" \ -c ';select log_line, log_part from access_log' \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 check_output "setting log_part is not working" < 1,middle 2,middle EOF run_cap_test ${lnav_test} -n \ -I "${top_srcdir}/test" \ -c ";select * from web_status" \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 run_cap_test ${lnav_test} -n \ -c ";select * from access_log" \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 run_cap_test ${lnav_test} -n \ -c ";select * from access_log where log_level >= 'warning'" \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 # XXX The timestamp on the file is used to determine the year for syslog files. touch -t 200711030923 ${test_dir}/logfile_syslog.0 run_cap_test ${lnav_test} -n \ -c ";select * from syslog_log" \ -c ':write-csv-to -' \ ${test_dir}/logfile_syslog.0 run_test ${lnav_test} -n \ -c ";select * from syslog_log where log_time >= NULL" \ -c ':write-csv-to -' \ ${test_dir}/logfile_syslog.0 check_output "log_time collation failed on null" <= datetime('2007-11-03T09:47:02.000')" \ -c ':write-csv-to -' \ ${test_dir}/logfile_syslog.0 check_output "log_time collation is wrong" < 60000" \ -c ':write-to -' \ ${test_dir}/logfile_access_log.0 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" <,2015-04-07 00:49:42.000 1,middle,2015-04-07 05:49:53.000 18,middle,2015-04-07 07:31:56.000 20,middle,2015-04-07 07:31:56.000 21,end,2015-04-07 07:31:56.000 22,end,2015-04-07 07:32:56.000 EOF run_test ${lnav_test} -n \ -c ":goto 1" \ -c ":partition-name middle" \ -c ":clear-partition" \ -c ";select log_line, log_part from access_log" \ -c ":write-csv-to -" \ ${test_dir}/logfile_access_log.0 check_output "clear-partition does not work" < 1, 2, EOF run_test ${lnav_test} -n \ -c ":goto 1" \ -c ":partition-name middle" \ -c ":goto 2" \ -c ":clear-partition" \ -c ";select log_line, log_part from access_log" \ -c ":write-csv-to -" \ ${test_dir}/logfile_access_log.0 check_output "clear-partition does not work when in the middle of a part" < 1, 2, EOF # test the partitions defined in the format run_cap_test ${lnav_test} -n \ -I ${test_dir} \ -c ";SELECT log_line, log_part, log_body FROM syslog_log" \ -c ":write-csv-to -" \ ${test_dir}/logfile_partitions.0 run_cap_test ${lnav_test} -n \ -c ";SELECT * FROM openam_log" \ -c ":write-json-to -" \ ${test_dir}/logfile_openam.0 touch -t 200711030000 ${srcdir}/logfile_for_join.0 run_cap_test ${lnav_test} -d "/tmp/lnav.err" -n \ -c ";select log_line, col_0 from logline" \ ${test_dir}/logfile_for_join.0 run_cap_test ${lnav_test} -d "/tmp/lnav.err" -n \ -c ";select col_0 from logline where log_line > 4" \ ${test_dir}/logfile_for_join.0 run_test ${lnav_test} -d "/tmp/lnav.err" -n \ -c ":goto 1" \ -c ":create-logline-table join_group" \ -c ":goto 2" \ -c ";select logline.log_line as llline, join_group.log_line as jgline from logline, join_group where logline.col_0 = join_group.col_2" \ -c ':write-csv-to -' \ ${test_dir}/logfile_for_join.0 check_output "create-logline-table is not working" < 0" \ -c ":write-csv-to -" \ ${test_dir}/logfile_multiline.0 check_output "create-search-table is not working with where clause?" <\w+), World!" \ -c ";select word, typeof(word) from search_test1" \ -c ":write-csv-to -" \ ${test_dir}/logfile_multiline.0 check_output "create-search-table is not working?" <\d+)" \ -c ";select typeof(ethnum) from search_test1" \ -c ":write-csv-to -" \ ${test_dir}/logfile_syslog.2 check_output "regex type guessing is not working?" < EOF run_test ${lnav_test} -n \ -c ";SELECT regexp_capture.content FROM access_log, regexp_capture(access_log.cs_version, 'HTTP/(\d+\.\d+)') WHERE regexp_capture.capture_index = 1" \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 check_output "joining log table with regexp_capture is not working?" <