Bug 226385 - [JSC] Fix run-jsc-stress-tests missing escape $
Summary: [JSC] Fix run-jsc-stress-tests missing escape $
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zhifei Fang
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-28 11:39 PDT by Zhifei Fang
Modified: 2021-06-01 02:41 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.38 KB, patch)
2021-05-28 11:39 PDT, Zhifei Fang
no flags Details | Formatted Diff | Diff
Patch (1.58 KB, patch)
2021-05-28 12:49 PDT, Zhifei Fang
no flags Details | Formatted Diff | Diff
Patch (2.97 KB, patch)
2021-05-28 14:43 PDT, Zhifei Fang
no flags Details | Formatted Diff | Diff
Patch (1.54 KB, patch)
2021-05-28 14:47 PDT, Zhifei Fang
no flags Details | Formatted Diff | Diff
Patch (2.97 KB, patch)
2021-05-28 16:33 PDT, Zhifei Fang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhifei Fang 2021-05-28 11:39:14 PDT
[JSC] Fix run-jsc-stress-tests missing escape $
Comment 1 Zhifei Fang 2021-05-28 11:39:42 PDT
Created attachment 430033 [details]
Patch
Comment 2 Alexey Proskuryakov 2021-05-28 11:44:04 PDT
Comment on attachment 430033 [details]
Patch

rs=me
Comment 3 EWS 2021-05-28 12:40:34 PDT
Committed r278218 (238257@main): <https://commits.webkit.org/238257@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430033 [details].
Comment 4 Radar WebKit Bug Importer 2021-05-28 12:41:16 PDT
<rdar://problem/78628571>
Comment 5 Zhifei Fang 2021-05-28 12:49:54 PDT
Reopening to attach new patch.
Comment 6 Zhifei Fang 2021-05-28 12:49:55 PDT
Created attachment 430044 [details]
Patch
Comment 7 Alexey Proskuryakov 2021-05-28 13:02:54 PDT
Comment on attachment 430044 [details]
Patch

rs=me
Comment 8 Zhifei Fang 2021-05-28 14:43:00 PDT
Created attachment 430055 [details]
Patch
Comment 9 Zhifei Fang 2021-05-28 14:43:43 PDT
Test patch with MIPS JSC EWS
Comment 10 Zhifei Fang 2021-05-28 14:47:14 PDT
Created attachment 430057 [details]
Patch
Comment 11 Alexey Proskuryakov 2021-05-28 15:07:49 PDT
Comment on attachment 430057 [details]
Patch

I'm just going to keep saying rs=me until it lands :)
Comment 12 Zhifei Fang 2021-05-28 16:33:32 PDT
Created attachment 430072 [details]
Patch
Comment 13 Zhifei Fang 2021-05-28 16:34:07 PDT
uh, back to the complex solution. Test with EWS.
Comment 14 EWS 2021-05-28 21:34:19 PDT
Committed r278234 (238271@main): <https://commits.webkit.org/238271@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430072 [details].
Comment 15 Darin Adler 2021-05-29 13:43:19 PDT
Comment on attachment 430072 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430072&action=review

> Tools/ChangeLog:3
> +        [JSC] Escape $ only when run with SSH

Why?
Comment 16 Angelos Oikonomopoulos 2021-05-31 03:48:10 PDT
So, AFAIU this happens when using `--remote-config-file` but not `--gnu-parallel-runner`, right? The symptom I see is:

sh: line 0: cd: ../.vm: No such file or directory
sh: line 0: cd: ../.vm/..: No such file or directory

