svn commit: r359277 - head/usr.sbin/newsyslog/tests
Mark Johnston
markj at FreeBSD.org
Tue Mar 24 18:17:10 UTC 2020
Author: markj
Date: Tue Mar 24 18:16:56 2020
New Revision: 359277
URL: https://svnweb.freebsd.org/changeset/base/359277
Log:
Add regression tests for newsyslog.conf's p flag.
While here do a bit of cleanup:
- declare local variables as such,
- make tmpdir_create() clean up logfile directories, to handle a
previously interrupt test run more gracefully.
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Modified:
head/usr.sbin/newsyslog/tests/legacy_test.sh
Modified: head/usr.sbin/newsyslog/tests/legacy_test.sh
==============================================================================
--- head/usr.sbin/newsyslog/tests/legacy_test.sh Tue Mar 24 18:16:36 2020 (r359276)
+++ head/usr.sbin/newsyslog/tests/legacy_test.sh Tue Mar 24 18:16:56 2020 (r359277)
@@ -194,7 +194,8 @@ ckstr()
tmpdir_create()
{
- mkdir -p ${TMPDIR}/log ${TMPDIR}/alog
+ rm -rf ${TMPDIR}/log ${TMPDIR}/alog
+ mkdir ${TMPDIR}/log ${TMPDIR}/alog
cd ${TMPDIR}/log
}
@@ -211,6 +212,8 @@ run_newsyslog()
}
tests_normal_rotate() {
+ local dir ext name_postfix newsyslog_args
+
ext="$1"
dir="$2"
@@ -286,6 +289,8 @@ tests_normal_rotate() {
}
tests_normal_rotate_keepn() {
+ local cnt dir ext name_postfix newsyslog_args
+
cnt="$1"
ext="$2"
dir="$3"
@@ -354,6 +359,8 @@ tests_normal_rotate_keepn() {
}
tests_time_rotate() {
+ local dir ext name_postfix newsyslog_args
+
ext="$1"
dir="$2"
@@ -413,6 +420,8 @@ tests_time_rotate() {
}
tests_rfc5424() {
+ local dir ext name_postfix newsyslog_args
+
ext="$1"
dir="$2"
@@ -451,7 +460,73 @@ tests_rfc5424() {
tmpdir_clean
}
-echo 1..180
+tests_p_flag_rotate() {
+ local ext
+
+ ext="$1"
+
+ tmpdir_create
+
+ begin "create file"
+ run_newsyslog -C
+ ckfe $LOGFNAME
+ cknt ${LOGFNAME}.0
+ cknt ${LOGFNAME}.0${ext}
+ end
+
+ begin "rotate p flag 1 ${ext}"
+ run_newsyslog
+ ckfe $LOGFNAME
+ ckfe ${LOGFNAME}.0
+ cknt ${LOGFNAME}.0${ext}
+ run_newsyslog
+ ckfe $LOGFNAME
+ ckfe ${LOGFNAME}.0
+ cknt ${LOGFNAME}.0${ext}
+ ckfe ${LOGFNAME}.1${ext}
+ run_newsyslog
+ ckfe $LOGFNAME
+ ckfe ${LOGFNAME}.0
+ cknt ${LOGFNAME}.0${ext}
+ ckfe ${LOGFNAME}.1${ext}
+ ckfe ${LOGFNAME}.2${ext}
+ end
+
+ tmpdir_clean
+}
+
+tests_normal_rotate_recompress() {
+ local ext
+
+ ext=".gz"
+
+ tmpdir_create
+
+ begin "create file recompress"
+ run_newsyslog -C
+ ckfe $LOGFNAME
+ cknt ${LOGFNAME}.0${ext}
+ end
+
+ begin "rotate normal 1"
+ run_newsyslog
+ ckfe $LOGFNAME
+ ckfe ${LOGFNAME}.0${ext}
+ cknt ${LOGFNAME}.1${ext}
+ end
+
+ begin "rotate recompress 1"
+ gunzip ${LOGFNAME}.0${ext}
+ ckfe ${LOGFNAME}.0
+ cknt ${LOGFNAME}.0${ext}
+ run_newsyslog
+ ckfe $LOGFNAME
+ ckfe ${LOGFNAME}.0${ext}
+ ckfe ${LOGFNAME}.1${ext}
+ end
+}
+
+echo 1..185
mkdir -p ${TMPDIR}
cd ${TMPDIR}
@@ -556,5 +631,11 @@ tests_time_rotate "zst" "${TMPDIR}/alog/"
echo "$LOGFPATH5424 640 3 * @T00 NCT" > newsyslog.conf
echo "$LOGFPATH 640 3 * @T00 NC" >> newsyslog.conf
tests_rfc5424
+
+echo "$LOGFPATH 640 3 * @T00 NCpZ" > newsyslog.conf
+tests_p_flag_rotate ".gz"
+
+echo "$LOGFPATH 640 3 * @T00 NCZ" > newsyslog.conf
+tests_normal_rotate_recompress
rm -rf "${TMPDIR}"
More information about the svn-src-all
mailing list