Normalize run-test arguments

The tests generally call `${RUN} "${@}" ...`.
Use this convention for all tests (${@} being at the start).
This is no-op but makes command logging&diffing easier.

Also fix environment logging - we should log the explicit
small environment now rather than `os.environ`.

Pass missing {test_args} on target (it is present on host&jvm).
{test_args} are test args passed with the "-- --foo" syntax,
whereas {ARGS} are args passed with the "--args=--foo" syntax.
This distinction will be removed in the future.
This affected only 004-ThreadStress.

Test: ./art/test.py -r
Change-Id: I132c65638570f2e3fe58bee8461d6f18b9e72a15
diff --git a/test/004-ThreadStress/run b/test/004-ThreadStress/run
index d327c5e..87dfb27 100755
--- a/test/004-ThreadStress/run
+++ b/test/004-ThreadStress/run
@@ -15,13 +15,13 @@
 # limitations under the License.
 
 # Enable lock contention logging.
-${RUN} --runtime-option -Xlockprofthreshold:10 "${@}"
+${RUN} "${@}" --runtime-option -Xlockprofthreshold:10
 return_status1=$?
 
 # Run locks-only mode with stack-dump lock profiling. Reduce the number of total operations from
 # the default 1000 to 100.
-${RUN} --runtime-option -Xlockprofthreshold:10 --runtime-option -Xstackdumplockprofthreshold:20 \
-  "${@}" -- Main --locks-only -o 100
+${RUN} "${@}" --runtime-option -Xlockprofthreshold:10 \
+  --runtime-option -Xstackdumplockprofthreshold:20 -- Main --locks-only -o 100
 return_status2=$?
 
 # Make sure we don't silently ignore an early failure.
diff --git a/test/115-native-bridge/run b/test/115-native-bridge/run
index 8ce44a9..1cb03e7 100644
--- a/test/115-native-bridge/run
+++ b/test/115-native-bridge/run
@@ -36,4 +36,5 @@
 LEFT=$(echo ${ARGS} | sed -r 's/-Djava.library.path.*//')
 RIGHT=$(echo ${ARGS} | sed -r 's/.*Djava.library.path[^ ]* //')
 MODARGS="${LEFT} -Djava.library.path=`pwd` ${RIGHT}"
-exec ${RUN} --runtime-option -Xforce-nb-testing --runtime-option -XX:NativeBridge=$BRIDGE_SO ${MODARGS} NativeBridgeMain
+exec ${RUN} ${MODARGS} --runtime-option -Xforce-nb-testing \
+  --runtime-option -XX:NativeBridge=$BRIDGE_SO NativeBridgeMain
diff --git a/test/2230-profile-save-hotness/run b/test/2230-profile-save-hotness/run
index d0c49b6..5ce577d 100644
--- a/test/2230-profile-save-hotness/run
+++ b/test/2230-profile-save-hotness/run
@@ -13,9 +13,9 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-${RUN} \
+${RUN} "${@}" \
   -Xcompiler-option --count-hotness-in-compiled-code \
   -Xcompiler-option --compiler-filter=speed \
   --runtime-option -Xps-profile-aot-code \
   --runtime-option -Xjitsaveprofilinginfo \
-  --runtime-option -Xusejit:true "${@}"
+  --runtime-option -Xusejit:true
diff --git a/test/566-polymorphic-inlining/run b/test/566-polymorphic-inlining/run
index 2919f46..6e51cb1 100644
--- a/test/566-polymorphic-inlining/run
+++ b/test/566-polymorphic-inlining/run
@@ -15,6 +15,5 @@
 # limitations under the License.
 
 # -Xjitinitialsize:32M to prevent profiling info creation failure.
-exec ${RUN} \
-  --runtime-option -Xjitinitialsize:32M \
-  "${@}"
+exec ${RUN} "${@}" \
+  --runtime-option -Xjitinitialsize:32M
diff --git a/test/595-profile-saving/run b/test/595-profile-saving/run
index 851be09..03d3046 100644
--- a/test/595-profile-saving/run
+++ b/test/595-profile-saving/run
@@ -20,11 +20,10 @@
 # -Xjitsaveprofilinginfo to enable profile saving
 # -Xusejit:false to disable jit and only test profiles.
 # -Xjitinitialsize:32M to prevent profiling info creation failure.
