#! /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" <,/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,-,,/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,-,,/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" <,/vmw/vSphere/default/vmkboot.gz,gPXE/0.9.7,-,HTTP/1.0,46210,404 EOF # XXX The timestamp on the file is used to determine the year for syslog files. touch -t 201311030923 ${test_dir}/logfile_syslog.0 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" <,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" <,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" <,sudo,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 * 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" <,/vmw/cgi/tramp,gPXE/0.9.7,-,HTTP/1.0,134,200 1,middle,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,middle,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 ":goto 1" \ -c ":partition-name middle" \ -c ":clear-partition" \ -c ";select * from access_log" \ -c ":write-csv-to -" \ ${test_dir}/logfile_access_log.0 check_output "clear-partition does not work" <,/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,-,,/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,-,,/vmw/vSphere/default/vmkernel.gz,gPXE/0.9.7,-,HTTP/1.0,78929,200 EOF run_test ${lnav_test} -n \ -c ":goto 1" \ -c ":partition-name middle" \ -c ":goto 2" \ -c ":clear-partition" \ -c ";select * 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" <,/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,-,,/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,-,,/vmw/vSphere/default/vmkernel.gz,gPXE/0.9.7,-,HTTP/1.0,78929,200 EOF run_test ${lnav_test} -n \ -c ";SELECT * FROM openam_log" \ -c ":write-json-to -" \ ${test_dir}/logfile_openam.0 check_output "" <http://openam.vagrant.dev/openam\\\\\\\\n\\\\\\\\n\\\\\\\\n\\\\\\\\nhttp://openam.vagrant.dev/openam\\\\\\\\n\\\\\\\\n\\\\\\\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tFf2OW4yvGWWvlcwcNSZJmTJ8ARvVYOMEVNbsT4OFcfu2/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": "p.0", "log_time": "2014-06-15 01:04:52.000", "log_idle_msecs": 0, "log_level": "trace", "log_mark": 0, "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 ":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" < sudo EOF # Create a dummy database for the next couple of tests to consume. run_test ${lnav_test} -n \ -c ";ATTACH DATABASE 'simple-db.db' as 'db'" \ -c ";CREATE TABLE IF NOT EXISTS db.person ( id integer PRIMARY KEY, first_name text, last_name, age integer )" \ -c ";INSERT INTO db.person(id, first_name, last_name, age) VALUES (0, 'Phil', 'Myman', 30)" \ -c ";INSERT INTO db.person(id, first_name, last_name, age) VALUES (1, 'Lem', 'Hewitt', 35)" \ -c ";DETACH DATABASE 'db'" \ /dev/null check_output "Could not create db?" <