From: Nick Porter Date: Fri, 11 Nov 2022 13:55:38 +0000 (+0000) Subject: Add test for linelog header option X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dd38a9a18f2a1e29aacde289a8f3563bb215be5;p=thirdparty%2Ffreeradius-server.git Add test for linelog header option --- diff --git a/src/tests/modules/linelog/linelog.unlang b/src/tests/modules/linelog/linelog.unlang index 1dfe9820558..417d8d3f9a6 100644 --- a/src/tests/modules/linelog/linelog.unlang +++ b/src/tests/modules/linelog/linelog.unlang @@ -277,3 +277,61 @@ else { # Remove the file &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_d.log"` + +# Remove old log files +group { + &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_e.log"` + + actions { + fail = 1 + } +} +if (fail) { + ok +} + +# Set attribute used in header line +&control.Tmp-String-1 := "%t" + +linelog_header + +&Tmp-String-0 := `/bin/sh -c "head -n1 $ENV{MODULE_TEST_DIR}/test_e.log"` + +if (&Tmp-String-0 == "Log started %{control.Tmp-String-1}") { + test_pass +} +else { + test_fail +} + +&Tmp-String-0 := `/bin/sh -c "tail -n1 $ENV{MODULE_TEST_DIR}/test_e.log"` + +if (&Tmp-String-0 == 'bob,olobobob') { + test_pass +} +else { + test_fail +} + +linelog_header + +&Tmp-String-0 := `/bin/sh -c "tail -n1 $ENV{MODULE_TEST_DIR}/test_e.log"` + +if (&Tmp-String-0 == 'bob,olobobob') { + test_pass +} +else { + test_fail +} + +&Tmp-Integer-0 := `/bin/sh -c "cat $ENV{MODULE_TEST_DIR}/test_e.log | wc -l"` + +if (&Tmp-Integer-0 == 3) { + test_pass +} +else { + test_fail +} + +# Remove the file +&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_e.log"` diff --git a/src/tests/modules/linelog/module.conf b/src/tests/modules/linelog/module.conf index 0d8f86c43ac..b441d094335 100644 --- a/src/tests/modules/linelog/module.conf +++ b/src/tests/modules/linelog/module.conf @@ -68,6 +68,18 @@ linelog linelog_fmt { format = &User-Name } +# Used by linelog +linelog linelog_header { + destination = file + + file { + filename = $ENV{MODULE_TEST_DIR}/test_e.log + } + + header = "Log started %{control.Tmp-String-1}" + format = "%{User-Name},%{User-Password}" +} + # Used by linelog escapes linelog linelog_escapes { destination = file