util,tests: Updated compiler-tests to support paths with spaces
authorBobby R. Bruce <bbruce@ucdavis.edu>
Sat, 18 Jul 2020 06:02:37 +0000 (23:02 -0700)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Mon, 20 Jul 2020 19:46:04 +0000 (19:46 +0000)
This script was failing if the gem5 directory path contained a space.
E.g: `/home/bobbys home/gem5`. This script has thereby been improved to
handle this.

Change-Id: Id56ff5a0e9aa31eef14de2111b040f7f2b0b286c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31534
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
util/compiler-tests.sh

index 30ce637039d38a268c300028c1cd3f77a59a7ba4..c586c273e226f341472cf706f89a82938000f3df 100755 (executable)
@@ -70,14 +70,14 @@ test_dir="${gem5_root}/.compile-test-out"
 exits="${test_dir}/exit-codes.csv"
 
 # Create the testing output directory and files
-rm -rf $test_dir_final
-rm -rf $test_dir
-mkdir $test_dir
-touch $exits
-echo "compiler,build_target,exit_code" >> $exits
+rm -rf "${test_dir_final}"
+rm -rf "${test_dir}"
+mkdir "${test_dir}"
+touch "${exits}"
+echo "compiler,build_target,exit_code" >> "${exits}"
 
 for compiler in ${images[@]}; do
-    echo "Starting build tests with '$compiler'..."
+    echo "Starting build tests with '${compiler}'..."
     # Generate a randomized list of build targets
     build_permutation=($(shuf -i 0-$((${#builds[@]} - 1)) ))
 
@@ -96,33 +96,34 @@ for compiler in ${images[@]}; do
     # Grab compiler image
     docker pull $repo_name >/dev/null
 
-    mkdir "$test_dir/$compiler"
+    mkdir "${test_dir}/${compiler}"
 
     for build_index in ${build_indices[@]}; do
         for build_opt in ${opts[@]}; do
             build="${builds[$build_index]}"
             build_out="build/$build/gem5$build_opt"
-            build_stdout="$test_dir/$compiler/$build$build_opt.stdout"
-            build_stderr="$test_dir/$compiler/$build$build_opt.stderr"
+            build_stdout="${test_dir}/${compiler}/${build}${build_opt}.stdout"
+            build_stderr="${test_dir}/${compiler}/${build}${build_opt}.stderr"
 
             # Clean the build
             rm -rf "${build_dir}"
 
-            touch $build_stdout
-            touch $build_stderr
+            touch "${build_stdout}"
+            touch "${build_stderr}"
 
-            echo "  * Building target '$build$build_opt' with '$compiler'..."
+            echo "  * Building target '${build}${build_opt}' with '${compiler}'..."
 
             # Build with container
             {
-                docker run --rm -v ${gem5_root}:/gem5 -u $UID:$GID -w /gem5 \
-                    $repo_name scons $build_out $build_args
-            }>$build_stdout 2>$build_stderr
+                docker run --rm -v "${gem5_root}":"/gem5" -u $UID:$GID \
+                    -w /gem5 $repo_name scons "${build_out}" "${build_args}"
+            }>"${build_stdout}" 2>"${build_stderr}"
             result=$?
 
-            echo "$compiler,$build/gem5$build_opt,$result" >> $exits
-            if [ $result -ne 0 ]; then
-                echo "  ! Failed with exit code $result."
+            echo "${compiler},${build}/gem5${build_opt},${result}" >>"${exits}"
+
+            if [ ${result} -ne 0 ]; then
+                echo "  ! Failed with exit code ${result}."
             else
                 echo "    Done."
             fi