#! /bin/bash lnav_test="${top_builddir}/src/lnav-test" run_test ${lnav_test} -n \ -c ";.read nonexistent-file" \ ${test_dir}/logfile_empty.0 check_error_output "read worked with a nonexistent file?" <,2015-11-03 09:23:38.000,0,info,0,,,,syslog_log,# is up,aff2bfc3c61e7b86329b83190f0912b3 1,,2015-11-03 09:23:38.000,0,info,0,,,,syslog_log,# is up,aff2bfc3c61e7b86329b83190f0912b3 2,,2015-11-03 09:23:38.000,0,info,0,,,,syslog_log,# is down,506560b3c73dee057732e69a3c666718 EOF run_test ${lnav_test} -n \ -c ";SELECT sc_substatus FROM w3c_log" \ -c ":write-json-to -" \ ${test_dir}/logfile_w3c.3 check_output "w3c quoted strings are not handled correctly?" < 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?" < EOF run_test ${lnav_test} -n \ -c ":goto 2" \ -c ";SELECT log_top_datetime()" \ ${test_dir}/logfile_uwsgi.0 check_output "log_top_datetime() not working?" < EOF run_test ${lnav_test} -n \ -c ";SELECT * FROM uwsgi_log LIMIT 1" \ -c ':switch-to-view db' \ ${test_dir}/logfile_uwsgi.0 check_output "uwsgi not working?" < 2016-03-13 22:49:12.000 0 info 0 127.0.0.1 696 POST /update_metrics 38 HTTP/1.1 0 3 88185 1 0.129 1 1 47 378 9 200 EOF run_test ${lnav_test} -n \ -c ";SELECT s_runtime FROM uwsgi_log LIMIT 5" \ -c ':write-csv-to -' \ ${test_dir}/logfile_uwsgi.0 check_output "uwsgi scaling not working?" <,2011-11-03 00:19:26.452,0,info,0,,,,1320279566.452687,CwFs1P2UcUdlSxD2La,192.168.2.76,52026,132.235.215.119,80,1,GET,www.reddit.com,/,,1.1,Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,0,109978,200,OK,,,,,,,,,,Ftw3fJ2JJF3ntMTL2,,text/html 1,,2011-11-03 00:19:26.831,379,info,0,,,,1320279566.831619,CJxSUgkInyKSHiju1,192.168.2.76,52030,72.21.211.173,80,1,GET,e.thumbs.redditmedia.com,/E-pbDbmiBclPkDaX.jpg,http://www.reddit.com/,1.1,Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,0,2300,200,OK,,,,,,,,,,FFTf9Zdgk3YkfCKo3,,image/jpeg 2,,2011-11-03 00:19:26.831,0,info,0,,,,1320279566.831563,CJwUi9bdB9c1lLW44,192.168.2.76,52029,72.21.211.173,80,1,GET,f.thumbs.redditmedia.com,/BP5bQfy4o-C7cF6A.jpg,http://www.reddit.com/,1.1,Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,0,2272,200,OK,,,,,,,,,,FfXtOj3o7aub4vbs2j,,image/jpeg 3,,2011-11-03 00:19:26.831,0,info,0,,,,1320279566.831473,CoX7zA3OJKGUOSCBY2,192.168.2.76,52027,72.21.211.173,80,1,GET,e.thumbs.redditmedia.com,/SVUtep3Rhg5FTRn4.jpg,http://www.reddit.com/,1.1,Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,0,2562,200,OK,,,,,,,,,,F21Ybs3PTqS6O4Q2Zh,,image/jpeg 4,,2011-11-03 00:19:26.831,0,info,0,,,,1320279566.831643,CT0JIh479jXIGt0Po1,192.168.2.76,52031,72.21.211.173,80,1,GET,f.thumbs.redditmedia.com,/uuy31444rLSyKdHS.jpg,http://www.reddit.com/,1.1,Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,0,1595,200,OK,,,,,,,,,,Fdk0MZ1wQmKWAJ4WH4,,image/jpeg EOF run_test env TZ=UTC ${lnav_test} -n \ -c ";SELECT * FROM bro_http_log WHERE log_level = 'error'" \ -c ":write-csv-to -" \ ${test_dir}/logfile_bro_http.log.0 check_output "bro logs are not recognized?" <,2011-11-03 00:19:49.337,18,error,0,,,,1320279589.337053,CBHHuR1xFnm5C5CQBc,192.168.2.76,52074,74.125.225.76,80,1,GET,i4.ytimg.com,/vi/gDbg_GeuiSY/hqdefault.jpg,,1.1,Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,0,893,404,Not Found,,,,,,,,,,F2GiAw3j1m22R2yIg2,,image/jpeg EOF run_test ${lnav_test} -n \ -c ';select log_time from access_log where log_line > 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 check_output "out-of-range query failed?" < -10000' \ ${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 check_output "range query failed?" < 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_test ${lnav_test} -n \ -I "${top_srcdir}/test" \ -c ";select * from web_status" \ -c ':write-csv-to -' \ ${test_dir}/logfile_access_log.0 check_output "access_log table is not working" <,2009-07-20 22:59:26.000,0,info,0,,,,192.168.202.254,GET,-,,/vmw/cgi/tramp,gPXE/0.9.7,-,HTTP/1.0,134,200, 1,,2009-07-20 22:59:29.000,3000,error,0,,,,192.168.202.254,GET,-,,/vmw/vSphere/default/vmkboot.gz,gPXE/0.9.7,-,HTTP/1.0,46210,404, 2,,2009-07-20 22:59:29.000,0,info,0,,,,192.168.202.254,GET,-,,/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" <,2009-07-20 22:59:29.000,3000,error,0,,,,192.168.202.254,GET,-,,/vmw/vSphere/default/vmkboot.gz,gPXE/0.9.7,-,HTTP/1.0,46210,404, EOF run_test ${lnav_test} -n \ -c ":goto 0" \ -c ";select log_line from access_log where log_level >= 'warning'" \ -c ":switch-to-view log" \ -c ":next-mark query" \ ${test_dir}/logfile_access_log.0 check_output "query bookmark not working?" <,2007-11-03 09:23:38.000,0,error,0,,,,veridian,,7998,,automount,, 1,,2007-11-03 09:23:38.000,0,info,0,,,,veridian,,16442,,automount,, 2,,2007-11-03 09:23:38.000,0,error,0,,,,veridian,,7999,,automount,, 3,,2007-11-03 09:47:02.000,1404000,info,0,,,,veridian,,,,sudo,, EOF 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" <,2007-11-03 09:47:02.000,1404000,info,0,,,,veridian,,,,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" <,2007-11-03 09:47:02.000,0,info,0,,,[1],veridian,,,,sudo,,,0,timstack,pts/6,/auto/wstimstack/rpms/lbuild/test,root,/usr/bin/tail /var/log/messages EOF run_test ${lnav_test} -n \ -c ':goto 1' \ -c ";select log_line, log_pid, col_0 from logline" \ -c ':write-csv-to -' \ ${test_dir}/logfile_syslog.1 check_output "logline table is not working" < 60000" \ -c ':write-to -' \ ${test_dir}/logfile_access_log.0 check_output "setting log_mark is not working" <,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 run_test ${lnav_test} -n \ -c ";SELECT * FROM openam_log" \ -c ":write-json-to -" \ ${test_dir}/logfile_openam.0 check_output "write-json-to isn't working?" <http://openam.vagrant.dev/openam\\\\n\\\\n\\\\n\\\\nhttp://openam.vagrant.dev/openam\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n4uSmVzjovUdQd3px/RcnoxQBsqE=\\\\n\\\\n\\\\n\\\\nhm/grge36uA6j1OWif2bTcvVTwESjmuJa27NxepW0AiV5YlcsHDl7RAIk6k/CjsSero3bxGbm56m\\\\nYncOEi9F1Tu7dS0bfx+vhm/kKTPgwZctf4GWn4qQwP+KeoZywbNj9ShsYJ+zPKzXwN4xBSuPjMxP\\\\nNf5szzjEWpOndQO/uDs=\\\\n\\\\n\\\\n\\\\n\\\\nMIICQDCCAakCBEeNB0swDQYJKoZIhvcNAQEEBQAwZzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNh\\\\nbGlmb3JuaWExFDASBgNVBAcTC1NhbnRhIENsYXJhMQwwCgYDVQQKEwNTdW4xEDAOBgNVBAsTB09w\\\\nZW5TU08xDTALBgNVBAMTBHRlc3QwHhcNMDgwMTE1MTkxOTM5WhcNMTgwMTEyMTkxOTM5WjBnMQsw\\\\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExDDAK\\\\nBgNVBAoTA1N1bjEQMA4GA1UECxMHT3BlblNTTzENMAsGA1UEAxMEdGVzdDCBnzANBgkqhkiG9w0B\\\\nAQEFAAOBjQAwgYkCgYEArSQc/U75GB2AtKhbGS5piiLkmJzqEsp64rDxbMJ+xDrye0EN/q1U5Of+\\\\nRkDsaN/igkAvV1cuXEgTL6RlafFPcUX7QxDhZBhsYF9pbwtMzi4A4su9hnxIhURebGEmxKW9qJNY\\\\nJs0Vo5+IgjxuEWnjnnVgHTs1+mq5QYTA7E6ZyL8CAwEAATANBgkqhkiG9w0BAQQFAAOBgQB3Pw/U\\\\nQzPKTPTYi9upbFXlrAKMwtFf2OW4yvGWWvlcwcNSZJmTJ8ARvVYOMEVNbsT4OFcfu2/PeYoAdiDA\\\\ncGy/F2Zuj8XJJpuQRSE6PtQqBuDEHjjmOQJ0rV/r8mO1ZCtHRhpZ5zYRjhRC9eCbjx9VrFax0JDC\\\\n/FfwWigmrW0Y0Q==\\\\n\\\\n\\\\n\\\\n\\\\nuser@example.com\\\\n\\\\n\\\\n\\\\nhttp://localhost:8086\\\\n\\\\n\\\\nurn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "domain": "dc=openam", "hostname": "192.168.33.1\t", "ipaddr": "Not Available", "loggedby": "cn=dsameuser,ou=DSAME Users,dc=openam", "loginid": "id=openamuser,ou=user,dc=openam", "messageid": "SAML2-37", "modulename": "SAML2.access", "nameid": "user@example.com" }, { "log_line": 1, "log_part": null, "log_time": "2014-06-15 01:04:52.000", "log_idle_msecs": 0, "log_level": "trace", "log_mark": 0, "log_comment": null, "log_tags": null, "log_filters": null, "contextid": "ec5708a7f199678a01", "data": "vagrant|/", "domain": "dc=openam", "hostname": "127.0.1.1\t", "ipaddr": "Not Available", "loggedby": "cn=dsameuser,ou=DSAME Users,dc=openam", "loginid": "cn=dsameuser,ou=DSAME Users,dc=openam", "messageid": "COT-22", "modulename": "COT.access", "nameid": "Not Available" } ] EOF run_test ${lnav_test} -d "/tmp/lnav.err" -n \ -c ";select log_line, log_msg_instance, col_0 from logline" \ ${test_dir}/logfile_for_join.0 check_output "log msg instance is not working" < 4" \ ${test_dir}/logfile_for_join.0 check_output "log msg instance is not working" <,2015-03-24 14:02:50.000,6927348000,info,0,,,,127.0.0.1,GET,,,/includes/js/combined-javascript.js,,-,HTTP/1.1,65508,200, 2,,2015-03-24 14:02:50.000,0,error,0,,,,127.0.0.1,GET,,,/bad.foo,,-,HTTP/1.1,65508,404, EOF run_test ${lnav_test} -n \ -c ";select log_text from generic_log" \ -c ":write-json-to -" \ ${test_dir}/logfile_multiline.0 check_output "multiline data is not right?" < 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?" <