Prechádzať zdrojové kódy

Fix Debugger tests for Linux and macOS
1. support loading debugger baselines in ch for xplat
2. update DbgController.js for '/' delimited paths
3. update case of baseline names in rl.xml files (ubuntu is case sensitive)

rhuanjl 5 rokov pred
rodič
commit
cc97221d91

+ 4 - 2
bin/ch/DbgController.js

@@ -1,5 +1,6 @@
 //-------------------------------------------------------------------------------------------------------
 // Copyright (C) Microsoft. All rights reserved.
+// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 
@@ -157,9 +158,10 @@ var controllerObj = (function () {
     function filterFileName(fileName) {
         try {
             var index = fileName.lastIndexOf("\\");
-            if (index >= 0) {
-                return fileName.substring(index + 1);
+            if (index === -1) {
+                index = fileName.lastIndexOf("/");
             }
+            return fileName.substring(index + 1);
         } catch (ex) { }
         return "";
     }

+ 17 - 43
bin/ch/Debugger.cpp

@@ -1,8 +1,11 @@
 //-------------------------------------------------------------------------------------------------------
 // Copyright (C) Microsoft. All rights reserved.
+// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "stdafx.h"
+#include "Helpers.h"
+#include "PlatformAgnostic/ChakraICU.h"
 
 #define MAX_BASELINE_SIZE       (1024*1024*200)
 
@@ -303,63 +306,34 @@ Error:
 
 bool Debugger::SetBaseline()
 {
-#ifdef _WIN32
-    LPSTR script = nullptr;
-    FILE *file = nullptr;
-    size_t numChars = 0;
-    HRESULT hr = S_OK;
-
-    if (_wfopen_s(&file, HostConfigFlags::flags.dbgbaseline, _u("rb")) != 0)
-    {
-        Helpers::LogError(_u("opening baseline file '%s'"), HostConfigFlags::flags.dbgbaseline);
-    }
+    const char* script = nullptr;
+    char* fileName = nullptr;
+    JsValueRef scriptRef = JS_INVALID_REFERENCE;
+    HRESULT hr = E_FAIL;
+    UINT lengthBytes = 0;
 
-    if(file != nullptr)
+    if (SUCCEEDED(WideStringToNarrowDynamic(HostConfigFlags::flags.dbgbaseline, &fileName)))
     {
-        long fileSize = _filelength(_fileno(file));
-        if (0 <= fileSize && fileSize <= MAX_BASELINE_SIZE)
-        {
-            script = new char[(size_t)fileSize + 1];
-
-            numChars = fread(script, sizeof(script[0]), fileSize, file);
-            if (numChars == (size_t)fileSize)
-            {
-                script[numChars] = '\0';
-
-                JsValueRef wideScriptRef;
-                IfJsErrorFailLogAndHR(ChakraRTInterface::JsCreateString(
-                  script, strlen(script), &wideScriptRef));
-
-                this->CallFunctionNoResult("SetBaseline", wideScriptRef);
-            }
-            else
-            {
-                Helpers::LogError(_u("failed to read from baseline file"));
-                IfFailGo(E_FAIL);
-            }
-        }
-        else
+        Helpers::LoadScriptFromFile(fileName, script, &lengthBytes);
+        if (script && lengthBytes < MAX_BASELINE_SIZE &&
+            ChakraRTInterface::JsCreateString(script, strlen(script), &scriptRef) == JsNoError)
         {
-            Helpers::LogError(_u("baseline file too large"));
-            IfFailGo(E_FAIL);
+            this->CallFunctionNoResult("SetBaseline", scriptRef);
+            hr = S_OK;
         }
     }
-Error:
+
     if (script)
     {
         delete[] script;
     }
 
-    if (file)
+    if (hr != S_OK)
     {
-        fclose(file);
+        Helpers::LogError(_u("Failed to load & process debug baseline: %s"), HostConfigFlags::flags.dbgbaseline);
     }
 
     return hr == S_OK;
-#else
-    // xplat-todo: Implement this on Linux
-    return false;
-#endif
 }
 
 bool Debugger::SetInspectMaxStringLength()

+ 7 - 7
test/DebuggerCommon/rlexe.xml

@@ -1269,25 +1269,25 @@
   <test>
     <default>
       <files>TypedArray.js</files>
-      <compile-flags>-debuglaunch -dbgbaseline:typedarray.js.dbg.baseline -InspectMaxStringLength:200</compile-flags>
+      <compile-flags>-debuglaunch -dbgbaseline:TypedArray.js.dbg.baseline -InspectMaxStringLength:200</compile-flags>
     </default>
   </test>
   <test>
     <default>
       <files>ComputedPropertyNames.js</files>
-      <compile-flags>-debuglaunch -dbgbaseline:computedpropertynames.js.dbg.baseline</compile-flags>
+      <compile-flags>-debuglaunch -dbgbaseline:ComputedPropertyNames.js.dbg.baseline</compile-flags>
     </default>
   </test>
   <test>
     <default>
       <files>parentedDynamicCode2.js</files>
-      <compile-flags>-InspectMaxStringLength:1000 -dbgbaseline:parenteddynamiccode2.js.dbg.baseline</compile-flags>
+      <compile-flags>-InspectMaxStringLength:1000 -dbgbaseline:parentedDynamicCode2.js.dbg.baseline</compile-flags>
     </default>
   </test>
   <test>
     <default>
       <files>parentedDynamicCode3.js</files>
-      <compile-flags>-InspectMaxStringLength:1000 -dbgbaseline:parenteddynamiccode3.js.dbg.baseline</compile-flags>
+      <compile-flags>-InspectMaxStringLength:1000 -dbgbaseline:parentedDynamicCode3.js.dbg.baseline</compile-flags>
     </default>
   </test>
   <test>
@@ -1301,14 +1301,14 @@
     <default>
       <files>ConsoleScope.js</files>
       <baseline>ConsoleScope.js.baseline</baseline>
-      <compile-flags>-debuglaunch -dbgbaseline:consolescope.js.dbg.baseline</compile-flags>
+      <compile-flags>-debuglaunch -dbgbaseline:ConsoleScope.js.dbg.baseline</compile-flags>
     </default>
   </test>
   <test>
     <default>
       <files>ConsoleScopePMSpec.js</files>
       <baseline>ConsoleScopePMSpec.js.baseline</baseline>
-      <compile-flags>-debuglaunch -dbgbaseline:consolescopepmspec.js.dbg.baseline</compile-flags>
+      <compile-flags>-debuglaunch -dbgbaseline:ConsoleScopePMSpec.js.dbg.baseline</compile-flags>
     </default>
   </test>
   <test>
@@ -1351,7 +1351,7 @@
   <test>
     <default>
       <files>promiseDisplay.js</files>
-      <compile-flags>-debuglaunch -dbgbaseline:promisedisplay.js.dbg.baseline</compile-flags>
+      <compile-flags>-debuglaunch -dbgbaseline:promiseDisplay.js.dbg.baseline</compile-flags>
     </default>
   </test>
   <test>

+ 5 - 5
test/runtests.py

@@ -741,12 +741,8 @@ def main():
             ])
     ] if x.name in args.variants]
 
-    # rm profile.dpl.*
-    for f in glob.glob(test_root + '/*/profile.dpl.*'):
-        os.remove(f)
-
     print('############# ChakraCore Test Suite #############')
-    print('Testing {} build'.format('Test' if flavor is 'Test' else 'Debug'))
+    print('Testing {} build'.format('Test' if flavor == 'Test' else 'Debug'))
     print('Using {} threads'.format(processcount))
     # run each variant
     pool, sequential_pool = Pool(processcount), Pool(1)
@@ -759,6 +755,10 @@ def main():
     print('[{} seconds] {}'.format(
         round(elapsed_time.total_seconds(),2), 'Success!' if not failed else 'Failed!'))
 
+    # rm profile.dpl.*
+    for f in glob.glob(test_root + '/*/profile.dpl.*'):
+        os.remove(f)
+
     return 1 if failed else 0
 
 if __name__ == '__main__':