Ejemplo n.º 1
0
def testBinary(shellPath, args, useValgrind, stderr=subprocess.STDOUT):  # pylint: disable=invalid-name
    # pylint: disable=missing-param-doc,missing-return-doc,missing-return-type-doc,missing-type-doc
    """Test the given shell with the given args."""
    test_cmd = (constructVgCmdList()
                if useValgrind else []) + [str(shellPath)] + args
    sps.vdump(
        f'The testing command is: {" ".join(quote(str(x)) for x in test_cmd)}')

    test_env = env_with_path(str(shellPath.parent))
    asan_options = f"exitcode={ASAN_ERROR_EXIT_CODE}"
    # Turn on LSan, except on macOS: https://github.com/google/sanitizers/issues/1026
    # Note: Unsure about Windows for now
    if not platform.system() == "Darwin":
        asan_options = "detect_leaks=1," + asan_options
        test_env.update({"LSAN_OPTIONS": "max_leaks=1,"})
    test_env.update({"ASAN_OPTIONS": asan_options})

    test_cmd_result = subprocess.run(test_cmd,
                                     cwd=os.getcwd(),
                                     env=test_env,
                                     stderr=stderr,
                                     stdout=subprocess.PIPE,
                                     timeout=999)
    out, return_code = test_cmd_result.stdout.decode(
        "utf-8", errors="replace"), test_cmd_result.returncode
    sps.vdump(f"The exit code is: {return_code}")
    return out, return_code
Ejemplo n.º 2
0
def testBinary(shellPath, args, useValgrind, stderr=subprocess.STDOUT):  # pylint: disable=invalid-name
    # pylint: disable=missing-param-doc,missing-return-doc,missing-return-type-doc,missing-type-doc
    """Test the given shell with the given args."""
    test_cmd = (constructVgCmdList()
                if useValgrind else []) + [str(shellPath)] + args
    sps.vdump(
        f'The testing command is: {" ".join(quote(str(x)) for x in test_cmd)}')

    test_env = env_with_path(str(shellPath.parent))
    asan_options = f"exitcode={ASAN_ERROR_EXIT_CODE}"
    # Turn on LSan, Linux-only
    # macOS non-support: https://github.com/google/sanitizers/issues/1026
    # Windows non-support: https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Firefox_and_Address_Sanitizer
    #   (search for LSan)
    if platform.system() == "Linux" and not ("-asan-" in str(shellPath) and
                                             "-armsim64-" in str(shellPath)):
        asan_options = "detect_leaks=1," + asan_options
        test_env.update({"LSAN_OPTIONS": "max_leaks=1,"})
    test_env.update({"ASAN_OPTIONS": asan_options})

    test_cmd_result = subprocess.run(test_cmd,
                                     check=False,
                                     cwd=os.getcwd(),
                                     env=test_env,
                                     stderr=stderr,
                                     stdout=subprocess.PIPE,
                                     timeout=999)
    out, return_code = test_cmd_result.stdout.decode(
        "utf-8", errors="replace"), test_cmd_result.returncode
    sps.vdump(f"The exit code is: {return_code}")
    return out, return_code
Ejemplo n.º 3
0
def testIsHardFpShellARM(s):
    """Test if the ARM shell is compiled with hardfp support."""
    readelfBin = '/usr/bin/readelf'
    if os.path.exists(readelfBin):
        newEnv = env_with_path(os.path.dirname(os.path.abspath(s)))
        readelfOutput = sps.captureStdout([readelfBin, '-A', s], env=newEnv)[0]
        return 'Tag_ABI_VFP_args: VFP registers' in readelfOutput
    else:
        raise Exception('readelf is not found.')