-exec ${RUN} \
+exec ${RUN} "${@}" \
   -Xcompiler-option --compiler-filter=quicken \
   --runtime-option '-Xcompiler-option --compiler-filter=quicken' \
   --runtime-option -Xjitinitialsize:32M \
   --runtime-option -Xjitsaveprofilinginfo \
   --runtime-option -Xusejit:false \
-  --runtime-option -Xps-profile-boot-class-path \
-  "${@}"
+  --runtime-option -Xps-profile-boot-class-path
diff --git a/test/638-checker-inline-cache-intrinsic/run b/test/638-checker-inline-cache-intrinsic/run
index 9016107..941ac9e 100644
--- a/test/638-checker-inline-cache-intrinsic/run
+++ b/test/638-checker-inline-cache-intrinsic/run
@@ -19,4 +19,6 @@
 # The test is for JIT, but we run in "optimizing" (AOT) mode, so that the Checker
 # stanzas in test/638-checker-inline-cache-intrinsic/src/Main.java will be checked.
 # Also pass a large JIT code cache size to avoid getting the inline caches GCed.
-exec ${RUN} --jit --runtime-option -Xjitinitialsize:32M --runtime-option -Xjitthreshold:1000 -Xcompiler-option --verbose-methods=inlineMonomorphic,inlinePolymorphic,knownReceiverType,stringEquals $@
+exec ${RUN} $@ --jit \
+  --runtime-option -Xjitinitialsize:32M --runtime-option -Xjitthreshold:1000 -Xcompiler-option \
+  --verbose-methods=inlineMonomorphic,inlinePolymorphic,knownReceiverType,stringEquals
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 67bbfa2..004aee1 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -47,13 +47,6 @@
       with open(
           os.path.join(ART_TEST_CMD_DIR, os.environ["FULL_TEST_NAME"]),
           "a") as f:
-        env_ignore = [
-            "SHLVL", "_", "ART_TOOLS_BUILD_VAR_CACHE", "PWD", "OLDPWD", "TMUX",
-            "TMUX_PANE"
-        ]
-        env = {
-            k: v for k, v in sorted(os.environ.items()) if k not in env_ignore
-        }
         # Replace DEX_LOCATION (which is randomly generated temporary directory),
         # with a deterministic placeholder so that we can do a diff from run to run.
         f.write("\n".join(
@@ -1038,7 +1031,7 @@
                     {QUOTED_DALVIKVM_BOOT_OPT} \
                     {TMP_DIR_OPTION} \
                     -XX:DumpNativeStackOnSigQuit:false \
-                    -cp {DALVIKVM_CLASSPATH} {MAIN} {ARGS}"
+                    -cp {DALVIKVM_CLASSPATH} {MAIN} {ARGS} {test_args}".strip()
 
   if SIMPLEPERF:
     dalvikvm_cmdline = f"simpleperf record {dalvikvm_cmdline} && simpleperf report"
@@ -1335,14 +1328,14 @@
     if USE_GDB:
       # When running under gdb, we cannot do piping and grepping...
       env["TERM"] = os.environ.get("TERM", "")
-      subprocess.run(cmdline + test_args, env=env, shell=True)
+      subprocess.run(cmdline, env=env, shell=True)
     elif USE_GDBSERVER:
       print(f"Connect to {GDBSERVER_PORT}")
       # When running under gdb, we cannot do piping and grepping...
-      subprocess.run(cmdline + test_args, env=env, shell=True)
+      subprocess.run(cmdline, env=env, shell=True)
     else:
       if TIME_OUT != "gdb":
-        proc = run(cmdline + test_args, env, check=False, quiet=False)
+        proc = run(cmdline, env, check=False, quiet=False)
         exit_value = proc.returncode
         # Add extra detail if time out is enabled.
         if exit_value == 124 and TIME_OUT == "timeout":
@@ -1350,7 +1343,7 @@
         sys.exit(exit_value)
       else:
         # With a thread dump that uses gdb if a timeout.
-        proc = run(cmdline + test_args, check=False)
+        proc = run(cmdline, check=False)
         # TODO: Spawn a watcher process.
         raise Exception("Not implemented")
         # ( sleep {TIME_OUT_VALUE} && \