diff --git a/test/README.md b/test/README.md index c6b4af564e5ac10d55825877c4da1043385a215a..6ae50d50268fc085e0b9287eeb7ed14c3dd5cb8b 100644 --- a/test/README.md +++ b/test/README.md @@ -25,13 +25,15 @@ agent * run all docker images - run the agent inside the images, print the JSON generated in execution -Building the images and the agent may take some time, so you can use the options +Building the images and the agent may take some time and through a lot of output, so you can use the options -* `-c` to copy (rsync) the agent into the distribution directories -* `-b [IMAGE_NAME]` to build the docker image specified by IMAGE_NAME or all - of them if none specified -* `-r [IMAGE_NAME]` to run the docker image specified by IMAGE_NAME or all - of them if none specified +* `-c` to copy (rsync) the agent into the distribution directories +* `-b [IMAGE_NAME]` to build the docker image specified by IMAGE_NAME or all + of them if none specified +* `-r [IMAGE_NAME]` to run the docker image specified by IMAGE_NAME or all + of them if none specified +* `-q` to run in quiet mode: redirect stdout to log.txt during + steps "copy" and "build" to execute only part of the flow. Of course, running will not work if the images have not been built once previously. @@ -45,7 +47,6 @@ Currently tested images are * debian * opensuse - Dockerfiles ------------------- diff --git a/test/test.sh b/test/test.sh index 922be165d4e9f8fd81c14de3743e78541a11886c..0eba57fc72a964d79037a4ee7ad7a5fa78cd4cbd 100755 --- a/test/test.sh +++ b/test/test.sh @@ -8,6 +8,7 @@ command -v docker >/dev/null 2>&1 || { echo >&2 "It seems docker is not installe # -c - rsync agent directory into image directory # -b - build only specified image / all images if no argument is provided # -r - run only specified image / all images if no argument is provided +# -q - redirect stdout of rsync and docker build to log.txt file EXECUTE_ALL=true RSYNC_AGENT=false @@ -62,8 +63,13 @@ do fi ;; - \?) - echo "Invalid option: $2" >&2 + -q) + QUIET_MODE=true + shift 1 + ;; + + \?) + echo "Invalid option: $2" >&2 shift ;; esac @@ -80,6 +86,15 @@ then fi +# If quiet mode was selected, redirect stdout to log.txt file +if ($QUIET_MODE) +then + # save stdout + exec 5<&1 + # redirect + exec 1> log.txt +fi + # rsync if ($RSYNC_AGENT) then @@ -119,6 +134,11 @@ then fi +# If quiet mode was selected, restore stdout before running +if ($QUIET_MODE) +then + exec 1<&5 +fi # run agent into images if ($RUN)