Which does not result into any errors for me (which I guess is why I didn't notice this when testing). Presumably, that's because I've been testing with $hostOS == "linux" so have been taking the path (in prepareBundle) that runs generate-bundle. As generate-bundle creates a shell wrapper that sets LD_LIBRARY_PATH, I guess the value of LD_LIBRARY_PATH doesn't matter on linux.

That said, it would be great to know which configuration this failed on!

IIUC, this could be fixed by switching to single quotes around the remoteScript (in runTestRunner). At the very least, this makes the symptom above go away for me. The patch would be:

diff --git a/Tools/Scripts/run-jsc-stress-tests b/Tools/Scripts/run-jsc-stress-tests
index e6141b5e7249..0c24c3d5f398 100755
--- a/Tools/Scripts/run-jsc-stress-tests
+++ b/Tools/Scripts/run-jsc-stress-tests
@@ -2197,14 +2197,9 @@ def copyBundleToRemote(remoteHost)
     mysys(["scp", "-o", "NoHostAuthenticationForLocalhost=yes", "-P", remoteHost.port.to_s, ($outputDir.dirname + $tarFileName).to_s, "#{remoteHost.user}@#{remoteHost.host}:#{remoteHost.remoteDirectory}"])
 end
 
-def exportBaseEnvironmentVariables(escape)
-    if escape
-        dyldFrameworkPath = "\\$(cd #{$testingFrameworkPath.dirname}; pwd)"
-        ldLibraryPath = "\\$(cd #{$testingFrameworkPath.dirname}/..; pwd)/#{$jscPath.dirname}"
-    else
-        dyldFrameworkPath = "\$(cd #{$testingFrameworkPath.dirname}; pwd)"
-        ldLibraryPath = "\$(cd #{$testingFrameworkPath.dirname}/..; pwd)/#{$jscPath.dirname}"
-    end
+def exportBaseEnvironmentVariables
+    dyldFrameworkPath = "\$(cd #{$testingFrameworkPath.dirname}; pwd)"
+    ldLibraryPath = "\$(cd #{$testingFrameworkPath.dirname}/..; pwd)/#{$jscPath.dirname}"
     [
         "export DYLD_FRAMEWORK_PATH=#{dyldFrameworkPath} && ",
         "export LD_LIBRARY_PATH=#{ldLibraryPath} &&",
@@ -2220,14 +2215,14 @@ def runTestRunner(remoteIndex=0)
         remoteHost = $remoteHosts[remoteIndex]
         getRemoteDirectoryIfNeeded(remoteHost)
         copyBundleToRemote(remoteHost)
-        remoteScript = "\""
+        remoteScript = "'"
         remoteScript += "cd #{remoteHost.remoteDirectory} && "
         remoteScript += "rm -rf #{$outputDir.basename} && "
         remoteScript += "tar xzf #{$tarFileName} && "
         remoteScript += "cd #{$outputDir.basename}/.runner && "
-        remoteScript += exportBaseEnvironmentVariables(true)
+        remoteScript += exportBaseEnvironmentVariables
         $envVars.each { |var| remoteScript += "export " << var << "\n" }
-        remoteScript += "#{testRunnerCommand(remoteIndex)}\""
+        remoteScript += "#{testRunnerCommand(remoteIndex)}'"
         runAndMonitorTestRunnerCommand(["ssh", "-o", "NoHostAuthenticationForLocalhost=yes", "-p", remoteHost.port.to_s, "#{remoteHost.user}@#{remoteHost.host}", remoteScript])
     else
         Dir.chdir($runnerDir) {
@@ -2637,7 +2632,7 @@ def runGnuParallelRunner(remoteHosts, inputs, options={})
             "--timeout", timeout.to_s,
             "-a", inputs,
             "if test -e #{$outputDir.basename}/.runner; then cd #{$outputDir.basename}/.runner; else echo #{PARALLEL_REMOTE_STATE_LOST_MARKER}; false; fi && " +
-            exportBaseEnvironmentVariables(false) +
+            exportBaseEnvironmentVariables +
             $envVars.collect { |var | "export #{var} &&"}.join("") +
             "sh "
         ]
Comment 17 Zhifei Fang 2021-06-01 02:40:18 PDT
(In reply to Darin Adler from comment #15)
> Comment on attachment 430072 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=430072&action=review
> 
> > Tools/ChangeLog:3
> > +        [JSC] Escape $ only when run with SSH
> 
> Why?

We have to run path, with --remote-config-file, we will run the script with SSH, without escape &, that will be considered as a local script instead of part command string running remotely.

We also have --gnu-parallel-runner, with this we should not escape $, since that will be part of the script that needed to be run locally.
Comment 18 Zhifei Fang 2021-06-01 02:41:24 PDT
(In reply to Angelos Oikonomopoulos from comment #16)
> So, AFAIU this happens when using `--remote-config-file` but not
> `--gnu-parallel-runner`, right? The symptom I see is:
> 
> sh: line 0: cd: ../.vm: No such file or directory
> sh: line 0: cd: ../.vm/..: No such file or directory
> 
> Which does not result into any errors for me (which I guess is why I didn't
> notice this when testing). Presumably, that's because I've been testing with
> $hostOS == "linux" so have been taking the path (in prepareBundle) that runs
> generate-bundle. As generate-bundle creates a shell wrapper that sets
> LD_LIBRARY_PATH, I guess the value of LD_LIBRARY_PATH doesn't matter on
> linux.
> 
> That said, it would be great to know which configuration this failed on!
> 
> IIUC, this could be fixed by switching to single quotes around the
> remoteScript (in runTestRunner). At the very least, this makes the symptom
> above go away for me. The patch would be:
> 
> diff --git a/Tools/Scripts/run-jsc-stress-tests
> b/Tools/Scripts/run-jsc-stress-tests
> index e6141b5e7249..0c24c3d5f398 100755
> --- a/Tools/Scripts/run-jsc-stress-tests
> +++ b/Tools/Scripts/run-jsc-stress-tests
> @@ -2197,14 +2197,9 @@ def copyBundleToRemote(remoteHost)
>      mysys(["scp", "-o", "NoHostAuthenticationForLocalhost=yes", "-P",
> remoteHost.port.to_s, ($outputDir.dirname + $tarFileName).to_s,
> "#{remoteHost.user}@#{remoteHost.host}:#{remoteHost.remoteDirectory}"])
>  end
>  
> -def exportBaseEnvironmentVariables(escape)
> -    if escape
> -        dyldFrameworkPath = "\\$(cd #{$testingFrameworkPath.dirname}; pwd)"
> -        ldLibraryPath = "\\$(cd #{$testingFrameworkPath.dirname}/..;
> pwd)/#{$jscPath.dirname}"
> -    else
> -        dyldFrameworkPath = "\$(cd #{$testingFrameworkPath.dirname}; pwd)"
> -        ldLibraryPath = "\$(cd #{$testingFrameworkPath.dirname}/..;
> pwd)/#{$jscPath.dirname}"
> -    end
> +def exportBaseEnvironmentVariables
> +    dyldFrameworkPath = "\$(cd #{$testingFrameworkPath.dirname}; pwd)"
> +    ldLibraryPath = "\$(cd #{$testingFrameworkPath.dirname}/..;
> pwd)/#{$jscPath.dirname}"
>      [
>          "export DYLD_FRAMEWORK_PATH=#{dyldFrameworkPath} && ",
>          "export LD_LIBRARY_PATH=#{ldLibraryPath} &&",
> @@ -2220,14 +2215,14 @@ def runTestRunner(remoteIndex=0)
>          remoteHost = $remoteHosts[remoteIndex]
>          getRemoteDirectoryIfNeeded(remoteHost)
>          copyBundleToRemote(remoteHost)
> -        remoteScript = "\""
> +        remoteScript = "'"
>          remoteScript += "cd #{remoteHost.remoteDirectory} && "
>          remoteScript += "rm -rf #{$outputDir.basename} && "
>          remoteScript += "tar xzf #{$tarFileName} && "
>          remoteScript += "cd #{$outputDir.basename}/.runner && "
> -        remoteScript += exportBaseEnvironmentVariables(true)
> +        remoteScript += exportBaseEnvironmentVariables
>          $envVars.each { |var| remoteScript += "export " << var << "\n" }
> -        remoteScript += "#{testRunnerCommand(remoteIndex)}\""
> +        remoteScript += "#{testRunnerCommand(remoteIndex)}'"
>          runAndMonitorTestRunnerCommand(["ssh", "-o",
> "NoHostAuthenticationForLocalhost=yes", "-p", remoteHost.port.to_s,
> "#{remoteHost.user}@#{remoteHost.host}", remoteScript])
>      else
>          Dir.chdir($runnerDir) {
> @@ -2637,7 +2632,7 @@ def runGnuParallelRunner(remoteHosts, inputs,
> options={})
>              "--timeout", timeout.to_s,
>              "-a", inputs,
>              "if test -e #{$outputDir.basename}/.runner; then cd
> #{$outputDir.basename}/.runner; else echo
> #{PARALLEL_REMOTE_STATE_LOST_MARKER}; false; fi && " +
> -            exportBaseEnvironmentVariables(false) +
> +            exportBaseEnvironmentVariables +
>              $envVars.collect { |var | "export #{var} &&"}.join("") +
>              "sh "
>          ]

Yeah, the issue here is export is using pwd, with the cd part failed, it won't export to the right path when run with remote device.