gecko-dev/tools/profiler/tests/test_shared_library.js
Markus Stange 5c5945bfa0 Bug 1329111 - Change the nsIProfiler shared library information API. r=njn
API before this change:
 - nsIProfiler::getSharedLibraryInformation() returns a string containing a
   JSON array of libraries.
 - The profile format is at version 3.
 - Every profile has a "libs" field that contains the same JSON string as the
   return value of nsIProfiler::getSharedLibraryInformation.
 - The array of libraries is not sorted.
 - Each library has a "name" field that contains:
    - The module's debug name on Windows
    - The full path to the binary on Mac + Linux

API after this change:
 - nsIProfiler::getSharedLibraryInformation() is removed.
 - nsIProfiler has a readonly property called sharedLibraries.
 - The profile format is at version 4.
 - Every profile has a "libs" field that contains the same array as
   nsIProfiler.sharedLibraries, no longer as a JSON string but as a regular
   array.
 - The array of libraries is sorted by start address.
 - Each library has a "name" field that contains the binary file's basename,
   on all platforms.
 - Each library has a "path" field that contains the full path to the binary,
   on all platforms.
 - Each library has a "debugName" field that contains the library's debug
   name, on all platforms. On Windows, the debug name is the filename
   (basename) of the pdb file for that binary. On other platforms, debugName
   is the same as |name|.
 - Each library has a "debugPath" field that contains the absolute path
   library's pdb file on Windows; on non-Windows, debugPath and path are the
   same.
 - Each library has an "arch" field that is either an empty string (Linux +
   Windows) or the library's architecture; it'll differentiate between the
   architectures "x86_64" and "x86_64h". (x86_64h is used for binaries that
   contain instructions that are specific to the Intel Haswell
   microarchitecture.)

MozReview-Commit-ID: 8Nrs4dyHhDS

--HG--
extra : rebase_source : 4039926ae4d776bf53ea71df5fe3f8200d3e2784
extra : source : 4e282aa03422de5b8d51e1aaeb3e53ee547293dd
2017-03-14 18:59:20 -04:00

32 lines
1.1 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
// If we can't get the profiler component then assume gecko was
// built without it and pass all the tests
var profilerCc = Cc["@mozilla.org/tools/profiler;1"];
if (!profilerCc)
return;
var profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
if (!profiler)
return;
var libs = profiler.sharedLibraries;
do_check_eq(typeof libs, "object");
do_check_true(Array.isArray(libs));
do_check_eq(typeof libs, "object");
do_check_true(libs.length >= 1);
do_check_eq(typeof libs[0], "object");
do_check_eq(typeof libs[0].name, "string");
do_check_eq(typeof libs[0].path, "string");
do_check_eq(typeof libs[0].debugName, "string");
do_check_eq(typeof libs[0].debugPath, "string");
do_check_eq(typeof libs[0].arch, "string");
do_check_eq(typeof libs[0].start, "number");
do_check_eq(typeof libs[0].end, "number");
do_check_true(libs[0].start <= libs[0].end);
}