#! /bin/bash lnav_test="${top_builddir}/src/lnav-test" run_test ${lnav_test} -n \ -c ";SELECT basename(filepath),format,lines,time_offset FROM lnav_file LIMIT 2" \ -c ":write-csv-to -" \ ${test_dir}/logfile_access_log.0 \ ${test_dir}/logfile_access_log.1 check_output "lnav_file table is 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?" <,2013-11-03 09:23:38.000,0,error,0,,,[],veridian,,7998,,automount,, 1,,2013-11-03 09:23:38.000,0,info,0,,,[],veridian,,16442,,automount,, 2,,2013-11-03 09:23:38.000,0,error,0,,,[],veridian,,7999,,automount,, 3,,2013-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('2013-11-03T09:47:02.000')" \ -c ':write-csv-to -' \ ${test_dir}/logfile_syslog.0 check_output "log_time collation is wrong" <,2013-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" <,2013-11-03 09:47:02.000,0,info,0,,,[0],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\\\\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user@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": [ ], "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 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?" <