]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move to using internal file functions
authorAlan T. DeKok <aland@freeradius.org>
Mon, 16 Oct 2023 13:13:24 +0000 (09:13 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 Oct 2023 13:13:24 +0000 (09:13 -0400)
src/tests/modules/linelog/linelog-delim.unlang
src/tests/modules/linelog/linelog-escapes.unlang
src/tests/modules/linelog/linelog-multi.unlang
src/tests/modules/linelog/linelog.unlang
src/tests/modules/linelog/linelog_xlat.unlang

index 760b5803e90238011ab427f25fa4477f111da2a0..fd447d70333cc8191268e16a92c7258e6a88e6d3 100644 (file)
@@ -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")
index cb93aac3ec6fcd6e97df20cbaa9696762f03f15f..04079fd41509d935c17447d378382101ad06472f 100644 (file)
@@ -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");
index d4e7adecea6da347f606ecaf0c6996b3686299b4..60ace6bd6657b1b38bd9fac81cbac8811c6febc1 100644 (file)
@@ -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")
index 417d8d3f9a603278ac1aa4a331e0648cac2eec73..ec0bd84465c576819a28cd16d91f5b71b2c4e829 100644 (file)
@@ -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")
index 6662a88979edf738ec11c7102fd6fb5bd53c2d93..ae256f666eba70a1e230e11007e6a318a3d1f917 100644 (file)
@@ -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")