From: Alan T. DeKok Date: Mon, 16 Oct 2023 13:13:24 +0000 (-0400) Subject: move to using internal file functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56b989e900a673786c296dbe2919a5b274a5d6d7;p=thirdparty%2Ffreeradius-server.git move to using internal file functions --- diff --git a/src/tests/modules/linelog/linelog-delim.unlang b/src/tests/modules/linelog/linelog-delim.unlang index 760b5803e90..fd447d70333 100644 --- a/src/tests/modules/linelog/linelog-delim.unlang +++ b/src/tests/modules/linelog/linelog-delim.unlang @@ -3,20 +3,7 @@ # # Remove old log files # -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_delim.log"` - - # - # We can only over-ride actions in an "actions" subsection, - # and then only as the last item in a group. - # - actions { - fail = 1 - } -} -if (fail) { - ok -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_delim.log") linelog_fmt_delim &Tmp-String-0 := `/bin/sh -c "tail -n1 $ENV{MODULE_TEST_DIR}/test_delim.log"` @@ -40,4 +27,4 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_delim.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_delim.log") diff --git a/src/tests/modules/linelog/linelog-escapes.unlang b/src/tests/modules/linelog/linelog-escapes.unlang index cb93aac3ec6..04079fd4150 100644 --- a/src/tests/modules/linelog/linelog-escapes.unlang +++ b/src/tests/modules/linelog/linelog-escapes.unlang @@ -3,16 +3,7 @@ # # Remove old log files # -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_escapes.log"` - - actions { - fail = 1 - } -} -if (fail) { - ok -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_escapes.log"); # Raw attribute value should be written out without further molestation. # Because the value is wrapped in '' the \n is left as \n. @@ -20,7 +11,7 @@ if (fail) { &control.Tmp-String-1 := 'foo\nbar' linelog_escapes -&Tmp-String-0 := `/bin/sh -c "tail -n2 $ENV{MODULE_TEST_DIR}/test_escapes.log"` +&Tmp-String-0 := `/bin/sh -c "tail -n1 $ENV{MODULE_TEST_DIR}/test_escapes.log"` &Tmp-String-1 := "%hex(%{Tmp-String-0})" # @@ -74,4 +65,4 @@ else { # Fixme... needs completing. Too many broken escaping things. # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_escapes.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_escapes.log"); diff --git a/src/tests/modules/linelog/linelog-multi.unlang b/src/tests/modules/linelog/linelog-multi.unlang index d4e7adecea6..60ace6bd665 100644 --- a/src/tests/modules/linelog/linelog-multi.unlang +++ b/src/tests/modules/linelog/linelog-multi.unlang @@ -3,16 +3,7 @@ # # Remove old log files # -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_multi.log"` - - actions { - fail = 1 - } -} -if (fail) { - ok -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_multi.log") # Check multiple string type attributes are logged correctly &control.Tmp-String-0 := 'test_multi_str' @@ -73,4 +64,4 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_multi.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_multi.log") diff --git a/src/tests/modules/linelog/linelog.unlang b/src/tests/modules/linelog/linelog.unlang index 417d8d3f9a6..ec0bd84465c 100644 --- a/src/tests/modules/linelog/linelog.unlang +++ b/src/tests/modules/linelog/linelog.unlang @@ -3,16 +3,7 @@ # # Remove old log files # -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_a.log"` - - actions { - fail = 1 - } -} -if (fail) { - ok -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_a.log") # Check linelog fails over to the default message (an xlat expansion) &control.Tmp-String-0 := 'test_default' @@ -42,7 +33,7 @@ else { } # Check it's not overwriting the same line repeatedly -&Tmp-String-0 := `/bin/sh -c "head -n1 $ENV{MODULE_TEST_DIR}/test_a.log"` +&Tmp-String-0 := %file.head("$ENV{MODULE_TEST_DIR}/test_a.log"); if (&Tmp-String-0 == 'bob default') { test_pass @@ -108,19 +99,10 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_a.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_a.log") # Remove old log files -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_b.log"` - - actions { - fail = 1 - } -} -if (fail) { - ok -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_b.log") # Check behaviour when we don't have a default configured (should not create new file) &control.Tmp-String-0 := 'test_default' @@ -162,19 +144,10 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_b.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_b.log") # Remove old log files -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_c.log"` - - actions { - fail = 1 - } -} -if (fail) { - ok -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_c.log") # Check behaviour using an attribute ref as a path &control.Tmp-String-0 := '.messages.test_xlat' @@ -251,19 +224,11 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_c.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_c.log") # Remove old log files -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_d.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_d.log") - actions { - fail = 1 - } -} -if (fail) { - ok -} linelog_fmt &Tmp-String-0 := `/bin/sh -c "tail -n1 $ENV{MODULE_TEST_DIR}/test_d.log"` @@ -276,26 +241,17 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_d.log"` +%file.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 -} +%file.rm("$ENV{MODULE_TEST_DIR}/test_d.log") # 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"` +&Tmp-String-0 := %file.head("$ENV{MODULE_TEST_DIR}/test_e.log") if (&Tmp-String-0 == "Log started %{control.Tmp-String-1}") { test_pass @@ -334,4 +290,4 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_e.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_e.log") diff --git a/src/tests/modules/linelog/linelog_xlat.unlang b/src/tests/modules/linelog/linelog_xlat.unlang index 6662a88979e..ae256f666eb 100644 --- a/src/tests/modules/linelog/linelog_xlat.unlang +++ b/src/tests/modules/linelog/linelog_xlat.unlang @@ -3,20 +3,8 @@ # # Remove old log files # -group { - &Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_xlat.log"` +%file.rm("$ENV{MODULE_TEST_DIR}/test_xlat.log") - # - # We can only over-ride actions in an "actions" subsection, - # and then only as the last item in a group. - # - actions { - fail = 1 - } -} -if (fail) { - ok -} if (%{linelog_fmt_delim_xlat:bob} != 5) { test_fail } @@ -44,8 +32,7 @@ else { } # Remove the file -&Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_xlat.log"` - +%file.rm("$ENV{MODULE_TEST_DIR}/test_xlat.log") # Try with some handcrafted JSON @@ -63,3 +50,6 @@ if (&Tmp-String-0 == '{ "foo" : "bar", "baz" : "boink" }, ') { else { test_fail } + +# Remove the file +%file.rm("$ENV{MODULE_TEST_DIR}/test_xlat.log")