aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCyril Hrubis <chrubis@suse.cz>2016-01-25 17:20:24 +0100
committerCyril Hrubis <chrubis@suse.cz>2016-01-26 11:29:44 +0100
commit43955d98fcea2ba2d5dfc53345cf1daa377abbbe (patch)
tree66a135770372e3d2d976d9087a88dc5dd03031f2 /doc
parent44998a6311eddacded5cdacf878d5d4ddcf6321a (diff)
test.sh: Fix ROD redirection && callers
The ROD could not detect failures when the output was redirected into a file since the redirection was handled in the caller. For example doing: ROD echo a > /proc/cpus Would have worked just fine since the $@ in ROD function would contain only 'echo a'. Moreover doing: ROD false > tmpfile Would end up writing the error message to the tmpfile instead of the stdout. For this reasons the ROD has been changed to take special char \> as redirection operator. The only difference is that the > in the ROD command must be prefixed with \ so that it's passed along with the file to the ROD function. The $@ there is split on '>' and the redirection is done inside ROD function which fixes the errors described above. Signed-off-by: Cyril Hrubis <chrubis@suse.cz> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/test-writing-guidelines.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 0c0909adf..1f260cb84 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1249,6 +1249,24 @@ if [ $? -ne 0 ]; then
fi
-------------------------------------------------------------------------------
+WARNING: Keep in mind that output redirection (to a file) happens in the
+ caller rather than in the ROD function and cannot be checked for
+ write errors by the ROD function.
+
+As a matter of a fact doing +ROD echo a > /proc/cpuinfo+ would work just fine
+since the 'ROD' function will only get the +echo a+ part that will run just
+fine.
+
+[source,sh]
+-------------------------------------------------------------------------------
+# Redirect output to a file with ROD
+ROD echo foo \> bar
+-------------------------------------------------------------------------------
+
+Note the '>' is escaped with '\', this causes that the '>' and filename are
+passed to the 'ROD' function as parameters and the 'ROD' function contains
+code to split '$@' on '>' and redirects the output to the file.
+
.tst_fs_has_free
[source,sh]
-------------------------------------------------------------------------------