Ejemplo n.º 4
0
def testIsHardFpShellARM(s):  # pylint: disable=invalid-name,missing-param-doc,missing-raises-doc,missing-return-doc
    # pylint: disable=missing-return-type-doc,missing-type-doc
    """Test if the ARM shell is compiled with hardfp support."""
    readelf_bin_path = '/usr/bin/readelf'
    if os.path.exists(readelf_bin_path):
        new_env = env_with_path(os.path.dirname(os.path.abspath(s)))
        readelf_output = sps.captureStdout([readelf_bin_path, '-A', s], env=new_env)[0]
        return 'Tag_ABI_VFP_args: VFP registers' in readelf_output
    else:
        raise Exception('readelf is not found.')
Ejemplo n.º 5
0
def testBinary(shellPath, args, useValgrind):  # pylint: disable=invalid-name,missing-param-doc,missing-return-doc
    # pylint: disable=missing-return-type-doc,missing-type-doc
    """Test the given shell with the given args."""
    test_cmd = (constructVgCmdList() if useValgrind else []) + [shellPath] + args
    sps.vdump('The testing command is: ' + sps.shellify(test_cmd))
    out, return_code = sps.captureStdout(test_cmd, combineStderr=True, ignoreStderr=True,
                                         ignoreExitCode=True, env=env_with_path(
                                             os.path.dirname(os.path.abspath(shellPath))))
    sps.vdump('The exit code is: ' + str(return_code))
    return out, return_code
Ejemplo n.º 6
0
def testBinary(shellPath, args, useValgrind):
    """Test the given shell with the given args."""
    testCmd = (constructVgCmdList() if useValgrind else []) + [shellPath
                                                               ] + args
    sps.vdump('The testing command is: ' + sps.shellify(testCmd))
    out, rCode = sps.captureStdout(
        testCmd,
        combineStderr=True,
        ignoreStderr=True,
        ignoreExitCode=True,
        env=env_with_path(os.path.dirname(os.path.abspath(shellPath))))
    sps.vdump('The exit code is: ' + str(rCode))
    return out, rCode
Ejemplo n.º 7
0
def testBinary(shellPath, args, useValgrind):  # pylint: disable=invalid-name,missing-param-doc,missing-return-doc
    # pylint: disable=missing-return-type-doc,missing-type-doc
    """Test the given shell with the given args."""
    test_cmd = (constructVgCmdList() if useValgrind else []) + [str(shellPath)] + args
    sps.vdump("The testing command is: " + " ".join(quote(str(x)) for x in test_cmd))
    test_cmd_result = subprocess.run(
        test_cmd,
        cwd=os.getcwdu() if sys.version_info.major == 2 else os.getcwd(),  # pylint: disable=no-member
        env=env_with_path(str(shellPath.parent)),
        stderr=subprocess.STDOUT,
        stdout=subprocess.PIPE,
        timeout=999)
    out, return_code = test_cmd_result.stdout.decode("utf-8", errors="replace"), test_cmd_result.returncode
    sps.vdump("The exit code is: " + str(return_code))
    return out, return_code
Ejemplo n.º 8
0
def testBinary(shellPath, args, useValgrind, stderr=subprocess.STDOUT):  # pylint: disable=invalid-name
    # pylint: disable=missing-param-doc,missing-return-doc,missing-return-type-doc,missing-type-doc
    """Test the given shell with the given args."""
    test_cmd = (constructVgCmdList()
                if useValgrind else []) + [str(shellPath)] + args
    test_env = env_with_path(str(shellPath.parent))
    test_env.update({
        "ASAN_OPTIONS":
        f"detect_leaks=1,exitcode={ASAN_ERROR_EXIT_CODE}"
    })  # Turn on LSan throughout
    sps.vdump(
        f'The testing command is: {" ".join(quote(str(x)) for x in test_cmd)}')
    test_cmd_result = subprocess.run(test_cmd,
                                     cwd=os.getcwd(),
                                     env=test_env,
                                     stderr=stderr,
                                     stdout=subprocess.PIPE,
                                     timeout=999)
    out, return_code = test_cmd_result.stdout.decode(
        "utf-8", errors="replace"), test_cmd_result.returncode
    sps.vdump(f"The exit code is: {return_code}")
    return out, return_code