[logfile] check for truncated files

pull/111/head
Timothy Stack 10 years ago
parent 1b60e49d0b
commit f37ec555bf

@ -26,6 +26,9 @@ test_file_base=`basename $1`
# The current test number for shell based tests.
test_num=0
lnav_test="${top_builddir}/src/lnav-test"
export lnav_test
## BEGIN Functions
LAST_TEST=""

@ -2967,6 +2967,7 @@ static void watch_logfile(string filename, int fd, bool required)
/* It's a new file, load it in. */
logfile *lf = new logfile(filename, fd);
log_info("loading new file: %s", filename.c_str());
lnav_data.ld_files.push_back(lf);
lnav_data.ld_text_source.tss_files.push_back(lf);
break;
@ -3048,8 +3049,6 @@ static bool rescan_files(bool required)
logfile *lf = *file_iter;
if (!lf->exists() || lf->is_closed()) {
std::list<logfile *>::iterator tss_iter;
log_info("file has been deleted/closed -- %s",
lf->get_filename().c_str());
lnav_data.ld_file_names.erase(make_pair(lf->get_filename(), lf->get_fd()));

@ -122,7 +122,8 @@ bool logfile::exists(void) const
}
return this->lf_stat.st_dev == st.st_dev &&
this->lf_stat.st_ino == st.st_ino;
this->lf_stat.st_ino == st.st_ino &&
this->lf_stat.st_size <= st.st_size;
}
void logfile::set_format_base_time(log_format *lf)

@ -1,8 +1,5 @@
#! /bin/bash
lnav_test="${top_builddir}/src/lnav-test"
run_test ${lnav_test} -n \
-c ":adjust-log-time 2010-01-01T00:00:00" \
${test_dir}/logfile_access_log.0

@ -187,3 +187,15 @@ check_output "glog_log level interpreted incorrectly?" <<EOF
0x03
0x05
EOF
cp ${srcdir}/logfile_syslog.0 truncfile.0
run_test ${lnav_test} -n \
-c ";update syslog_log set log_mark = 1 where log_line = 1" \
-c ":write-to truncfile.0" \
-c ":goto 1" \
truncfile.0
check_output "truncated log file not detected" <<EOF
Nov 3 09:23:38 veridian automount[16442]: attempting to mount entry /auto/opt
EOF

Loading…
Cancel
Save