aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2019-12-06 20:03:10 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-12-06 20:03:10 -0800
commit6d4d1570dd59f439bd2fa7414e84af77973b82c4 (patch)
tree881d09bdf37513366ed0155a1fe1e7ab57d17d48
parent1491d34e34f01a4324c05861f84562db01a634fc (diff)
parentb6bc2798e8101f802554157778f4a73c8388eac0 (diff)
downloadtoolchain-utils-6d4d1570dd59f439bd2fa7414e84af77973b82c4.tar.gz
Merging 45 commit(s) from Chromium's toolchain-utils
am: b6bc2798e8 Change-Id: If52a53ed5bc062d83265fef19d52f82643a648e2
-rw-r--r--.gitignore1
-rw-r--r--afdo_metadata/chrome_afdo.json8
-rw-r--r--afdo_metadata/kernel_afdo.json6
-rwxr-xr-xafdo_tools/bisection/afdo_prof_analysis.py8
-rwxr-xr-xbuildbot_test_toolchains.py10
-rw-r--r--compiler_wrapper/android_config_test.go3
-rw-r--r--compiler_wrapper/bisect_flag_test.go18
-rw-r--r--compiler_wrapper/compiler_wrapper.go24
-rw-r--r--compiler_wrapper/compiler_wrapper_test.go80
-rw-r--r--compiler_wrapper/config.go47
-rw-r--r--compiler_wrapper/config_test.go3
-rw-r--r--compiler_wrapper/cros_hardened_config_test.go45
-rw-r--r--compiler_wrapper/cros_host_config_test.go6
-rw-r--r--compiler_wrapper/cros_nonhardened_config_test.go3
-rw-r--r--compiler_wrapper/goldenutil_test.go11
-rw-r--r--compiler_wrapper/main.go9
-rw-r--r--compiler_wrapper/oldwrapper.go392
-rw-r--r--compiler_wrapper/oldwrapper_test.go431
-rw-r--r--compiler_wrapper/print_config_flag_test.go12
-rw-r--r--compiler_wrapper/rusage_flag_test.go4
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/bisect.json21
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_ftrapv_maincc_target_specific.json63
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_host_wrapper.json7
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_maincc_target_specific.json63
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json84
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_sanitizer_args.json56
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json49
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clangtidy.json56
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json31
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/bisect.json15
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_ftrapv_maincc_target_specific.json45
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_maincc_target_specific.json45
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_path.json60
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_sanitizer_args.json40
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json35
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_sysroot_wrapper_common.json30
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clangtidy.json40
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json25
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/gcc_clang_syntax.json20
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json24
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json16
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json10
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json8
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json15
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json60
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/clangtidy.json40
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json25
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_clang_syntax.json20
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json15
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_ftrapv_maincc_target_specific.json45
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_maincc_target_specific.json45
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json60
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_sanitizer_args.json40
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json35
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_sysroot_wrapper_common.json30
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clangtidy.json40
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json25
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/gcc_clang_syntax.json20
-rw-r--r--compiler_wrapper/testutil_test.go43
-rwxr-xr-xcros_utils/device_setup_utils.py458
-rwxr-xr-xcros_utils/device_setup_utils_unittest.py620
-rw-r--r--crosperf/benchmark.py12
-rw-r--r--crosperf/benchmark_run.py29
-rwxr-xr-xcrosperf/benchmark_run_unittest.py6
-rwxr-xr-xcrosperf/benchmark_unittest.py2
-rwxr-xr-xcrosperf/crosperf_unittest.py3
-rw-r--r--crosperf/default-telemetry-results.json6
-rw-r--r--crosperf/download_images.py4
-rwxr-xr-xcrosperf/download_images_unittest.py8
-rw-r--r--crosperf/experiment.py14
-rw-r--r--crosperf/experiment_factory.py128
-rwxr-xr-xcrosperf/experiment_factory_unittest.py12
-rw-r--r--crosperf/experiment_file.py9
-rw-r--r--crosperf/experiment_runner.py10
-rwxr-xr-xcrosperf/experiment_runner_unittest.py1
-rw-r--r--crosperf/machine_manager.py8
-rwxr-xr-xcrosperf/machine_manager_unittest.py15
-rw-r--r--crosperf/results_report.py52
-rwxr-xr-xcrosperf/results_report_unittest.py51
-rw-r--r--crosperf/schedv2.py169
-rwxr-xr-xcrosperf/schedv2_unittest.py42
-rw-r--r--crosperf/settings.py4
-rw-r--r--crosperf/settings_factory.py8
-rwxr-xr-xcrosperf/settings_factory_unittest.py5
-rwxr-xr-xcrosperf/settings_unittest.py21
-rw-r--r--crosperf/suite_runner.py508
-rwxr-xr-xcrosperf/suite_runner_unittest.py750
-rw-r--r--crosperf/translate_xbuddy.py6
-rw-r--r--llvm_tools/README.md8
-rwxr-xr-xllvm_tools/get_llvm_hash.py196
-rwxr-xr-xllvm_tools/get_llvm_hash_unittest.py76
-rwxr-xr-xllvm_tools/git_llvm_rev.py356
-rwxr-xr-xllvm_tools/git_llvm_rev_test.py122
-rwxr-xr-xllvm_tools/llvm_bisection.py9
-rwxr-xr-xllvm_tools/llvm_bisection_unittest.py26
-rwxr-xr-xllvm_tools/llvm_patch_management.py16
-rwxr-xr-xllvm_tools/llvm_patch_management_unittest.py19
-rwxr-xr-xllvm_tools/patch_manager.py38
-rwxr-xr-xlock_machine.py6
-rwxr-xr-xtoolchain_utils_githooks/check-format122
-rwxr-xr-xtoolchain_utils_githooks/check-lint91
l---------[-rwxr-xr-x]toolchain_utils_githooks/check-presubmit65
-rwxr-xr-xtoolchain_utils_githooks/check-presubmit.py528
104 files changed, 4051 insertions, 3116 deletions
diff --git a/.gitignore b/.gitignore
index 45abe3a9..072bd9e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
logs
*.pyc
+.mypy_cache/
llvm-project-copy/
compiler_wrapper/compiler_wrapper
diff --git a/afdo_metadata/chrome_afdo.json b/afdo_metadata/chrome_afdo.json
index e46e05f7..5dbfa960 100644
--- a/afdo_metadata/chrome_afdo.json
+++ b/afdo_metadata/chrome_afdo.json
@@ -1,14 +1,14 @@
{
"silvermont": {
- "name": "R79-3928.0-1571049528.afdo"
+ "name": "R79-3931.2-1571659204.afdo"
},
"benchmark": {
- "name": "chromeos-chrome-amd64-79.0.3940.0_rc-r1.afdo"
+ "name": "chromeos-chrome-amd64-79.0.3943.1_rc-r1.afdo"
},
"airmont": {
- "name": "R79-3931.2-1571054549.afdo"
+ "name": "R79-3931.2-1571653097.afdo"
},
"broadwell": {
- "name": "R79-3904.41-1571046112.afdo"
+ "name": "R79-3931.2-1571657055.afdo"
}
} \ No newline at end of file
diff --git a/afdo_metadata/kernel_afdo.json b/afdo_metadata/kernel_afdo.json
index 1f23b170..8bb580e8 100644
--- a/afdo_metadata/kernel_afdo.json
+++ b/afdo_metadata/kernel_afdo.json
@@ -1,11 +1,11 @@
{
"chromeos-kernel-3_14": {
- "name": "R79-12499.14-1569836097"
+ "name": "R80-12607.34-1575283400"
},
"chromeos-kernel-4_4": {
- "name": "R79-12576.0-1571045606"
+ "name": "R80-12672.0-1575282851"
},
"chromeos-kernel-3_18": {
- "name": "R79-12564.0-1570440773"
+ "name": "R80-12607.34-1575282780"
}
} \ No newline at end of file
diff --git a/afdo_tools/bisection/afdo_prof_analysis.py b/afdo_tools/bisection/afdo_prof_analysis.py
index 8455d2b3..36531106 100755
--- a/afdo_tools/bisection/afdo_prof_analysis.py
+++ b/afdo_tools/bisection/afdo_prof_analysis.py
@@ -11,6 +11,13 @@ script which deems particular AFDO profiles as GOOD/BAD/SKIP, and an output
file as arguments. Given these pieces of information, it analyzes the profiles
to try and determine what exactly is bad about the bad profile. It does this
with three main techniques: bisecting search, range search, and rough diff-ing.
+
+The external script communicates the 'goodness' of an AFDO profile through its
+exit code. The codes known to this script are:
+ - 0: the AFDO profile produced a good binary
+ - 1: the AFDO profile produced a bad binary
+ - 125: no result could be determined; just try another profile
+ - >127: quit immediately
"""
from __future__ import division, print_function
@@ -395,6 +402,7 @@ def parse_args():
def main(flags):
+ logging.getLogger().setLevel(logging.INFO)
if not flags.no_resume and flags.seed: # conflicting seeds
raise RuntimeError('Ambiguous seed value; do not resume from existing '
'state and also specify seed by command line flag')
diff --git a/buildbot_test_toolchains.py b/buildbot_test_toolchains.py
index e289b1a5..cc07c8eb 100755
--- a/buildbot_test_toolchains.py
+++ b/buildbot_test_toolchains.py
@@ -56,6 +56,8 @@ IMAGE_RE_GROUPS = {
}
TRYBOT_IMAGE_RE = TRYBOT_IMAGE_FS.format(**IMAGE_RE_GROUPS)
+TELEMETRY_AQUARIUM_UNSUPPORTED = ['bob', 'elm', 'veyron_minnie']
+
class ToolchainComparator(object):
"""Class for doing the nightly tests work."""
@@ -175,7 +177,8 @@ class ToolchainComparator(object):
run_local: False
retries: 0
}
-
+ """
+ telemetry_aquarium_tests = """
benchmark: rendering.desktop {
run_local: False
suite: telemetry_Crosperf
@@ -195,6 +198,9 @@ class ToolchainComparator(object):
f.write(experiment_header)
f.write(experiment_tests)
+ if self._board not in TELEMETRY_AQUARIUM_UNSUPPORTED:
+ f.write(telemetry_aquarium_tests)
+
# Now add vanilla to test file.
official_image = """
vanilla_image {
@@ -277,7 +283,7 @@ class ToolchainComparator(object):
print('trybot_url: \
http://cros-goldeneye/chromeos/healthmonitoring/buildDetails?buildbucketId=%s'
% buildbucket_id)
- if len(trybot_image) == 0:
+ if not trybot_image:
self._l.LogError('Unable to find trybot_image!')
return 2
diff --git a/compiler_wrapper/android_config_test.go b/compiler_wrapper/android_config_test.go
index 104be6df..c61490f4 100644
--- a/compiler_wrapper/android_config_test.go
+++ b/compiler_wrapper/android_config_test.go
@@ -10,14 +10,13 @@ import (
"testing"
)
-const oldAndroidPathForTest = "$ANDROID_PREBUILTS/clang/host/linux-x86/clang-r353983c/bin/clang"
const androidGoldenDir = "testdata/android_golden"
func TestAndroidConfig(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := false
useCCache := false
- cfg, err := getConfig("android", useCCache, useLlvmNext, oldAndroidPathForTest, "123")
+ cfg, err := getConfig("android", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
diff --git a/compiler_wrapper/bisect_flag_test.go b/compiler_wrapper/bisect_flag_test.go
index 0bb6a820..5c4c82d6 100644
--- a/compiler_wrapper/bisect_flag_test.go
+++ b/compiler_wrapper/bisect_flag_test.go
@@ -131,14 +131,9 @@ func TestForwardGeneralErrorFromBisect(t *testing.T) {
func withBisectTestContext(t *testing.T, work func(ctx *testContext)) {
withTestContext(t, func(ctx *testContext) {
- // Disable comparing to the old wrapper as that calls the bisect_driver
- // directly from python, and the new wrapper calls it via a separate
- // sub command.
- ctx.cfg.oldWrapperPath = ""
ctx.env = []string{"BISECT_STAGE=xyz"}
// We execute the python script but replace the call to the bisect_driver with
- // a mock that logs the data in the same way as the oldwrapper. This way
- // we can reuse the parseOldWrapperCommands to get the values.
+ // a mock that logs the data.
ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
if err := verifyPath(cmd, "/usr/bin/env"); err != nil {
return err
@@ -177,6 +172,13 @@ bisect_driver = BisectDriver()
func mustCallBisectDriver(ctx *testContext, exitCode int) *command {
ctx.must(exitCode)
- cmds, _ := parseOldWrapperCommands(ctx.stdoutString())
- return cmds[0]
+ cmd := &command{}
+ for _, line := range strings.Split(ctx.stdoutString(), "\n") {
+ if prefix := "command "; strings.HasPrefix(line, prefix) {
+ cmd.Path = line[len(prefix):]
+ } else if prefix := "arg "; strings.HasPrefix(line, prefix) {
+ cmd.Args = append(cmd.Args, line[len(prefix):])
+ }
+ }
+ return cmd
}
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go
index 17c62db7..c614b99f 100644
--- a/compiler_wrapper/compiler_wrapper.go
+++ b/compiler_wrapper/compiler_wrapper.go
@@ -5,7 +5,6 @@
package main
import (
- "bytes"
"fmt"
"io"
"path/filepath"
@@ -29,11 +28,7 @@ func callCompiler(env env, cfg *config, inputCmd *command) int {
}
exitCode := 0
if compilerErr == nil {
- if cfg.oldWrapperPath != "" {
- exitCode, compilerErr = callCompilerWithRunAndCompareToOldWrapper(env, cfg, inputCmd)
- } else {
- exitCode, compilerErr = callCompilerInternal(env, cfg, inputCmd)
- }
+ exitCode, compilerErr = callCompilerInternal(env, cfg, inputCmd)
}
if compilerErr != nil {
printCompilerError(env.stderr(), compilerErr)
@@ -42,22 +37,6 @@ func callCompiler(env env, cfg *config, inputCmd *command) int {
return exitCode
}
-func callCompilerWithRunAndCompareToOldWrapper(env env, cfg *config, inputCmd *command) (exitCode int, err error) {
- stdinBuffer := &bytes.Buffer{}
- recordingEnv := &commandRecordingEnv{
- env: env,
- stdinReader: teeStdinIfNeeded(env, inputCmd, stdinBuffer),
- }
- // Note: this won't do a real exec as recordingEnv redirects exec to run.
- if exitCode, err = callCompilerInternal(recordingEnv, cfg, inputCmd); err != nil {
- return 0, err
- }
- if err = compareToOldWrapper(env, cfg, inputCmd, stdinBuffer.Bytes(), recordingEnv.cmdResults, exitCode); err != nil {
- return exitCode, err
- }
- return exitCode, nil
-}
-
func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int, err error) {
if err := checkUnsupportedFlags(inputCmd); err != nil {
return 0, err
@@ -170,6 +149,7 @@ func prepareClangCommand(builder *commandBuilder) (sysroot string, err error) {
sysroot = processSysrootFlag(builder)
}
builder.addPreUserArgs(builder.cfg.clangFlags...)
+ builder.addPostUserArgs(builder.cfg.clangPostFlags...)
calcCommonPreUserArgs(builder)
if err := processClangFlags(builder); err != nil {
return "", err
diff --git a/compiler_wrapper/compiler_wrapper_test.go b/compiler_wrapper/compiler_wrapper_test.go
index 71cd36df..67cbda92 100644
--- a/compiler_wrapper/compiler_wrapper_test.go
+++ b/compiler_wrapper/compiler_wrapper_test.go
@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
- "path/filepath"
"strings"
"syscall"
"testing"
@@ -50,27 +49,18 @@ func TestAddClangConfigFlags(t *testing.T) {
func TestLogGeneralExecError(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
- testOldWrapperPaths := []string{
- "",
- filepath.Join(ctx.tempDir, "fakewrapper"),
- }
- for _, testOldWrapperPath := range testOldWrapperPaths {
- ctx.cfg.oldWrapperPath = testOldWrapperPath
- // Note: No need to write the old wrapper as we don't execute
- // it due to the general error from the new error.
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- return errors.New("someerror")
- }
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
- if err := verifyInternalError(stderr); err != nil {
- t.Fatal(err)
- }
- if !strings.Contains(stderr, gccX86_64) {
- t.Errorf("could not find compiler path on stderr. Got: %s", stderr)
- }
- if !strings.Contains(stderr, "someerror") {
- t.Errorf("could not find original error on stderr. Got: %s", stderr)
- }
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
+ return errors.New("someerror")
+ }
+ stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ if err := verifyInternalError(stderr); err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(stderr, gccX86_64) {
+ t.Errorf("could not find compiler path on stderr. Got: %s", stderr)
+ }
+ if !strings.Contains(stderr, "someerror") {
+ t.Errorf("could not find original error on stderr. Got: %s", stderr)
}
})
}
@@ -93,50 +83,12 @@ func TestLogMissingCCacheExecError(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
ctx.cfg.useCCache = true
- testOldWrapperPaths := []string{
- "",
- filepath.Join(ctx.tempDir, "fakewrapper"),
- }
- for _, testOldWrapperPath := range testOldWrapperPaths {
- ctx.cfg.oldWrapperPath = testOldWrapperPath
- // Note: No need to write the old wrapper as we don't execute
- // it due to the general error from the new error.
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- return syscall.ENOENT
- }
- ctx.stderrBuffer.Reset()
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
- if err := verifyNonInternalError(stderr, "ccache not found under .*. Please install it"); err != nil {
- t.Fatal(err)
- }
- }
- })
-}
-
-func TestLogExitCodeErrorWhenComparingToOldWrapper(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writePythonMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- ExitCode: 2,
- },
- },
- })
- fmt.Fprint(stderr, "someerror")
- return newExitCodeError(2)
+ return syscall.ENOENT
}
-
- exitCode := callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc))
- if exitCode != 2 {
- t.Fatalf("Expected exit code 2. Got: %d", exitCode)
- }
- if err := verifyNonInternalError(ctx.stderrString(), "someerror"); err != nil {
+ ctx.stderrBuffer.Reset()
+ stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ if err := verifyNonInternalError(stderr, "ccache not found under .*. Please install it"); err != nil {
t.Fatal(err)
}
})
diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go
index 3720018e..5f389684 100644
--- a/compiler_wrapper/config.go
+++ b/compiler_wrapper/config.go
@@ -20,12 +20,11 @@ type config struct {
gccFlags []string
// Flags to add to clang only.
clangFlags []string
+ // Flags to add to clang only, AFTER user flags (cannot be overridden
+ // by the user).
+ clangPostFlags []string
// Toolchain root path relative to the wrapper binary.
rootRelPath string
- // Path of the old wrapper using the toolchain root.
- oldWrapperPath string
- // Whether to mock out the calls that the old wrapper does.
- mockOldWrapperCmds bool
// Directory to store errors that were prevented with -Wno-error.
newWarningsDir string
// Version. Only used for printing via -print-cmd.
@@ -62,16 +61,14 @@ func getRealConfig() (*config, error) {
if err != nil {
return nil, wrapErrorwithSourceLocf(err, "invalid format for UseLLvmNext")
}
- // FIXME: Remove comparison to old wrapper once the new wrapper has landed.
- oldWrapperPath := ""
- config, err := getConfig(ConfigName, useCCache, useLlvmNext, oldWrapperPath, Version)
+ config, err := getConfig(ConfigName, useCCache, useLlvmNext, Version)
if err != nil {
return nil, err
}
return config, nil
}
-func getConfig(configName string, useCCache bool, useLlvmNext bool, oldWrapperPath string, version string) (*config, error) {
+func getConfig(configName string, useCCache bool, useLlvmNext bool, version string) (*config, error) {
cfg := config{}
switch configName {
case "cros.hardened":
@@ -89,18 +86,14 @@ func getConfig(configName string, useCCache bool, useLlvmNext bool, oldWrapperPa
if useLlvmNext {
cfg.clangFlags = append(cfg.clangFlags, llvmNextFlags...)
}
- cfg.oldWrapperPath = oldWrapperPath
cfg.version = version
return &cfg, nil
}
-var llvmNextFlags = []string{
- "-Wno-reorder-init-list",
- "-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
- "-Wno-return-stack-address",
- "-Werror=poison-system-directories",
-}
+// TODO: Enable test in config_test.go, once we have new llvm-next flags.
+var llvmNextFlags = []string{}
+
+var llvmNextPostFlags = []string{}
// Full hardening.
// Temporarily disable function splitting because of chromium:434751.
@@ -132,6 +125,13 @@ var crosHardenedConfig = &config{
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
+ },
+ clangPostFlags: []string{
+ "-Wno-implicit-int-float-conversion",
},
newWarningsDir: "/tmp/fatal_clang_warnings",
}
@@ -156,6 +156,13 @@ var crosNonHardenedConfig = &config{
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
+ },
+ clangPostFlags: []string{
+ "-Wno-implicit-int-float-conversion",
},
newWarningsDir: "/tmp/fatal_clang_warnings",
}
@@ -181,8 +188,15 @@ var crosHostConfig = &config{
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
},
+ clangPostFlags: []string{
+ "-Wno-implicit-int-float-conversion",
+ },
newWarningsDir: "/tmp/fatal_clang_warnings",
}
@@ -193,5 +207,6 @@ var androidConfig = &config{
commonFlags: []string{},
gccFlags: []string{},
clangFlags: []string{},
+ clangPostFlags: []string{},
newWarningsDir: "/tmp/fatal_clang_warnings",
}
diff --git a/compiler_wrapper/config_test.go b/compiler_wrapper/config_test.go
index a11c2857..5492a1bb 100644
--- a/compiler_wrapper/config_test.go
+++ b/compiler_wrapper/config_test.go
@@ -38,6 +38,7 @@ func TestRealConfigWithUseCCacheFlag(t *testing.T) {
}
}
+/* TODO: Re-enable this, when llvm-next is different than llvm
func TestRealConfigWithUseLLvmFlag(t *testing.T) {
resetGlobals()
defer resetGlobals()
@@ -68,6 +69,7 @@ func TestRealConfigWithUseLLvmFlag(t *testing.T) {
t.Fatalf("UseLlvmNext: Expected an error, got none")
}
}
+*/
func TestRealConfigWithConfigNameFlag(t *testing.T) {
resetGlobals()
@@ -126,6 +128,7 @@ func isSysrootHardened(cfg *config) bool {
return false
}
+// TODO: Update this with correct flag when we change llvm-next.
func isUsingLLvmNext(cfg *config) bool {
for _, arg := range cfg.clangFlags {
if arg == "-Wno-reorder-init-list" {
diff --git a/compiler_wrapper/cros_hardened_config_test.go b/compiler_wrapper/cros_hardened_config_test.go
index 10d8bf6f..b459f1e2 100644
--- a/compiler_wrapper/cros_hardened_config_test.go
+++ b/compiler_wrapper/cros_hardened_config_test.go
@@ -6,15 +6,12 @@ package main
import (
"fmt"
- "io/ioutil"
"path"
"path/filepath"
- "regexp"
"strings"
"testing"
)
-const oldHardenedWrapperPathForTest = "$CHROOT/usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/gcc-bin/4.9.x/sysroot_wrapper.hardened"
const crosHardenedGoldenDir = "testdata/cros_hardened_golden"
const crosHardenedNoCCacheGoldenDir = "testdata/cros_hardened_noccache_golden"
const crosHardenedLlvmNextGoldenDir = "testdata/cros_hardened_llvmnext_golden"
@@ -23,7 +20,7 @@ func TestCrosHardenedConfig(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := false
useCCache := true
- cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
@@ -37,25 +34,12 @@ func TestCrosHardenedConfigWithoutCCache(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := false
useCCache := false
- cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
ctx.updateConfig(cfg)
- // Create a copy of the old wrapper where the CCACHE_DEFAULT is false.
- if ctx.cfg.oldWrapperPath != "" {
- oldWrapperContent, err := ioutil.ReadFile(ctx.cfg.oldWrapperPath)
- if err != nil {
- t.Fatal(err)
- }
- oldWrapperContent = regexp.MustCompile(`True\s+#\s+@CCACHE_DEFAULT@`).ReplaceAll(oldWrapperContent, []byte("False #"))
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "oldwrapper_noccache")
- if err := ioutil.WriteFile(ctx.cfg.oldWrapperPath, oldWrapperContent, 0666); err != nil {
- t.Fatal(err)
- }
- }
-
// Only run the subset of the sysroot wrapper tests that execute commands.
gomaPath := path.Join(ctx.tempDir, "gomacc")
ctx.writeFile(gomaPath, "")
@@ -75,31 +59,12 @@ func TestCrosHardenedConfigWithLlvmNext(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := true
useCCache := true
- cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
ctx.updateConfig(cfg)
- // Create a copy of the old wrapper where we add the llvm next flags
- if ctx.cfg.oldWrapperPath != "" {
- oldWrapperContent, err := ioutil.ReadFile(ctx.cfg.oldWrapperPath)
- if err != nil {
- t.Fatal(err)
- }
- oldWrapperLlvmNextFlags := `
-LLVM_NEXT_FLAGS_TO_ADD = set(['-Wno-reorder-init-list',
-'-Wno-final-dtor-non-final-class',
-'-Wno-implicit-int-float-conversion',
-'-Wno-return-stack-address'
-])`
- oldWrapperContent = regexp.MustCompile(`LLVM_NEXT_FLAGS_TO_ADD = set\(\[\]\)`).ReplaceAll(oldWrapperContent, []byte(oldWrapperLlvmNextFlags))
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "oldwrapper_llvmnext")
- if err := ioutil.WriteFile(ctx.cfg.oldWrapperPath, oldWrapperContent, 0666); err != nil {
- t.Fatal(err)
- }
- }
-
// Only run the subset of the sysroot wrapper tests that execute commands.
gomaPath := path.Join(ctx.tempDir, "gomacc")
ctx.writeFile(gomaPath, "")
@@ -187,10 +152,6 @@ func createGoldenInputsForAllTargets(compiler string, args ...string) goldenFile
func createBisectGoldenInputs(compiler string) goldenFile {
return goldenFile{
Name: "bisect.json",
- // Disable comparing to the old wrapper as that calls the bisect_driver
- // directly from python, and the new wrapper calls it via a separate
- // sub command.
- ignoreOldWrapper: true,
Records: []goldenRecord{
{
WrapperCmd: newGoldenCmd(compiler, mainCc),
diff --git a/compiler_wrapper/cros_host_config_test.go b/compiler_wrapper/cros_host_config_test.go
index d2be9ab6..fee78e62 100644
--- a/compiler_wrapper/cros_host_config_test.go
+++ b/compiler_wrapper/cros_host_config_test.go
@@ -9,8 +9,6 @@ import (
"testing"
)
-const oldClangHostWrapperPathForTest = "$CHROOT/usr/bin/clang_host_wrapper"
-const oldGccHostWrapperPathForTest = "$CHROOT/../src/third_party/chromiumos-overlay/sys-devel/gcc/files/host_wrapper"
const crosClangHostGoldenDir = "testdata/cros_clang_host_golden"
const crosGccHostGoldenDir = "testdata/cros_gcc_host_golden"
@@ -18,7 +16,7 @@ func TestCrosClangHostConfig(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := false
useCCache := false
- cfg, err := getConfig("cros.host", useCCache, useLlvmNext, oldClangHostWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.host", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
@@ -48,7 +46,7 @@ func TestCrosGccHostConfig(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := false
useCCache := false
- cfg, err := getConfig("cros.host", useCCache, useLlvmNext, oldGccHostWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.host", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
diff --git a/compiler_wrapper/cros_nonhardened_config_test.go b/compiler_wrapper/cros_nonhardened_config_test.go
index bf8af4d2..4883c5f9 100644
--- a/compiler_wrapper/cros_nonhardened_config_test.go
+++ b/compiler_wrapper/cros_nonhardened_config_test.go
@@ -8,14 +8,13 @@ import (
"testing"
)
-const oldNonHardenedWrapperPathForTest = "$CHROOT/usr/x86_64-pc-linux-gnu/arm-none-eabi/gcc-bin/4.9.x/sysroot_wrapper"
const crosNonHardenedGoldenDir = "testdata/cros_nonhardened_golden"
func TestCrosNonHardenedConfig(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
useLlvmNext := false
useCCache := true
- cfg, err := getConfig("cros.nonhardened", useCCache, useLlvmNext, oldNonHardenedWrapperPathForTest, "123")
+ cfg, err := getConfig("cros.nonhardened", useCCache, useLlvmNext, "123")
if err != nil {
t.Fatal(err)
}
diff --git a/compiler_wrapper/goldenutil_test.go b/compiler_wrapper/goldenutil_test.go
index 4eff8738..e6b42f77 100644
--- a/compiler_wrapper/goldenutil_test.go
+++ b/compiler_wrapper/goldenutil_test.go
@@ -21,9 +21,8 @@ var updateGoldenFiles = flag.Bool("updategolden", false, "update golden files")
var filterGoldenTests = flag.String("rungolden", "", "regex filter for golden tests to run")
type goldenFile struct {
- Name string `json:"name"`
- ignoreOldWrapper bool
- Records []goldenRecord `json:"records"`
+ Name string `json:"name"`
+ Records []goldenRecord `json:"records"`
}
type goldenRecord struct {
@@ -115,14 +114,8 @@ func filterGoldenRecords(pattern string, files []goldenFile) []goldenFile {
}
func fillGoldenResults(ctx *testContext, files []goldenFile) []goldenFile {
- oldWrapperPath := ctx.cfg.oldWrapperPath
newFiles := []goldenFile{}
for _, file := range files {
- ctx.cfg.oldWrapperPath = oldWrapperPath
- if file.ignoreOldWrapper {
- ctx.cfg.oldWrapperPath = ""
- }
-
newRecords := []goldenRecord{}
for _, record := range file.Records {
newCmds := []commandResult{}
diff --git a/compiler_wrapper/main.go b/compiler_wrapper/main.go
index 3fcf3a66..046cf5a5 100644
--- a/compiler_wrapper/main.go
+++ b/compiler_wrapper/main.go
@@ -6,24 +6,17 @@
// - main.UseCCache: Whether to use ccache.
// - main.ConfigName: Name of the configuration to use.
// See config.go for the supported values.
-// - main.OldWrapperPath: Path to the old wrapper to compare commands
-// against. Comparison is deactivated if empty.
//
// The script ./build simplifies the call to `go build`.
// E.g. ./build --use_ccache=true --config=cros.hardened will build a
// binary that uses the ccache for ChromeOS with hardened flags.
//
// Test arguments:
-// - crosroot: Specifies the ChromeOS toolchain root directory (aka chroot).
-// If this is given, golden tests will compare the produced commands against the
-// old compiler wrapper.
// - updategolden: To update the golden results for the wrapper. Without it,
// the tests will verify that the wrapper output matches the goldens.
// - rungolden: To filter the golden tests by a regex for the wrapper env, path and args.
//
// Examples:
-// - run all tests and compare golden output against old compiler wrapper:
-// go test third_party/toolchain-utils/compiler_wrapper/ -v --crosroot=$HOME/chromiumos/chroot/
// - run all tests in isolation:
// go test third_party/toolchain-utils/compiler_wrapper/ -v
package main
@@ -43,7 +36,7 @@ func main() {
log.Fatal(err)
}
// Note: callCompiler will exec the command. Only in case of
- // an error or when we are comparing against the old wrapper
+ // an error or when we run other commands like bisect
// will this os.Exit be called.
os.Exit(callCompiler(env, cfg, newProcessCommand()))
}
diff --git a/compiler_wrapper/oldwrapper.go b/compiler_wrapper/oldwrapper.go
deleted file mode 100644
index 72178da0..00000000
--- a/compiler_wrapper/oldwrapper.go
+++ /dev/null
@@ -1,392 +0,0 @@
-// Copyright 2019 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package main
-
-import (
- "bytes"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "reflect"
- "regexp"
- "sort"
- "strings"
- "text/template"
-)
-
-const compareToOldWrapperFilePattern = "old_wrapper_compare"
-
-// Note: We can't rely on os.TempDir as that just returns the value of $TMPDIR,
-// which some packages set incorrectly.
-// E.g. dev-python/pygobject sets it to "`pwd`/pygobject-2.18.0".
-const tempDir = "/tmp"
-
-func compareToOldWrapper(env env, cfg *config, inputCmd *command, stdinBuffer []byte, newCmdResults []*commandResult, newExitCode int) error {
- pythonStringEscaper := strings.NewReplacer("\n", "\\n", "'", "\\'", "\\", "\\\\")
-
- oldWrapperCfg, err := newOldWrapperConfig(env, cfg, inputCmd)
- if err != nil {
- return err
- }
- oldWrapperCfg.MockCmds = cfg.mockOldWrapperCmds
- newCmds := []*command{}
- for _, cmdResult := range newCmdResults {
- oldWrapperCfg.CmdResults = append(oldWrapperCfg.CmdResults, oldWrapperCmdResult{
- Stdout: pythonStringEscaper.Replace(cmdResult.Stdout),
- Stderr: pythonStringEscaper.Replace(cmdResult.Stderr),
- Exitcode: cmdResult.ExitCode,
- })
- newCmds = append(newCmds, cmdResult.Cmd)
- }
-
- stderrBuffer := bytes.Buffer{}
- oldExitCode := 0
- if strings.HasPrefix(oldWrapperCfg.OldWrapperContent, "#!/bin/sh") {
- oldExitCode, err = callOldShellWrapper(env, oldWrapperCfg, inputCmd, stdinBuffer, compareToOldWrapperFilePattern, &bytes.Buffer{}, &stderrBuffer)
- } else {
- oldExitCode, err = callOldPythonWrapper(env, oldWrapperCfg, inputCmd, stdinBuffer, compareToOldWrapperFilePattern, &bytes.Buffer{}, &stderrBuffer)
- }
- if err != nil {
- return err
- }
- differences := []string{}
- if oldExitCode != newExitCode {
- differences = append(differences, fmt.Sprintf("exit codes differ: old %d, new %d", oldExitCode, newExitCode))
- }
- oldCmds, stderr := parseOldWrapperCommands(stderrBuffer.String())
- if cmdDifferences := diffCommands(oldCmds, newCmds); cmdDifferences != "" {
- differences = append(differences, cmdDifferences)
- }
- if len(differences) > 0 {
- printCmd(env, inputCmd)
- return newErrorwithSourceLocf("wrappers differ:\n%s\nOld stderr:%s",
- strings.Join(differences, "\n"),
- stderr,
- )
- }
- return nil
-}
-
-func parseOldWrapperCommands(stderr string) (cmds []*command, remainingStderr string) {
- allStderrLines := strings.Split(stderr, "\n")
- remainingStderrLines := []string{}
- commandPrefix := "command "
- argPrefix := "arg "
- envUpdatePrefix := "envupdate "
- currentCmd := (*command)(nil)
- for _, line := range allStderrLines {
- if strings.HasPrefix(line, commandPrefix) {
- currentCmd = &command{
- Path: line[len(commandPrefix):],
- }
- cmds = append(cmds, currentCmd)
- } else if strings.HasPrefix(line, argPrefix) {
- currentCmd.Args = append(currentCmd.Args, line[len(argPrefix):])
- } else if strings.HasPrefix(line, envUpdatePrefix) {
- currentCmd.EnvUpdates = append(currentCmd.EnvUpdates, line[len(envUpdatePrefix):])
- } else {
- remainingStderrLines = append(remainingStderrLines, line)
- }
- }
- remainingStderr = strings.TrimSpace(strings.Join(remainingStderrLines, "\n"))
- return cmds, remainingStderr
-}
-
-func diffCommands(oldCmds []*command, newCmds []*command) string {
- maxLen := len(newCmds)
- if maxLen < len(oldCmds) {
- maxLen = len(oldCmds)
- }
- hasDifferences := false
- var cmdDifferences []string
- for i := 0; i < maxLen; i++ {
- var differences []string
- if i >= len(newCmds) {
- differences = append(differences, "missing command")
- } else if i >= len(oldCmds) {
- differences = append(differences, "extra command")
- } else {
- newCmd := newCmds[i]
- oldCmd := oldCmds[i]
-
- if newCmd.Path != oldCmd.Path {
- differences = append(differences, "path")
- }
-
- if !reflect.DeepEqual(newCmd.Args, oldCmd.Args) {
- differences = append(differences, "args")
- }
-
- // Sort the environment as we don't care in which order
- // it was modified.
- copyAndSort := func(data []string) []string {
- result := make([]string, len(data))
- copy(result, data)
- sort.Strings(result)
- return result
- }
-
- newEnvUpdates := copyAndSort(newCmd.EnvUpdates)
- oldEnvUpdates := copyAndSort(oldCmd.EnvUpdates)
-
- if !reflect.DeepEqual(newEnvUpdates, oldEnvUpdates) {
- differences = append(differences, "env updates")
- }
- }
- if len(differences) > 0 {
- hasDifferences = true
- } else {
- differences = []string{"none"}
- }
- cmdDifferences = append(cmdDifferences,
- fmt.Sprintf("Index %d: %s", i, strings.Join(differences, ",")))
- }
- if hasDifferences {
- return fmt.Sprintf("commands differ:\n%s\nOld:%#v\nNew:%#v",
- strings.Join(cmdDifferences, "\n"),
- dumpCommands(oldCmds),
- dumpCommands(newCmds))
- }
- return ""
-}
-
-func dumpCommands(cmds []*command) string {
- lines := []string{}
- for _, cmd := range cmds {
- lines = append(lines, fmt.Sprintf("%#v", cmd))
- }
- return strings.Join(lines, "\n")
-}
-
-// Note: field names are upper case so they can be used in
-// a template via reflection.
-type oldWrapperConfig struct {
- WrapperPath string
- CmdPath string
- OldWrapperContent string
- MockCmds bool
- CmdResults []oldWrapperCmdResult
-}
-
-type oldWrapperCmdResult struct {
- Stdout string
- Stderr string
- Exitcode int
-}
-
-func newOldWrapperConfig(env env, cfg *config, inputCmd *command) (*oldWrapperConfig, error) {
- absWrapperPath, err := getAbsWrapperPath(env, inputCmd)
- if err != nil {
- return nil, err
- }
- absOldWrapperPath := cfg.oldWrapperPath
- if !filepath.IsAbs(absOldWrapperPath) {
- absOldWrapperPath = filepath.Join(filepath.Dir(absWrapperPath), cfg.oldWrapperPath)
- }
- oldWrapperContentBytes, err := ioutil.ReadFile(absOldWrapperPath)
- if err != nil {
- return nil, wrapErrorwithSourceLocf(err, "failed to read old wrapper")
- }
- oldWrapperContent := string(oldWrapperContentBytes)
- return &oldWrapperConfig{
- WrapperPath: absWrapperPath,
- CmdPath: inputCmd.Path,
- OldWrapperContent: oldWrapperContent,
- }, nil
-}
-
-func callOldShellWrapper(env env, cfg *oldWrapperConfig, inputCmd *command, stdinBuffer []byte, filepattern string, stdout io.Writer, stderr io.Writer) (exitCode int, err error) {
- oldWrapperContent := cfg.OldWrapperContent
- oldWrapperContent = regexp.MustCompile(`(?m)^exec\b`).ReplaceAllString(oldWrapperContent, "exec_mock")
- oldWrapperContent = regexp.MustCompile(`\$EXEC`).ReplaceAllString(oldWrapperContent, "exec_mock")
- // TODO: Use strings.ReplaceAll once cros sdk uses golang >= 1.12
- oldWrapperContent = strings.Replace(oldWrapperContent, "$0", cfg.CmdPath, -1)
- cfg.OldWrapperContent = oldWrapperContent
- mockFile, err := ioutil.TempFile(tempDir, filepattern)
- if err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed to create tempfile")
- }
- defer os.Remove(mockFile.Name())
-
- const mockTemplate = `
-EXEC=exec
-
-function exec_mock {
- echo command "$1" 1>&2
- for arg in "${@:2}"; do
- echo arg "$arg" 1>&2
- done
- {{if .MockCmds}}
- echo '{{(index .CmdResults 0).Stdout}}'
- echo '{{(index .CmdResults 0).Stderr}}' 1>&2
- exit {{(index .CmdResults 0).Exitcode}}
- {{else}}
- $EXEC "$@"
- {{end}}
-}
-
-{{.OldWrapperContent}}
-`
- tmpl, err := template.New("mock").Parse(mockTemplate)
- if err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed to parse old wrapper template")
- }
- if err := tmpl.Execute(mockFile, cfg); err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed execute old wrapper template")
- }
- if err := mockFile.Close(); err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed to close temp file")
- }
-
- // Note: Using a self executable wrapper does not work due to a race condition
- // on unix systems. See https://github.com/golang/go/issues/22315
- oldWrapperCmd := &command{
- Path: "/bin/sh",
- Args: append([]string{mockFile.Name()}, inputCmd.Args...),
- EnvUpdates: inputCmd.EnvUpdates,
- }
- return wrapSubprocessErrorWithSourceLoc(oldWrapperCmd, env.run(oldWrapperCmd, bytes.NewReader(stdinBuffer), stdout, stderr))
-}
-
-func callOldPythonWrapper(env env, cfg *oldWrapperConfig, inputCmd *command, stdinBuffer []byte, filepattern string, stdout io.Writer, stderr io.Writer) (exitCode int, err error) {
- oldWrapperContent := cfg.OldWrapperContent
- // TODO: Use strings.ReplaceAll once cros sdk uses golang >= 1.12
- oldWrapperContent = strings.Replace(oldWrapperContent, "from __future__ import print_function", "", -1)
- // Replace sets with lists to make our comparisons deterministic
- oldWrapperContent = strings.Replace(oldWrapperContent, "set(", "ListSet(", -1)
- oldWrapperContent = strings.Replace(oldWrapperContent, "if __name__ == '__main__':", "def runMain():", -1)
- oldWrapperContent = strings.Replace(oldWrapperContent, "__file__", "'"+cfg.WrapperPath+"'", -1)
- cfg.OldWrapperContent = oldWrapperContent
-
- mockFile, err := ioutil.TempFile(tempDir, filepattern)
- if err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed to create tempfile")
- }
- defer os.Remove(mockFile.Name())
-
- const mockTemplate = `
-# -*- coding: utf-8 -*-
-from __future__ import print_function
-
-class ListSet:
- def __init__(self, values):
- self.values = list(values)
- def __contains__(self, key):
- return self.values.__contains__(key)
- def __iter__(self):
- return self.values.__iter__()
- def __nonzero__(self):
- return len(self.values) > 0
- def add(self, value):
- if value not in self.values:
- self.values.append(value)
- def discard(self, value):
- if value in self.values:
- self.values.remove(value)
- def intersection(self, values):
- return ListSet([value for value in self.values if value in values])
-
-{{.OldWrapperContent}}
-import subprocess
-
-init_env = os.environ.copy()
-
-{{if .MockCmds}}
-mockResults = [{{range .CmdResults}} {
- 'stdout': '{{.Stdout}}',
- 'stderr': '{{.Stderr}}',
- 'exitcode': {{.Exitcode}},
-},{{end}}]
-{{end}}
-
-def serialize_cmd(args):
- current_env = os.environ
- envupdates = [k + "=" + current_env.get(k, '') for k in set(list(current_env.keys()) + list(init_env.keys())) if current_env.get(k, '') != init_env.get(k, '')]
- print('command %s' % args[0], file=sys.stderr)
- for arg in args[1:]:
- print('arg %s' % arg, file=sys.stderr)
- for update in envupdates:
- print('envupdate %s' % update, file=sys.stderr)
-
-def check_output_mock(args):
- serialize_cmd(args)
- {{if .MockCmds}}
- result = mockResults.pop(0)
- print(result['stderr'], file=sys.stderr)
- if result['exitcode']:
- raise subprocess.CalledProcessError(result['exitcode'])
- return result['stdout']
- {{else}}
- return old_check_output(args)
- {{end}}
-
-old_check_output = subprocess.check_output
-subprocess.check_output = check_output_mock
-
-def popen_mock(args, stdout=None, stderr=None):
- serialize_cmd(args)
- {{if .MockCmds}}
- result = mockResults.pop(0)
- if stdout is None:
- print(result['stdout'], file=sys.stdout)
- if stderr is None:
- print(result['stderr'], file=sys.stderr)
-
- class MockResult:
- def __init__(self, returncode):
- self.returncode = returncode
- def wait(self):
- return self.returncode
- def communicate(self):
- return (result['stdout'], result['stderr'])
-
- return MockResult(result['exitcode'])
- {{else}}
- return old_popen(args)
- {{end}}
-
-old_popen = subprocess.Popen
-subprocess.Popen = popen_mock
-
-def execv_mock(binary, args):
- serialize_cmd([binary] + args[1:])
- {{if .MockCmds}}
- result = mockResults.pop(0)
- print(result['stdout'], file=sys.stdout)
- print(result['stderr'], file=sys.stderr)
- sys.exit(result['exitcode'])
- {{else}}
- old_execv(binary, args)
- {{end}}
-
-old_execv = os.execv
-os.execv = execv_mock
-
-sys.argv[0] = '{{.CmdPath}}'
-
-runMain()
-`
- tmpl, err := template.New("mock").Parse(mockTemplate)
- if err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed to parse old wrapper template")
- }
- if err := tmpl.Execute(mockFile, cfg); err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed execute old wrapper template")
- }
- if err := mockFile.Close(); err != nil {
- return 0, wrapErrorwithSourceLocf(err, "failed to close temp file")
- }
-
- // Note: Using a self executable wrapper does not work due to a race condition
- // on unix systems. See https://github.com/golang/go/issues/22315
- oldWrapperCmd := &command{
- Path: "/usr/bin/python2",
- Args: append([]string{"-S", mockFile.Name()}, inputCmd.Args...),
- EnvUpdates: inputCmd.EnvUpdates,
- }
- return wrapSubprocessErrorWithSourceLoc(oldWrapperCmd, env.run(oldWrapperCmd, bytes.NewReader(stdinBuffer), stdout, stderr))
-}
diff --git a/compiler_wrapper/oldwrapper_test.go b/compiler_wrapper/oldwrapper_test.go
deleted file mode 100644
index 4f5b3dc0..00000000
--- a/compiler_wrapper/oldwrapper_test.go
+++ /dev/null
@@ -1,431 +0,0 @@
-// Copyright 2019 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package main
-
-import (
- "bytes"
- "fmt"
- "io"
- "path/filepath"
- "strings"
- "testing"
- "text/template"
-)
-
-func TestCompareToOldPythonWrapperCompilerCommand(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- pathSuffix := ""
- extraArgs := []string{}
- exitCode := 0
- newWrapperExitCode := 0
-
- reset := func() {
- ctx.stderrBuffer.Reset()
- pathSuffix = ""
- extraArgs = []string{}
- exitCode = 0
- newWrapperExitCode = 0
- }
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writePythonMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path + pathSuffix,
- Args: append(cmd.Args, extraArgs...),
- ExitCode: exitCode,
- },
- },
- })
- if newWrapperExitCode != 0 {
- return newExitCodeError(newWrapperExitCode)
- }
- return nil
- }
-
- // Note: This will cause only the compiler command.
- inputCmd := ctx.newCommand(gccX86_64)
-
- reset()
- pathSuffix = "xyz"
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "Index 0: path") {
- t.Errorf("expected path difference error. Got: %s", stderr)
- }
-
- reset()
- extraArgs = []string{"xyz"}
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "Index 0: args") {
- t.Errorf("expected args difference error. Got: %s", stderr)
- }
-
- reset()
- exitCode = 1
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "exit codes differ: old 1, new 0") {
- t.Errorf("expected exit code difference error. Got: %s", stderr)
- }
-
- reset()
- newWrapperExitCode = 1
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "exit codes differ: old 0, new 1") {
- t.Errorf("expected exit code difference error. Got: %s", stderr)
- }
-
- reset()
- ctx.must(callCompiler(ctx, ctx.cfg, inputCmd))
- })
-}
-
-func TestCompareToOldPythonWrapperNestedCommand(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- pathSuffix := ""
- extraArgs := []string{}
- wrapperCfg := &mockWrapperConfig{}
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- isNestedCmd := len(wrapperCfg.Cmds) == 0
- var wrapperCmd *mockWrapperCmd
- if isNestedCmd {
- wrapperCmd = &mockWrapperCmd{
- Path: cmd.Path + pathSuffix,
- Args: append(cmd.Args, extraArgs...),
- }
- } else {
- wrapperCmd = &mockWrapperCmd{
- Path: cmd.Path,
- Args: cmd.Args,
- }
- }
- wrapperCfg.Cmds = append(wrapperCfg.Cmds, wrapperCmd)
- if !isNestedCmd {
- writePythonMockWrapper(ctx, wrapperCfg)
- }
- return nil
- }
-
- // Note: This will cause a nested command call.
- inputCmd := ctx.newCommand(clangX86_64, "-Xclang-path=somedir", mainCc)
-
- ctx.stderrBuffer.Reset()
- wrapperCfg = &mockWrapperConfig{}
- pathSuffix = "xyz"
- extraArgs = nil
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "Index 0: path") {
- t.Errorf("expected path difference error. Got: %s", stderr)
- }
- if !strings.Contains(stderr, "Index 1: none") {
- t.Errorf("expected no difference for cmd index 1. Got: %s", stderr)
- }
-
- ctx.stderrBuffer.Reset()
- wrapperCfg = &mockWrapperConfig{}
- pathSuffix = ""
- extraArgs = []string{"xyz"}
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "Index 0: args") {
- t.Errorf("expected args difference error. Got: %s", stderr)
- }
- if !strings.Contains(stderr, "Index 1: none") {
- t.Errorf("expected no difference for cmd index 1. Got: %s", stderr)
- }
-
- wrapperCfg = &mockWrapperConfig{}
- pathSuffix = ""
- extraArgs = nil
- ctx.must(callCompiler(ctx, ctx.cfg, inputCmd))
- })
-}
-
-func TestCompareToOldShellWrapperCompilerCommand(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- pathSuffix := ""
- extraArgs := []string{}
- exitCode := 0
- newWrapperExitCode := 0
-
- reset := func() {
- ctx.stderrBuffer.Reset()
- pathSuffix = ""
- extraArgs = []string{}
- exitCode = 0
- newWrapperExitCode = 0
- }
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writeShellMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path + pathSuffix,
- Args: append(cmd.Args, extraArgs...),
- ExitCode: exitCode,
- },
- },
- })
- if newWrapperExitCode != 0 {
- return newExitCodeError(newWrapperExitCode)
- }
- return nil
- }
-
- // Note: This will cause only the compiler command.
- inputCmd := ctx.newCommand(gccX86_64)
-
- reset()
- pathSuffix = "xyz"
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "Index 0: path") {
- t.Errorf("expected path difference error. Got: %s", stderr)
- }
-
- reset()
- extraArgs = []string{"xyz"}
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "Index 0: args") {
- t.Errorf("expected args difference error. Got: %s", stderr)
- }
-
- reset()
- exitCode = 1
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "exit codes differ: old 1, new 0") {
- t.Errorf("expected exit code difference error. Got: %s", stderr)
- }
-
- reset()
- newWrapperExitCode = 1
- stderr = ctx.mustFail(callCompiler(ctx, ctx.cfg, inputCmd))
- if !strings.Contains(stderr, "exit codes differ: old 0, new 1") {
- t.Errorf("expected exit code difference error. Got: %s", stderr)
- }
-
- reset()
- ctx.must(callCompiler(ctx, ctx.cfg, inputCmd))
-
- reset()
- ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, " spaces ")))
- })
-}
-
-func TestCompareToOldWrapperEscapeStdoutAndStderr(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- io.WriteString(stdout, "a\n'b'\\")
- io.WriteString(stderr, "c\n'd'\\")
- writePythonMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- },
- },
- })
- return nil
- }
-
- ctx.must(callCompiler(ctx, ctx.cfg,
- ctx.newCommand(clangX86_64, mainCc)))
- if ctx.stdoutString() != "a\n'b'\\" {
- t.Errorf("unexpected stdout. Got: %s", ctx.stdoutString())
- }
- if ctx.stderrString() != "c\n'd'\\" {
- t.Errorf("unexpected stderr. Got: %s", ctx.stderrString())
- }
- })
-}
-
-func TestCompareToOldWrapperSupportUtf8InStdoutAndStderr(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- io.WriteString(stdout, "©")
- io.WriteString(stderr, "®")
- writePythonMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- },
- },
- })
- return nil
- }
-
- ctx.must(callCompiler(ctx, ctx.cfg,
- ctx.newCommand(clangX86_64, mainCc)))
- if ctx.stdoutString() != "©" {
- t.Errorf("unexpected stdout. Got: %s", ctx.stdoutString())
- }
- if ctx.stderrString() != "®" {
- t.Errorf("unexpected stderr. Got: %s", ctx.stderrString())
- }
- })
-}
-
-func TestCompareToOldPythonWrapperArgumentsWithSpaces(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writePythonMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- },
- },
- })
- return nil
- }
-
- ctx.must(callCompiler(ctx, ctx.cfg,
- ctx.newCommand(clangX86_64, "a b", "c", mainCc)))
- })
-}
-
-func TestCompareToOldShellWrapperArgumentsWithSpaces(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writeShellMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- },
- },
- })
- return nil
- }
-
- ctx.must(callCompiler(ctx, ctx.cfg,
- ctx.newCommand(clangX86_64, "a b", "c", mainCc)))
- })
-}
-
-func TestForwardStdinWhenUsingOldWrapper(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- io.WriteString(&ctx.stdinBuffer, "someinput")
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writeShellMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- },
- },
- })
- stdinStr := ctx.readAllString(stdin)
- if stdinStr != "someinput" {
- return fmt.Errorf("unexpected stdin. Got: %s", stdinStr)
- }
- return nil
- }
-
- ctx.must(callCompiler(ctx, ctx.cfg,
- ctx.newCommand(clangX86_64, "-", mainCc)))
- })
-}
-
-func writePythonMockWrapper(ctx *testContext, cfg *mockWrapperConfig) {
- const mockTemplate = `
-from __future__ import print_function
-import os
-import sys
-import subprocess
-
-mockCmds = [{{range .Cmds}} {
- 'path': '{{.Path}}',
- 'args': [{{range .Args}}'{{.}}',{{end}}],
- 'exitcode': {{.ExitCode}},
-},{{end}}]
-
-def execv_impl(binary, args):
- cmd = mockCmds.pop(0)
- sys.exit(cmd['exitcode'])
-os.execv = execv_impl
-
-def check_output_impl(args):
- cmd = mockCmds.pop(0)
- if cmd['exitcode']:
- raise subprocess.CalledProcessError(cmd['exitcode'])
- return ""
-subprocess.check_output = check_output_impl
-
-def main():
- while len(mockCmds) > 1:
- subprocess.check_output([mockCmds[0]['path']] + mockCmds[0]['args'])
-
- os.execv(mockCmds[0]['path'], [mockCmds[0]['path']] + mockCmds[0]['args'])
-
-if __name__ == '__main__':
- sys.exit(main())
-`
- tmpl, err := template.New("mock").Parse(mockTemplate)
- if err != nil {
- ctx.t.Fatalf("failed to parse old wrapper template. Error: %s", err)
- }
- buf := bytes.Buffer{}
- if err := tmpl.Execute(&buf, cfg); err != nil {
- ctx.t.Fatalf("failed to execute the template. Error: %s", err)
- }
- ctx.writeFile(ctx.cfg.oldWrapperPath, buf.String())
-}
-
-func writeShellMockWrapper(ctx *testContext, cfg *mockWrapperConfig) {
- const mockTemplate = `#!/bin/sh
-EXEC=fake_exec
-
-function fake_exec {
- exit {{(index .Cmds 0).ExitCode}}
-}
-
-$EXEC "{{(index .Cmds 0).Path}}"{{range (index .Cmds 0).Args}} "{{.}}"{{end}}
-`
- tmpl, err := template.New("mock").Parse(mockTemplate)
- if err != nil {
- ctx.t.Fatalf("failed to parse old wrapper template. Error: %s", err)
- }
- buf := bytes.Buffer{}
- if err := tmpl.Execute(&buf, cfg); err != nil {
- ctx.t.Fatalf("failed to execute the template. Error: %s", err)
- }
- ctx.writeFile(ctx.cfg.oldWrapperPath, buf.String())
-}
-
-// Note: Fields have to be uppercase so that they can be used with template.
-type mockWrapperConfig struct {
- Cmds []*mockWrapperCmd
-}
-
-// Note: Fields have to be uppercase so that they can be used with template.
-type mockWrapperCmd struct {
- Path string
- Args []string
- ExitCode int
-}
diff --git a/compiler_wrapper/print_config_flag_test.go b/compiler_wrapper/print_config_flag_test.go
index 1b1528e8..63451edb 100644
--- a/compiler_wrapper/print_config_flag_test.go
+++ b/compiler_wrapper/print_config_flag_test.go
@@ -10,7 +10,7 @@ import (
)
func TestRemovePrintConfigArg(t *testing.T) {
- withPrintConfigTestContext(t, func(ctx *testContext) {
+ withTestContext(t, func(ctx *testContext) {
cmd := ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-print-config", mainCc)))
if err := verifyArgCount(cmd, 0, "-print-config"); err != nil {
t.Error(err)
@@ -19,18 +19,10 @@ func TestRemovePrintConfigArg(t *testing.T) {
}
func TestPrintConfig(t *testing.T) {
- withPrintConfigTestContext(t, func(ctx *testContext) {
+ withTestContext(t, func(ctx *testContext) {
ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-print-config", mainCc)))
if !strings.Contains(ctx.stderrString(), "wrapper config: main.config{") {
t.Errorf("config not printed to stderr. Got: %s", ctx.stderrString())
}
})
}
-
-func withPrintConfigTestContext(t *testing.T, work func(ctx *testContext)) {
- withTestContext(t, func(ctx *testContext) {
- // Not comparing to old wrapper as the old wrapper doesn't have a print-config command.
- ctx.cfg.oldWrapperPath = ""
- work(ctx)
- })
-}
diff --git a/compiler_wrapper/rusage_flag_test.go b/compiler_wrapper/rusage_flag_test.go
index 7acba0c8..bd0f980c 100644
--- a/compiler_wrapper/rusage_flag_test.go
+++ b/compiler_wrapper/rusage_flag_test.go
@@ -164,10 +164,6 @@ func TestLogRusageAppendsToFile(t *testing.T) {
func withLogRusageTestContext(t *testing.T, work func(ctx *testContext)) {
withTestContext(t, func(ctx *testContext) {
- // Disable comparing to the old wrapper as that uses fork + wait3
- // to calculate resource usage, and the new wrapper uses the getrusage
- // syscall.
- ctx.cfg.oldWrapperPath = ""
ctx.env = []string{"GETRUSAGE=" + filepath.Join(ctx.tempDir, "rusage.log")}
work(ctx)
})
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json b/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json
index b9b1509f..5920a365 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json
@@ -32,8 +32,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -73,8 +78,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -117,8 +127,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_ftrapv_maincc_target_specific.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_ftrapv_maincc_target_specific.json
index 18a54945..b52f0c85 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_ftrapv_maincc_target_specific.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_ftrapv_maincc_target_specific.json
@@ -23,8 +23,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -54,8 +59,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -85,8 +95,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -116,8 +131,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -147,8 +167,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -178,8 +203,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -209,8 +239,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -240,8 +275,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -271,8 +311,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_host_wrapper.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_host_wrapper.json
index d46586f2..251694e8 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_host_wrapper.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_host_wrapper.json
@@ -22,8 +22,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_maincc_target_specific.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_maincc_target_specific.json
index 812686c7..e5a8afa7 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_maincc_target_specific.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_maincc_target_specific.json
@@ -22,8 +22,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -52,8 +57,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -82,8 +92,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -112,8 +127,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -142,8 +162,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -172,8 +197,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -202,8 +232,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -232,8 +267,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -262,8 +302,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json
index 61537a59..cb175e05 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_path.json
@@ -22,8 +22,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -55,8 +60,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stdout": "somemessage",
@@ -88,8 +98,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -121,8 +136,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -161,10 +181,15 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -206,10 +231,15 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -251,10 +281,15 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stdout": "somemessage",
@@ -286,8 +321,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -316,8 +356,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -346,8 +391,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -376,8 +426,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -409,8 +464,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_sanitizer_args.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_sanitizer_args.json
index be1a2922..3df459fa 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_sanitizer_args.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_sanitizer_args.json
@@ -24,9 +24,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fsanitize=kernel-address",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -57,9 +62,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fsanitize=kernel-address",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -90,9 +100,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fsanitize=kernel-address",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -123,9 +138,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fsanitize=kernel-address",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -155,10 +175,15 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fno-experimental-new-pass-manager",
"-fsanitize=fuzzer",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -189,11 +214,16 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fno-experimental-new-pass-manager",
"-fsanitize=address",
"-fprofile-instr-generate",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -223,9 +253,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fsanitize=address",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -255,9 +290,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-fprofile-instr-generate",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json
index 40a84449..40427b96 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json
@@ -33,8 +33,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -64,9 +69,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-Wno-#warnings",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -96,9 +106,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-Wno-error=uninitialized",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -128,9 +143,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-Wno-error=unused-variable",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -160,9 +180,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-Wno-unused-variable",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -192,9 +217,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-Wunused-variable",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -224,9 +254,14 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"-someflag",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clangtidy.json b/compiler_wrapper/testdata/cros_clang_host_golden/clangtidy.json
index b6588995..eebda022 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clangtidy.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clangtidy.json
@@ -38,8 +38,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
},
@@ -55,8 +60,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -102,8 +112,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
},
@@ -119,8 +134,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -168,8 +188,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stdout": "somemessage",
@@ -188,8 +213,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -238,8 +268,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
},
@@ -255,8 +290,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json
index c3c316bf..248fcb4b 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json
@@ -25,8 +25,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
}
}
@@ -58,8 +63,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stderr": "-Werror originalerror",
@@ -77,8 +87,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Wno-error"
]
}
@@ -113,8 +128,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
- "main.cc"
+ "main.cc",
+ "-Wno-implicit-int-float-conversion"
]
},
"stderr": "-Werror originalerror",
@@ -132,8 +152,13 @@
"-Wno-deprecated-declarations",
"-Wno-tautological-constant-compare",
"-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unknown-warning-option",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Wno-error"
]
},
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_golden/bisect.json
index f9a503f3..c1daaa88 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/bisect.json
@@ -35,12 +35,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -92,12 +97,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -152,12 +162,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_ftrapv_maincc_target_specific.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_ftrapv_maincc_target_specific.json
index 847d0e5f..f71551be 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_ftrapv_maincc_target_specific.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_ftrapv_maincc_target_specific.json
@@ -26,6 +26,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -33,6 +37,7 @@
"-fno-omit-frame-pointer",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -74,6 +79,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -81,6 +90,7 @@
"-fno-omit-frame-pointer",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-eabi"
@@ -122,6 +132,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -129,6 +143,7 @@
"-fno-omit-frame-pointer",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-win-gnu"
@@ -170,6 +185,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -177,6 +196,7 @@
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-linux-gnu"
@@ -218,6 +238,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -225,6 +249,7 @@
"-fno-omit-frame-pointer",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-eabi"
@@ -266,6 +291,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -273,6 +302,7 @@
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-win-gnu"
@@ -314,6 +344,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -321,6 +355,7 @@
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-linux-gnu"
@@ -362,6 +397,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -369,6 +408,7 @@
"-fno-omit-frame-pointer",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-eabi"
@@ -410,6 +450,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -417,6 +461,7 @@
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-win-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_maincc_target_specific.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_maincc_target_specific.json
index 15241001..0dae3e82 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_maincc_target_specific.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_maincc_target_specific.json
@@ -25,12 +25,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -71,12 +76,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-eabi"
@@ -117,12 +127,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-win-gnu"
@@ -163,12 +178,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-linux-gnu"
@@ -209,12 +229,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-eabi"
@@ -255,12 +280,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-win-gnu"
@@ -301,12 +331,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-linux-gnu"
@@ -347,12 +382,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-eabi"
@@ -393,12 +433,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-win-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json
index 86cead04..6932398b 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_path.json
@@ -25,12 +25,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -74,12 +79,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -123,12 +133,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -172,12 +187,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -228,6 +248,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -236,6 +260,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -289,6 +314,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -297,6 +326,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -344,6 +374,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -352,6 +386,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -395,12 +430,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -441,12 +481,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -487,12 +532,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -533,12 +583,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -582,12 +637,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_sanitizer_args.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_sanitizer_args.json
index 39094948..398b6d5c 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_sanitizer_args.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_sanitizer_args.json
@@ -27,12 +27,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-fno-omit-frame-pointer",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -75,12 +80,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-fno-omit-frame-pointer",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -123,12 +133,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-fno-omit-frame-pointer",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -171,12 +186,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-fno-omit-frame-pointer",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -218,6 +238,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -225,6 +249,7 @@
"-fno-experimental-new-pass-manager",
"-fsanitize=fuzzer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -267,6 +292,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -275,6 +304,7 @@
"-fsanitize=address",
"-fprofile-instr-generate",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -316,12 +346,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-fno-omit-frame-pointer",
"-fsanitize=address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -363,6 +398,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -370,6 +409,7 @@
"-fno-omit-frame-pointer",
"-fprofile-instr-generate",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json
index c9ad6e46..a1a05c22 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json
@@ -36,12 +36,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -83,6 +88,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -90,6 +99,7 @@
"-fno-omit-frame-pointer",
"-Wno-#warnings",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -131,6 +141,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -138,6 +152,7 @@
"-fno-omit-frame-pointer",
"-Wno-error=uninitialized",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -179,6 +194,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -186,6 +205,7 @@
"-fno-omit-frame-pointer",
"-Wno-error=unused-variable",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -227,6 +247,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -234,6 +258,7 @@
"-fno-omit-frame-pointer",
"-Wno-unused-variable",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -275,6 +300,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -282,6 +311,7 @@
"-fno-omit-frame-pointer",
"-Wunused-variable",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -323,6 +353,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -330,6 +364,7 @@
"-fno-omit-frame-pointer",
"-someflag",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_sysroot_wrapper_common.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_sysroot_wrapper_common.json
index ff68d4bd..161bad6f 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_sysroot_wrapper_common.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_sysroot_wrapper_common.json
@@ -60,12 +60,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -109,12 +114,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -150,10 +160,15 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -195,11 +210,16 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"-fno-stack-protector",
"-D__KERNEL__",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -241,11 +261,16 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-D_FORTIFY_SOURCE=2",
"-mthumb",
"-fno-stack-protector",
"-D__KERNEL__",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7a-cros-linux-gnueabihf"
@@ -286,6 +311,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -293,6 +322,7 @@
"-fno-omit-frame-pointer",
"--sysroot=xyz",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clangtidy.json b/compiler_wrapper/testdata/cros_hardened_golden/clangtidy.json
index 03d0c437..d75eb527 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clangtidy.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clangtidy.json
@@ -40,12 +40,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -66,12 +71,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -122,12 +132,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -149,12 +164,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -207,12 +227,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -237,12 +262,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -296,12 +326,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -323,12 +358,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json
index f80d9b65..f975f452 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json
@@ -28,12 +28,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -77,12 +82,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -112,12 +122,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -164,12 +179,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -199,12 +219,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/gcc_clang_syntax.json b/compiler_wrapper/testdata/cros_hardened_golden/gcc_clang_syntax.json
index b9778247..b9582f6d 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/gcc_clang_syntax.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/gcc_clang_syntax.json
@@ -25,12 +25,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -95,12 +100,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -159,12 +169,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -207,12 +222,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json
index 56b7b3ed..c1daaa88 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json
@@ -37,7 +37,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -46,6 +45,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -99,7 +99,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -108,6 +107,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -164,7 +164,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -173,6 +172,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json
index 09f39ebd..6932398b 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json
@@ -27,7 +27,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -36,6 +35,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -81,7 +81,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -90,6 +89,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -135,7 +135,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -144,6 +143,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -189,7 +189,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -198,6 +197,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -250,7 +250,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -261,6 +260,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -316,7 +316,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -327,6 +326,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -376,7 +376,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -387,6 +386,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -432,7 +432,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -441,6 +440,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -483,7 +483,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -492,6 +491,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -534,7 +534,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -543,6 +542,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -585,7 +585,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -594,6 +593,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -639,7 +639,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -648,6 +647,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json
index d4b1e970..d75eb527 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json
@@ -42,7 +42,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -51,6 +50,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -73,7 +73,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -82,6 +81,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -134,7 +134,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -143,6 +142,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -166,7 +166,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -175,6 +174,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -229,7 +229,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -238,6 +237,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -264,7 +264,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -273,6 +272,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -328,7 +328,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -337,6 +336,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -360,7 +360,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -369,6 +368,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json
index e197de4c..f975f452 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json
@@ -30,7 +30,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -39,6 +38,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -84,7 +84,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -93,6 +92,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -124,7 +124,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -133,6 +132,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -181,7 +181,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -190,6 +189,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -221,7 +221,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -230,6 +229,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json
index a4305412..b9582f6d 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json
@@ -27,7 +27,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -36,6 +35,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -102,7 +102,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -111,6 +110,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -171,7 +171,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -180,6 +179,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -224,7 +224,6 @@
"-fuse-ld=lld",
"-Wno-reorder-init-list",
"-Wno-final-dtor-non-final-class",
- "-Wno-implicit-int-float-conversion",
"-Wno-return-stack-address",
"-Werror=poison-system-directories",
"-fstack-protector-strong",
@@ -233,6 +232,7 @@
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json
index f3061817..46c29635 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json
@@ -34,12 +34,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -84,12 +89,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -137,12 +147,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json
index 8062e8a5..096d1aaf 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/clang_path.json
@@ -24,12 +24,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -66,12 +71,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -108,12 +118,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -150,12 +165,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -199,6 +219,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -207,6 +231,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -254,6 +279,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -262,6 +291,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -308,6 +338,10 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
@@ -316,6 +350,7 @@
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -352,12 +387,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -391,12 +431,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -430,12 +475,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -469,12 +519,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -511,12 +566,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/clangtidy.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/clangtidy.json
index 03d0c437..d75eb527 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/clangtidy.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/clangtidy.json
@@ -40,12 +40,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -66,12 +71,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -122,12 +132,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -149,12 +164,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -207,12 +227,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -237,12 +262,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -296,12 +326,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -323,12 +358,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json
index 5510eec8..59dfb93e 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json
@@ -27,12 +27,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -69,12 +74,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -97,12 +107,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -142,12 +157,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -170,12 +190,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_clang_syntax.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_clang_syntax.json
index ff7b3c9d..1bb779f0 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_clang_syntax.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/gcc_clang_syntax.json
@@ -25,12 +25,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -89,12 +94,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -153,12 +163,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -201,12 +216,17 @@
"-Wno-section",
"-static-libgcc",
"-fuse-ld=lld",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fstack-protector-strong",
"-fPIE",
"-pie",
"-D_FORTIFY_SOURCE=2",
"-fno-omit-frame-pointer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json b/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json
index 4bc696d3..b97c379d 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json
@@ -32,7 +32,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -81,7 +86,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -133,7 +143,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_ftrapv_maincc_target_specific.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_ftrapv_maincc_target_specific.json
index d7b5258d..ae4a85c3 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_ftrapv_maincc_target_specific.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_ftrapv_maincc_target_specific.json
@@ -23,8 +23,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -63,8 +68,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-eabi"
@@ -103,8 +113,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-win-gnu"
@@ -143,9 +158,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-linux-gnu"
@@ -184,8 +204,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-eabi"
@@ -224,9 +249,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-win-gnu"
@@ -265,9 +295,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-linux-gnu"
@@ -306,8 +341,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-eabi"
@@ -346,9 +386,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"-ftrapv",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-win-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_maincc_target_specific.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_maincc_target_specific.json
index e78a420a..bf91b019 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_maincc_target_specific.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_maincc_target_specific.json
@@ -22,7 +22,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -60,7 +65,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-eabi"
@@ -98,7 +108,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-win-gnu"
@@ -136,8 +151,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-linux-gnu"
@@ -175,7 +195,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-eabi"
@@ -213,8 +238,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7m-cros-win-gnu"
@@ -252,8 +282,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-linux-gnu"
@@ -291,7 +326,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-eabi"
@@ -329,8 +369,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv8m-cros-win-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json
index 2a30100c..2f843529 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_path.json
@@ -22,7 +22,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -63,7 +68,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -104,7 +114,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -145,7 +160,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -193,9 +213,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -246,9 +271,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -293,9 +323,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-resource-dir=someResourceDir",
"--gcc-toolchain=/usr",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -336,7 +371,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -374,7 +414,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -412,7 +457,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-Ba/b/bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -450,7 +500,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -491,7 +546,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sanitizer_args.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sanitizer_args.json
index 386e82d6..9cc90057 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sanitizer_args.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sanitizer_args.json
@@ -24,8 +24,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -65,8 +70,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -106,8 +116,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -147,8 +162,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fsanitize=kernel-address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -187,9 +207,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fno-experimental-new-pass-manager",
"-fsanitize=fuzzer",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -229,10 +254,15 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fno-experimental-new-pass-manager",
"-fsanitize=address",
"-fprofile-instr-generate",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -271,8 +301,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fsanitize=address",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -311,8 +346,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fprofile-instr-generate",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json
index c8d16bfe..c1c78dc2 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json
@@ -33,7 +33,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -72,8 +77,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-#warnings",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -112,8 +122,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-error=uninitialized",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -152,8 +167,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-error=unused-variable",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -192,8 +212,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wno-unused-variable",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -232,8 +257,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-Wunused-variable",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -272,8 +302,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-someflag",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sysroot_wrapper_common.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sysroot_wrapper_common.json
index d0788a6b..46c0c832 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sysroot_wrapper_common.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_sysroot_wrapper_common.json
@@ -53,7 +53,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -94,7 +99,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -127,7 +137,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -166,9 +181,14 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-fno-stack-protector",
"-D__KERNEL__",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -207,10 +227,15 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"-mthumb",
"-fno-stack-protector",
"-D__KERNEL__",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"armv7a-cros-linux-gnueabihf"
@@ -248,8 +273,13 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"--sysroot=xyz",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clangtidy.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clangtidy.json
index 22dd9ddc..3a15badd 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clangtidy.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clangtidy.json
@@ -37,7 +37,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -55,7 +60,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -103,7 +113,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -122,7 +137,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -172,7 +192,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -194,7 +219,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -245,7 +275,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -264,7 +299,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json
index a99c1067..787ce95d 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json
@@ -25,7 +25,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -66,7 +71,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -93,7 +103,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -137,7 +152,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu"
@@ -164,7 +184,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_clang_syntax.json b/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_clang_syntax.json
index 81b81a2f..c8db8869 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_clang_syntax.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/gcc_clang_syntax.json
@@ -22,7 +22,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -80,7 +85,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -132,7 +142,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
@@ -172,7 +187,12 @@
"-Wno-unknown-warning-option",
"-Wno-section",
"-static-libgcc",
+ "-Wno-reorder-init-list",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-return-stack-address",
+ "-Werror=poison-system-directories",
"main.cc",
+ "-Wno-implicit-int-float-conversion",
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testutil_test.go b/compiler_wrapper/testutil_test.go
index c0e49fdd..57a68df2 100644
--- a/compiler_wrapper/testutil_test.go
+++ b/compiler_wrapper/testutil_test.go
@@ -6,7 +6,6 @@ package main
import (
"bytes"
- "flag"
"fmt"
"io"
"io/ioutil"
@@ -18,9 +17,6 @@ import (
"testing"
)
-var crosRootDirFlag = flag.String("crosroot", "", "root dir of the chrome os toolchain")
-var androidPrebuiltsDirFlag = flag.String("androidprebuilts", "", "prebuilts dir of android")
-
const mainCc = "main.cc"
const clangAndroid = "./clang"
const clangX86_64 = "./x86_64-cros-linux-gnu-clang"
@@ -107,22 +103,6 @@ func (ctx *testContext) stderrString() string {
}
func (ctx *testContext) run(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- // Keep calling the old wrapper when we are comparing the output of the
- // old wrapper to the new wrapper.
- if isCompareToOldWrapperCmd(cmd) {
- // Make sure we have a PATH in the env as the old wrapper needs that.
- pathFound := false
- for _, arg := range ctx.env {
- if arg == "PATH" {
- pathFound = true
- break
- }
- }
- if !pathFound {
- ctx.env = append(ctx.env, "PATH=")
- }
- return runCmd(ctx, cmd, nil, stdout, stderr)
- }
ctx.cmdCount++
ctx.lastCmd = cmd
if ctx.cmdMock != nil {
@@ -157,21 +137,7 @@ func (ctx *testContext) mustFail(exitCode int) string {
func (ctx *testContext) updateConfig(cfg *config) {
*ctx.cfg = *cfg
- ctx.cfg.mockOldWrapperCmds = true
ctx.cfg.newWarningsDir = filepath.Join(ctx.tempDir, "fatal_clang_warnings")
- if strings.HasPrefix(ctx.cfg.oldWrapperPath, "$CHROOT") {
- if *crosRootDirFlag != "" && ctx.cfg.oldWrapperPath != "" {
- ctx.cfg.oldWrapperPath = strings.Replace(ctx.cfg.oldWrapperPath, "$CHROOT", *crosRootDirFlag, -1)
- } else {
- ctx.cfg.oldWrapperPath = ""
- }
- } else if strings.HasPrefix(ctx.cfg.oldWrapperPath, "$ANDROID_PREBUILTS") {
- if *androidPrebuiltsDirFlag != "" && ctx.cfg.oldWrapperPath != "" {
- ctx.cfg.oldWrapperPath = strings.Replace(ctx.cfg.oldWrapperPath, "$ANDROID_PREBUILTS", *androidPrebuiltsDirFlag, -1)
- } else {
- ctx.cfg.oldWrapperPath = ""
- }
- }
}
func (ctx *testContext) newCommand(path string, args ...string) *command {
@@ -325,12 +291,3 @@ func newExitCodeError(exitCode int) error {
tmpCmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("exit %d", exitCode))
return tmpCmd.Run()
}
-
-func isCompareToOldWrapperCmd(cmd *command) bool {
- for _, arg := range cmd.Args {
- if strings.Contains(arg, compareToOldWrapperFilePattern) {
- return true
- }
- }
- return false
-}
diff --git a/cros_utils/device_setup_utils.py b/cros_utils/device_setup_utils.py
new file mode 100755
index 00000000..93e681bd
--- /dev/null
+++ b/cros_utils/device_setup_utils.py
@@ -0,0 +1,458 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+#
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utils for setting devices
+
+This script provides utils to set device specs.
+"""
+
+from __future__ import division
+from __future__ import print_function
+
+__author__ = 'zhizhouy@google.com (Zhizhou Yang)'
+
+import re
+import time
+
+from cros_utils import command_executer
+
+
+class DutWrapper(object):
+ """Wrap DUT parameters inside.
+
+ Eventially CommandExecuter will reqiure only one
+ argument - command.
+ """
+
+ def __init__(self,
+ chromeos_root,
+ remote,
+ log_level='verbose',
+ logger=None,
+ ce=None,
+ dut_config=None):
+ self.chromeos_root = chromeos_root
+ self.remote = remote
+ self.log_level = log_level
+ self.logger = logger
+ self.ce = ce or command_executer.GetCommandExecuter(log_level=log_level)
+ self.dut_config = dut_config
+
+ def RunCommandOnDut(self, command, ignore_status=False):
+ ret, msg, err_msg = self.ce.CrosRunCommandWOutput(
+ command, machine=self.remote, chromeos_root=self.chromeos_root)
+
+ if ret:
+ err_msg = ('Command execution on DUT %s failed.\n'
+ 'Failing command: %s\n'
+ 'returned %d\n'
+ 'Error message: %s' % (self.remote, command, ret, err_msg))
+ if ignore_status:
+ self.logger.LogError(err_msg +
+ '\n(Failure is considered non-fatal. Continue.)')
+ else:
+ self.logger.LogFatal(err_msg)
+
+ return ret, msg, err_msg
+
+ def DisableASLR(self):
+ disable_aslr = ('set -e; '
+ 'if [[ -e /proc/sys/kernel/randomize_va_space ]]; then '
+ ' echo 0 > /proc/sys/kernel/randomize_va_space; '
+ 'fi')
+ if self.log_level == 'average':
+ self.logger.LogOutput('Disable ASLR.')
+ self.RunCommandOnDut(disable_aslr, ignore_status=False)
+
+ def SetCpuGovernor(self, governor, ignore_status=False):
+ set_gov_cmd = (
+ 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
+ # Skip writing scaling_governor if cpu is offline.
+ ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
+ ' && continue; '
+ ' cd $f; '
+ ' if [[ -e scaling_governor ]]; then '
+ ' echo %s > scaling_governor; fi; '
+ 'done; ')
+ if self.log_level == 'average':
+ self.logger.LogOutput('Setup CPU Governor: %s.' % governor)
+ ret, _, _ = self.RunCommandOnDut(
+ set_gov_cmd % governor, ignore_status=ignore_status)
+ return ret
+
+ def DisableTurbo(self):
+ dis_turbo_cmd = (
+ 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then '
+ ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then '
+ ' echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo; '
+ ' fi; '
+ 'fi; ')
+ if self.log_level == 'average':
+ self.logger.LogOutput('Disable Turbo.')
+ self.RunCommandOnDut(dis_turbo_cmd)
+
+ def SetupCpuUsage(self):
+ """Setup CPU usage.
+
+ Based on self.dut_config['cpu_usage'] configure CPU cores
+ utilization.
+ """
+
+ if (self.dut_config['cpu_usage'] == 'big_only' or
+ self.dut_config['cpu_usage'] == 'little_only'):
+ _, arch, _ = self.RunCommandOnDut('uname -m')
+
+ if arch.lower().startswith('arm') or arch.lower().startswith('aarch64'):
+ self.SetupArmCores()
+
+ def SetupArmCores(self):
+ """Setup ARM big/little cores."""
+
+ # CPU implemeters/part numbers of big/LITTLE CPU.
+ # Format: dict(CPU implementer: set(CPU part numbers))
+ LITTLE_CORES = {
+ '0x41': {
+ '0xd01', # Cortex A32
+ '0xd03', # Cortex A53
+ '0xd04', # Cortex A35
+ '0xd05', # Cortex A55
+ },
+ }
+ BIG_CORES = {
+ '0x41': {
+ '0xd07', # Cortex A57
+ '0xd08', # Cortex A72
+ '0xd09', # Cortex A73
+ '0xd0a', # Cortex A75
+ '0xd0b', # Cortex A76
+ },
+ }
+
+ # Values of CPU Implementer and CPU part number are exposed by cpuinfo.
+ # Format:
+ # =================
+ # processor : 0
+ # model name : ARMv8 Processor rev 4 (v8l)
+ # BogoMIPS : 48.00
+ # Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
+ # CPU implementer : 0x41
+ # CPU architecture: 8
+ # CPU variant : 0x0
+ # CPU part : 0xd03
+ # CPU revision : 4
+
+ _, cpuinfo, _ = self.RunCommandOnDut('cat /proc/cpuinfo')
+
+ # List of all CPU cores: 0, 1, ..
+ proc_matches = re.findall(r'^processor\s*: (\d+)$', cpuinfo, re.MULTILINE)
+ # List of all corresponding CPU implementers
+ impl_matches = re.findall(r'^CPU implementer\s*: (0x[\da-f]+)$', cpuinfo,
+ re.MULTILINE)
+ # List of all corresponding CPU part numbers
+ part_matches = re.findall(r'^CPU part\s*: (0x[\da-f]+)$', cpuinfo,
+ re.MULTILINE)
+ assert len(proc_matches) == len(impl_matches)
+ assert len(part_matches) == len(impl_matches)
+
+ all_cores = set(proc_matches)
+ dut_big_cores = {
+ core
+ for core, impl, part in zip(proc_matches, impl_matches, part_matches)
+ if impl in BIG_CORES and part in BIG_CORES[impl]
+ }
+ dut_lit_cores = {
+ core
+ for core, impl, part in zip(proc_matches, impl_matches, part_matches)
+ if impl in LITTLE_CORES and part in LITTLE_CORES[impl]
+ }
+
+ if self.dut_config['cpu_usage'] == 'big_only':
+ cores_to_enable = dut_big_cores
+ cores_to_disable = all_cores - dut_big_cores
+ elif self.dut_config['cpu_usage'] == 'little_only':
+ cores_to_enable = dut_lit_cores
+ cores_to_disable = all_cores - dut_lit_cores
+ else:
+ self.logger.LogError(
+ 'cpu_usage=%s is not supported on ARM.\n'
+ 'Ignore ARM CPU setup and continue.' % self.dut_config['cpu_usage'])
+ return
+
+ if cores_to_enable:
+ cmd_enable_cores = ('echo 1 | tee /sys/devices/system/cpu/cpu{%s}/online'
+ % ','.join(sorted(cores_to_enable)))
+
+ cmd_disable_cores = ''
+ if cores_to_disable:
+ cmd_disable_cores = (
+ 'echo 0 | tee /sys/devices/system/cpu/cpu{%s}/online' % ','.join(
+ sorted(cores_to_disable)))
+
+ self.RunCommandOnDut('; '.join([cmd_enable_cores, cmd_disable_cores]))
+ else:
+ # If there are no cores enabled by dut_config then configuration
+ # is invalid for current platform and should be ignored.
+ self.logger.LogError(
+ '"cpu_usage" is invalid for targeted platform.\n'
+ 'dut_config[cpu_usage]=%s\n'
+ 'dut big cores: %s\n'
+ 'dut little cores: %s\n'
+ 'Ignore ARM CPU setup and continue.' % (self.dut_config['cpu_usage'],
+ dut_big_cores, dut_lit_cores))
+
+ def GetCpuOnline(self):
+ """Get online status of CPU cores.
+
+ Return dict of {int(cpu_num): <0|1>}.
+ """
+ get_cpu_online_cmd = ('paste -d" "'
+ ' <(ls /sys/devices/system/cpu/cpu*/online)'
+ ' <(cat /sys/devices/system/cpu/cpu*/online)')
+ _, online_output_str, _ = self.RunCommandOnDut(get_cpu_online_cmd)
+
+ # Here is the output we expect to see:
+ # -----------------
+ # /sys/devices/system/cpu/cpu0/online 0
+ # /sys/devices/system/cpu/cpu1/online 1
+
+ cpu_online = {}
+ cpu_online_match = re.compile(r'^[/\S]+/cpu(\d+)/[/\S]+\s+(\d+)$')
+ for line in online_output_str.splitlines():
+ match = cpu_online_match.match(line)
+ if match:
+ cpu = int(match.group(1))
+ status = int(match.group(2))
+ cpu_online[cpu] = status
+ # At least one CPU has to be online.
+ assert cpu_online
+
+ return cpu_online
+
+ def SetupCpuFreq(self, online_cores):
+ """Setup CPU frequency.
+
+ Based on self.dut_config['cpu_freq_pct'] setup frequency of online CPU cores
+ to a supported value which is less or equal to (freq_pct * max_freq / 100)
+ limited by min_freq.
+
+ NOTE: scaling_available_frequencies support is required.
+ Otherwise the function has no effect.
+ """
+ freq_percent = self.dut_config['cpu_freq_pct']
+ list_all_avail_freq_cmd = ('ls /sys/devices/system/cpu/cpu{%s}/cpufreq/'
+ 'scaling_available_frequencies')
+ # Ignore error to support general usage of frequency setup.
+ # Not all platforms support scaling_available_frequencies.
+ ret, all_avail_freq_str, _ = self.RunCommandOnDut(
+ list_all_avail_freq_cmd % ','.join(str(core) for core in online_cores),
+ ignore_status=True)
+ if ret or not all_avail_freq_str:
+ # No scalable frequencies available for the core.
+ return ret
+ for avail_freq_path in all_avail_freq_str.split():
+ # Get available freq from every scaling_available_frequency path.
+ # Error is considered fatal in self.RunCommandOnDut().
+ _, avail_freq_str, _ = self.RunCommandOnDut('cat ' + avail_freq_path)
+ assert avail_freq_str
+
+ all_avail_freq = sorted(
+ int(freq_str) for freq_str in avail_freq_str.split())
+ min_freq = all_avail_freq[0]
+ max_freq = all_avail_freq[-1]
+ # Calculate the frequency we are targeting.
+ target_freq = round(max_freq * freq_percent / 100)
+ # More likely it's not in the list of supported frequencies
+ # and our goal is to find the one which is less or equal.
+ # Default is min and we will try to maximize it.
+ avail_ngt_target = min_freq
+ # Find the largest not greater than the target.
+ for next_largest in reversed(all_avail_freq):
+ if next_largest <= target_freq:
+ avail_ngt_target = next_largest
+ break
+
+ max_freq_path = avail_freq_path.replace('scaling_available_frequencies',
+ 'scaling_max_freq')
+ min_freq_path = avail_freq_path.replace('scaling_available_frequencies',
+ 'scaling_min_freq')
+ # With default ignore_status=False we expect 0 status or Fatal error.
+ self.RunCommandOnDut('echo %s | tee %s %s' %
+ (avail_ngt_target, max_freq_path, min_freq_path))
+
+ def WaitCooldown(self):
+ waittime = 0
+ timeout_in_sec = int(self.dut_config['cooldown_time']) * 60
+ # Temperature from sensors come in uCelsius units.
+ temp_in_ucels = int(self.dut_config['cooldown_temp']) * 1000
+ sleep_interval = 30
+
+ # Wait until any of two events occurs:
+ # 1. CPU cools down to a specified temperature.
+ # 2. Timeout cooldown_time expires.
+ # For the case when targeted temperature is not reached within specified
+ # timeout the benchmark is going to start with higher initial CPU temp.
+ # In the worst case it may affect test results but at the same time we
+ # guarantee the upper bound of waiting time.
+ # TODO(denik): Report (or highlight) "high" CPU temperature in test results.
+ # "high" should be calculated based on empirical data per platform.
+ # Based on such reports we can adjust CPU configuration or
+ # cooldown limits accordingly.
+ while waittime < timeout_in_sec:
+ _, temp_output, _ = self.RunCommandOnDut(
+ 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
+ if any(int(temp) > temp_in_ucels for temp in temp_output.split()):
+ time.sleep(sleep_interval)
+ waittime += sleep_interval
+ else:
+ # Exit the loop when:
+ # 1. Reported temp numbers from all thermal sensors do not exceed
+ # 'cooldown_temp' or
+ # 2. No data from the sensors.
+ break
+
+ self.logger.LogOutput('Cooldown wait time: %.1f min' % (waittime / 60))
+ return waittime
+
+ def DecreaseWaitTime(self):
+ """Change the ten seconds wait time for pagecycler to two seconds."""
+ FILE = '/usr/local/telemetry/src/tools/perf/page_sets/page_cycler_story.py'
+ ret = self.RunCommandOnDut('ls ' + FILE)
+
+ if not ret:
+ sed_command = 'sed -i "s/_TTI_WAIT_TIME = 10/_TTI_WAIT_TIME = 2/g" '
+ self.RunCommandOnDut(sed_command + FILE)
+
+ def StopUI(self):
+ # Added "ignore_status" for the case when crosperf stops ui service which
+ # was already stopped. Command is going to fail with 1.
+ self.RunCommandOnDut('stop ui', ignore_status=True)
+
+ def StartUI(self):
+ # Similar to StopUI, `start ui` fails if the service is already started.
+ self.RunCommandOnDut('start ui', ignore_status=True)
+
+ def KerncmdUpdateNeeded(self, intel_pstate):
+ """Check whether kernel cmdline update is needed.
+
+ Args:
+ intel_pstate: kernel command line argument (active, passive, no_hwp)
+
+ Returns:
+ True if update is needed.
+ """
+
+ good = 0
+
+ # Check that dut platform supports hwp
+ cmd = "grep -q '^flags.*hwp' /proc/cpuinfo"
+ ret_code, _, _ = self.RunCommandOnDut(cmd, ignore_status=True)
+ if ret_code != good:
+ # Intel hwp is not supported, update is not needed.
+ return False
+
+ kern_cmdline_cmd = 'grep -q "intel_pstate=%s" /proc/cmdline' % intel_pstate
+ ret_code, _, _ = self.RunCommandOnDut(kern_cmdline_cmd, ignore_status=True)
+ self.logger.LogOutput('grep /proc/cmdline returned %d' % ret_code)
+ if (intel_pstate and ret_code == good or
+ not intel_pstate and ret_code != good):
+ # No need to updated cmdline if:
+ # 1. We are setting intel_pstate and we found it is already set.
+ # 2. Not using intel_pstate and it is not in cmdline.
+ return False
+
+ # Otherwise we need to update intel_pstate.
+ return True
+
+ def UpdateKerncmdIntelPstate(self, intel_pstate):
+ """Update kernel command line.
+
+ Args:
+ intel_pstate: kernel command line argument (active, passive, no_hwp)
+ """
+
+ good = 0
+
+ # First phase is to remove rootfs verification to allow cmdline change.
+ remove_verif_cmd = ' '.join([
+ '/usr/share/vboot/bin/make_dev_ssd.sh',
+ '--remove_rootfs_verification',
+ '--partition %d',
+ ])
+ # Command for partition 2.
+ verif_part2_failed, _, _ = self.RunCommandOnDut(
+ remove_verif_cmd % 2, ignore_status=True)
+ # Command for partition 4
+ # Some machines in the lab use partition 4 to boot from,
+ # so cmdline should be update for both partitions.
+ verif_part4_failed, _, _ = self.RunCommandOnDut(
+ remove_verif_cmd % 4, ignore_status=True)
+ if verif_part2_failed or verif_part4_failed:
+ self.logger.LogFatal(
+ 'ERROR. Failed to update kernel cmdline on partition %d.\n'
+ 'Remove verification failed with status %d' %
+ (2 if verif_part2_failed else 4, verif_part2_failed or
+ verif_part4_failed))
+
+ self.RunCommandOnDut('reboot && exit')
+ # Give enough time for dut to complete reboot
+ # TODO(denik): Replace with the function checking machine availability.
+ time.sleep(30)
+
+ # Second phase to update intel_pstate in kernel cmdline.
+ kern_cmdline = '\n'.join([
+ 'tmpfile=$(mktemp)',
+ 'partnumb=%d',
+ 'pstate=%s',
+ # Store kernel cmdline in a temp file.
+ '/usr/share/vboot/bin/make_dev_ssd.sh --partition ${partnumb}'
+ ' --save_config ${tmpfile}',
+ # Remove intel_pstate argument if present.
+ "sed -i -r 's/ intel_pstate=[A-Za-z_]+//g' ${tmpfile}.${partnumb}",
+ # Insert intel_pstate with a new value if it is set.
+ '[[ -n ${pstate} ]] &&'
+ ' sed -i -e \"s/ *$/ intel_pstate=${pstate}/\" ${tmpfile}.${partnumb}',
+ # Save the change in kernel cmdline.
+ # After completion we have to reboot.
+ '/usr/share/vboot/bin/make_dev_ssd.sh --partition ${partnumb}'
+ ' --set_config ${tmpfile}'
+ ])
+ kern_part2_cmdline_cmd = kern_cmdline % (2, intel_pstate)
+ self.logger.LogOutput(
+ 'Command to change kernel command line: %s' % kern_part2_cmdline_cmd)
+ upd_part2_failed, _, _ = self.RunCommandOnDut(
+ kern_part2_cmdline_cmd, ignore_status=True)
+ # Again here we are updating cmdline for partition 4
+ # in addition to partition 2. Without this some machines
+ # in the lab might fail.
+ kern_part4_cmdline_cmd = kern_cmdline % (4, intel_pstate)
+ self.logger.LogOutput(
+ 'Command to change kernel command line: %s' % kern_part4_cmdline_cmd)
+ upd_part4_failed, _, _ = self.RunCommandOnDut(
+ kern_part4_cmdline_cmd, ignore_status=True)
+ if upd_part2_failed or upd_part4_failed:
+ self.logger.LogFatal(
+ 'ERROR. Failed to update kernel cmdline on partition %d.\n'
+ 'intel_pstate update failed with status %d' %
+ (2 if upd_part2_failed else 4, upd_part2_failed or upd_part4_failed))
+
+ self.RunCommandOnDut('reboot && exit')
+ # Wait 30s after reboot.
+ time.sleep(30)
+
+ # Verification phase.
+ # Check that cmdline was updated.
+ # Throw an exception if not.
+ kern_cmdline_cmd = 'grep -q "intel_pstate=%s" /proc/cmdline' % intel_pstate
+ ret_code, _, _ = self.RunCommandOnDut(kern_cmdline_cmd, ignore_status=True)
+ if (intel_pstate and ret_code != good or
+ not intel_pstate and ret_code == good):
+ # Kernel cmdline doesn't match input intel_pstate.
+ self.logger.LogFatal(
+ 'ERROR. Failed to update kernel cmdline. '
+ 'Final verification failed with status %d' % ret_code)
+
+ self.logger.LogOutput('Kernel cmdline updated successfully.')
diff --git a/cros_utils/device_setup_utils_unittest.py b/cros_utils/device_setup_utils_unittest.py
new file mode 100755
index 00000000..b2f76f7d
--- /dev/null
+++ b/cros_utils/device_setup_utils_unittest.py
@@ -0,0 +1,620 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+#
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Unittest for device_setup_utils."""
+
+from __future__ import print_function
+
+import time
+
+import unittest
+import mock
+
+from device_setup_utils import DutWrapper
+
+from cros_utils import command_executer
+from cros_utils import logger
+
+BIG_LITTLE_CPUINFO = """processor : 0
+model name : ARMv8 Processor rev 4 (v8l)
+BogoMIPS : 48.00
+Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 8
+CPU variant : 0x0
+CPU part : 0xd03
+CPU revision : 4
+
+processor : 1
+model name : ARMv8 Processor rev 4 (v8l)
+BogoMIPS : 48.00
+Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 8
+CPU variant : 0x0
+CPU part : 0xd03
+CPU revision : 4
+
+processor : 2
+model name : ARMv8 Processor rev 2 (v8l)
+BogoMIPS : 48.00
+Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 8
+CPU variant : 0x0
+CPU part : 0xd08
+CPU revision : 2
+"""
+LITTLE_ONLY_CPUINFO = """processor : 0
+model name : ARMv8 Processor rev 4 (v8l)
+BogoMIPS : 48.00
+Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 8
+CPU variant : 0x0
+CPU part : 0xd03
+CPU revision : 4
+
+processor : 1
+model name : ARMv8 Processor rev 4 (v8l)
+BogoMIPS : 48.00
+Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 8
+CPU variant : 0x0
+CPU part : 0xd03
+CPU revision : 4
+"""
+
+NOT_BIG_LITTLE_CPUINFO = """processor : 0
+model name : ARMv7 Processor rev 1 (v7l)
+Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant : 0x0
+CPU part : 0xc0d
+CPU revision : 1
+
+processor : 1
+model name : ARMv7 Processor rev 1 (v7l)
+Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant : 0x0
+CPU part : 0xc0d
+CPU revision : 1
+
+Hardware : Rockchip (Device Tree)
+Revision : 0000
+Serial : 0000000000000000
+"""
+
+
+class DutWrapperTest(unittest.TestCase):
+ """Class of DutWrapper test."""
+ real_logger = logger.GetLogger()
+
+ mock_cmd_exec = mock.Mock(spec=command_executer.CommandExecuter)
+ mock_logger = mock.Mock(spec=logger.Logger)
+
+ def __init__(self, *args, **kwargs):
+ super(DutWrapperTest, self).__init__(*args, **kwargs)
+
+ def setUp(self):
+ self.dw = DutWrapper(
+ '/tmp/chromeos',
+ 'lumpy.cros2',
+ log_level='verbose',
+ logger=self.mock_logger,
+ ce=self.mock_cmd_exec,
+ dut_config={})
+
+ @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
+ def test_run_command_on_dut(self, mock_cros_runcmd):
+ self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
+ mock_cros_runcmd.return_value = (0, '', '')
+ mock_cros_runcmd.assert_not_called()
+ self.dw.RunCommandOnDut('run command;')
+ mock_cros_runcmd.assert_called_once_with(
+ 'run command;', chromeos_root='/tmp/chromeos', machine='lumpy.cros2')
+
+ @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
+ def test_dut_wrapper_fatal_error(self, mock_cros_runcmd):
+ self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
+ # Command returns error 1.
+ mock_cros_runcmd.return_value = (1, '', 'Error!')
+ mock_cros_runcmd.assert_not_called()
+ self.dw.RunCommandOnDut('run command;')
+ mock_cros_runcmd.assert_called_once_with(
+ 'run command;', chromeos_root='/tmp/chromeos', machine='lumpy.cros2')
+ # Error status causes log fatal.
+ self.assertEqual(
+ self.mock_logger.method_calls[-1],
+ mock.call.LogFatal('Command execution on DUT lumpy.cros2 failed.\n'
+ 'Failing command: run command;\nreturned 1\n'
+ 'Error message: Error!'))
+
+ @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
+ def test_dut_wrapper_ignore_error(self, mock_cros_runcmd):
+ self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
+ # Command returns error 1.
+ mock_cros_runcmd.return_value = (1, '', 'Error!')
+ self.dw.RunCommandOnDut('run command;', ignore_status=True)
+ mock_cros_runcmd.assert_called_once_with(
+ 'run command;', chromeos_root='/tmp/chromeos', machine='lumpy.cros2')
+ # Error status is not fatal. LogError records the error message.
+ self.assertEqual(
+ self.mock_logger.method_calls[-1],
+ mock.call.LogError('Command execution on DUT lumpy.cros2 failed.\n'
+ 'Failing command: run command;\nreturned 1\n'
+ 'Error message: Error!\n'
+ '(Failure is considered non-fatal. Continue.)'))
+
+ def test_disable_aslr(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '', ''))
+ self.dw.DisableASLR()
+ # pyformat: disable
+ set_cpu_cmd = ('set -e; '
+ 'if [[ -e /proc/sys/kernel/randomize_va_space ]]; then '
+ ' echo 0 > /proc/sys/kernel/randomize_va_space; '
+ 'fi')
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ set_cpu_cmd, ignore_status=False)
+
+ def test_set_cpu_governor(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '', ''))
+ self.dw.SetCpuGovernor('new_governor', ignore_status=False)
+ set_cpu_cmd = (
+ 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
+ # Skip writing scaling_governor if cpu is offline.
+ ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
+ ' && continue; '
+ ' cd $f; '
+ ' if [[ -e scaling_governor ]]; then '
+ ' echo %s > scaling_governor; fi; '
+ 'done; ')
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ set_cpu_cmd % 'new_governor', ignore_status=False)
+
+ def test_set_cpu_governor_propagate_error(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(1, '', 'Error.'))
+ self.dw.SetCpuGovernor('non-exist_governor')
+ set_cpu_cmd = (
+ 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
+ # Skip writing scaling_governor if cpu is not online.
+ ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
+ ' && continue; '
+ ' cd $f; '
+ ' if [[ -e scaling_governor ]]; then '
+ ' echo %s > scaling_governor; fi; '
+ 'done; ')
+ # By default error status is fatal.
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ set_cpu_cmd % 'non-exist_governor', ignore_status=False)
+
+ def test_set_cpu_governor_ignore_status(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(1, '', 'Error.'))
+ ret_code = self.dw.SetCpuGovernor('non-exist_governor', ignore_status=True)
+ set_cpu_cmd = (
+ 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
+ # Skip writing scaling_governor if cpu is not online.
+ ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
+ ' && continue; '
+ ' cd $f; '
+ ' if [[ -e scaling_governor ]]; then '
+ ' echo %s > scaling_governor; fi; '
+ 'done; ')
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ set_cpu_cmd % 'non-exist_governor', ignore_status=True)
+ self.assertEqual(ret_code, 1)
+
+ def test_disable_turbo(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '', ''))
+ self.dw.DisableTurbo()
+ set_cpu_cmd = (
+ # Disable Turbo in Intel pstate driver
+ 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then '
+ ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then '
+ ' echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo; '
+ ' fi; '
+ 'fi; ')
+ self.dw.RunCommandOnDut.assert_called_once_with(set_cpu_cmd)
+
+ def test_get_cpu_online_two(self):
+ """Test one digit CPU #."""
+ self.dw.RunCommandOnDut = mock.Mock(
+ return_value=(0, '/sys/devices/system/cpu/cpu0/online 0\n'
+ '/sys/devices/system/cpu/cpu1/online 1\n', ''))
+ cpu_online = self.dw.GetCpuOnline()
+ self.assertEqual(cpu_online, {0: 0, 1: 1})
+
+ def test_get_cpu_online_twelve(self):
+ """Test two digit CPU #."""
+ self.dw.RunCommandOnDut = mock.Mock(
+ return_value=(0, '/sys/devices/system/cpu/cpu0/online 1\n'
+ '/sys/devices/system/cpu/cpu1/online 0\n'
+ '/sys/devices/system/cpu/cpu10/online 1\n'
+ '/sys/devices/system/cpu/cpu11/online 1\n'
+ '/sys/devices/system/cpu/cpu2/online 1\n'
+ '/sys/devices/system/cpu/cpu3/online 0\n'
+ '/sys/devices/system/cpu/cpu4/online 1\n'
+ '/sys/devices/system/cpu/cpu5/online 0\n'
+ '/sys/devices/system/cpu/cpu6/online 1\n'
+ '/sys/devices/system/cpu/cpu7/online 0\n'
+ '/sys/devices/system/cpu/cpu8/online 1\n'
+ '/sys/devices/system/cpu/cpu9/online 0\n', ''))
+ cpu_online = self.dw.GetCpuOnline()
+ self.assertEqual(cpu_online, {
+ 0: 1,
+ 1: 0,
+ 2: 1,
+ 3: 0,
+ 4: 1,
+ 5: 0,
+ 6: 1,
+ 7: 0,
+ 8: 1,
+ 9: 0,
+ 10: 1,
+ 11: 1
+ })
+
+ def test_get_cpu_online_no_output(self):
+ """Test error case, no output."""
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '', ''))
+ with self.assertRaises(AssertionError):
+ self.dw.GetCpuOnline()
+
+ def test_get_cpu_online_command_error(self):
+ """Test error case, command error."""
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=AssertionError)
+ with self.assertRaises(AssertionError):
+ self.dw.GetCpuOnline()
+
+ @mock.patch.object(DutWrapper, 'SetupArmCores')
+ def test_setup_cpu_usage_little_on_arm(self, mock_setup_arm):
+ self.dw.SetupArmCores = mock_setup_arm
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, 'armv7l', ''))
+ self.dw.dut_config['cpu_usage'] = 'little_only'
+ self.dw.SetupCpuUsage()
+ self.dw.SetupArmCores.assert_called_once_with()
+
+ @mock.patch.object(DutWrapper, 'SetupArmCores')
+ def test_setup_cpu_usage_big_on_aarch64(self, mock_setup_arm):
+ self.dw.SetupArmCores = mock_setup_arm
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, 'aarch64', ''))
+ self.dw.dut_config['cpu_usage'] = 'big_only'
+ self.dw.SetupCpuUsage()
+ self.dw.SetupArmCores.assert_called_once_with()
+
+ @mock.patch.object(DutWrapper, 'SetupArmCores')
+ def test_setup_cpu_usage_big_on_intel(self, mock_setup_arm):
+ self.dw.SetupArmCores = mock_setup_arm
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, 'x86_64', ''))
+ self.dw.dut_config['cpu_usage'] = 'big_only'
+ self.dw.SetupCpuUsage()
+ # Check that SetupArmCores not called with invalid setup.
+ self.dw.SetupArmCores.assert_not_called()
+
+ @mock.patch.object(DutWrapper, 'SetupArmCores')
+ def test_setup_cpu_usage_all_on_intel(self, mock_setup_arm):
+ self.dw.SetupArmCores = mock_setup_arm
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, 'x86_64', ''))
+ self.dw.dut_config['cpu_usage'] = 'all'
+ self.dw.SetupCpuUsage()
+ # Check that SetupArmCores not called in general case.
+ self.dw.SetupArmCores.assert_not_called()
+
+ def test_setup_arm_cores_big_on_big_little(self):
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0, BIG_LITTLE_CPUINFO, ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_usage'] = 'big_only'
+ self.dw.SetupArmCores()
+ self.dw.RunCommandOnDut.assert_called_with(
+ 'echo 1 | tee /sys/devices/system/cpu/cpu{2}/online; '
+ 'echo 0 | tee /sys/devices/system/cpu/cpu{0,1}/online')
+
+ def test_setup_arm_cores_little_on_big_little(self):
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0, BIG_LITTLE_CPUINFO, ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_usage'] = 'little_only'
+ self.dw.SetupArmCores()
+ self.dw.RunCommandOnDut.assert_called_with(
+ 'echo 1 | tee /sys/devices/system/cpu/cpu{0,1}/online; '
+ 'echo 0 | tee /sys/devices/system/cpu/cpu{2}/online')
+
+ def test_setup_arm_cores_invalid_config(self):
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0, LITTLE_ONLY_CPUINFO, ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_usage'] = 'big_only'
+ self.dw.SetupArmCores()
+ # Check that setup command is not sent when trying
+ # to use 'big_only' on a platform with all little cores.
+ self.dw.RunCommandOnDut.assert_called_once_with('cat /proc/cpuinfo')
+
+ def test_setup_arm_cores_not_big_little(self):
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0, NOT_BIG_LITTLE_CPUINFO, ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_usage'] = 'big_only'
+ self.dw.SetupArmCores()
+ # Check that setup command is not sent when trying
+ # to use 'big_only' on a platform w/o support of big/little.
+ self.dw.RunCommandOnDut.assert_called_once_with('cat /proc/cpuinfo')
+
+ def test_setup_arm_cores_unsupported_cpu_usage(self):
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0, BIG_LITTLE_CPUINFO, ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_usage'] = 'exclusive_cores'
+ self.dw.SetupArmCores()
+ # Check that setup command is not sent when trying to use
+ # 'exclusive_cores' on ARM CPU setup.
+ self.dw.RunCommandOnDut.assert_called_once_with('cat /proc/cpuinfo')
+
+ def test_setup_cpu_freq_single_full(self):
+ online = [0]
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0,
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n',
+ ''),
+ (0, '1 2 3 4 5 6 7 8 9 10', ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_freq_pct'] = 100
+ self.dw.SetupCpuFreq(online)
+ self.assertGreaterEqual(self.dw.RunCommandOnDut.call_count, 3)
+ self.assertEqual(
+ self.dw.RunCommandOnDut.call_args,
+ mock.call('echo 10 | tee '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
+
+ def test_setup_cpu_freq_middle(self):
+ online = [0]
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0,
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n',
+ ''),
+ (0, '1 2 3 4 5 6 7 8 9 10', ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_freq_pct'] = 60
+ self.dw.SetupCpuFreq(online)
+ self.assertGreaterEqual(self.dw.RunCommandOnDut.call_count, 2)
+ self.assertEqual(
+ self.dw.RunCommandOnDut.call_args,
+ mock.call('echo 6 | tee '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
+
+ def test_setup_cpu_freq_lowest(self):
+ online = [0]
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0,
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n',
+ ''),
+ (0, '1 2 3 4 5 6 7 8 9 10', ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_freq_pct'] = 0
+ self.dw.SetupCpuFreq(online)
+ self.assertGreaterEqual(self.dw.RunCommandOnDut.call_count, 2)
+ self.assertEqual(
+ self.dw.RunCommandOnDut.call_args,
+ mock.call('echo 1 | tee '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
+
+ def test_setup_cpu_freq_multiple_middle(self):
+ online = [0, 1]
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0,
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n'
+ '/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n',
+ ''),
+ (0, '1 2 3 4 5 6 7 8 9 10', ''),
+ (0, '', ''),
+ (0, '1 4 6 8 10 12 14 16 18 20', ''),
+ (0, '', ''),
+ ])
+ self.dw.dut_config['cpu_freq_pct'] = 70
+ self.dw.SetupCpuFreq(online)
+ self.assertEqual(self.dw.RunCommandOnDut.call_count, 5)
+ self.assertEqual(
+ self.dw.RunCommandOnDut.call_args_list[2],
+ mock.call('echo 7 | tee '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
+ self.assertEqual(
+ self.dw.RunCommandOnDut.call_args_list[4],
+ mock.call('echo 14 | tee '
+ '/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq '
+ '/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq'))
+
+ def test_setup_cpu_freq_no_scaling_available(self):
+ online = [0, 1]
+ self.dw.RunCommandOnDut = mock.Mock(
+ return_value=(2, '', 'No such file or directory'))
+ self.dw.dut_config['cpu_freq_pct'] = 50
+ self.dw.SetupCpuFreq(online)
+ self.dw.RunCommandOnDut.assert_called_once()
+ self.assertNotRegexpMatches(self.dw.RunCommandOnDut.call_args_list[0][0][0],
+ '^echo.*scaling_max_freq$')
+
+ def test_setup_cpu_freq_multiple_no_access(self):
+ online = [0, 1]
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0,
+ '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n'
+ '/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n',
+ ''),
+ (0, '1 4 6 8 10 12 14 16 18 20', ''),
+ AssertionError(),
+ ])
+ self.dw.dut_config['cpu_freq_pct'] = 30
+ # Error status causes log fatal.
+ with self.assertRaises(AssertionError):
+ self.dw.SetupCpuFreq(online)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_nowait(self, mock_sleep):
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '39000', ''))
+ self.dw.dut_config['cooldown_time'] = 10
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ # Send command to DUT only once to check temperature
+ # and make sure it does not exceed the threshold.
+ self.dw.RunCommandOnDut.assert_called_once()
+ mock_sleep.assert_not_called()
+ self.assertEqual(wait_time, 0)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_needwait_once(self, mock_sleep):
+ """Wait one iteration for cooldown.
+
+ Set large enough timeout and changing temperature
+ output. Make sure it exits when expected value
+ received.
+ Expect that WaitCooldown check temp twice.
+ """
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[(0, '41000',
+ ''), (0, '39999', '')])
+ self.dw.dut_config['cooldown_time'] = 100
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ self.dw.RunCommandOnDut.assert_called()
+ self.assertEqual(self.dw.RunCommandOnDut.call_count, 2)
+ mock_sleep.assert_called()
+ self.assertGreater(wait_time, 0)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_needwait(self, mock_sleep):
+ """Test exit by timeout.
+
+ Send command to DUT checking the temperature and
+ check repeatedly until timeout goes off.
+ Output from temperature sensor never changes.
+ """
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '41000', ''))
+ self.dw.dut_config['cooldown_time'] = 60
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ self.dw.RunCommandOnDut.assert_called()
+ self.assertGreater(self.dw.RunCommandOnDut.call_count, 2)
+ mock_sleep.assert_called()
+ self.assertGreater(wait_time, 0)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_needwait_multtemp(self, mock_sleep):
+ """Wait until all temps go down.
+
+ Set large enough timeout and changing temperature
+ output. Make sure it exits when expected value
+ for all temperatures received.
+ Expect 3 checks.
+ """
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (0, '41000\n20000\n30000\n45000', ''),
+ (0, '39000\n20000\n30000\n41000', ''),
+ (0, '39000\n20000\n30000\n31000', ''),
+ ])
+ self.dw.dut_config['cooldown_time'] = 100
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ self.dw.RunCommandOnDut.assert_called()
+ self.assertEqual(self.dw.RunCommandOnDut.call_count, 3)
+ mock_sleep.assert_called()
+ self.assertGreater(wait_time, 0)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_thermal_error(self, mock_sleep):
+ """Handle error status.
+
+ Any error should be considered non-fatal.
+ """
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[
+ (1, '39000\n20000\n30000\n41000', 'Thermal error'),
+ (1, '39000\n20000\n30000\n31000', 'Thermal error'),
+ ])
+ self.dw.dut_config['cooldown_time'] = 10
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ # Check that errors are ignored.
+ self.dw.RunCommandOnDut.assert_called_with(
+ 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
+ self.assertEqual(self.dw.RunCommandOnDut.call_count, 2)
+ # Check that we are waiting even when an error is returned
+ # as soon as data is coming.
+ mock_sleep.assert_called()
+ self.assertGreater(wait_time, 0)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_thermal_no_output(self, mock_sleep):
+ """Handle no output.
+
+ Check handling of empty stdout.
+ """
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[(1, '', 'Thermal error')])
+ self.dw.dut_config['cooldown_time'] = 10
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ # Check that errors are ignored.
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
+ # No wait.
+ mock_sleep.assert_not_called()
+ self.assertEqual(wait_time, 0)
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_cooldown_thermal_ws_output(self, mock_sleep):
+ """Handle whitespace output.
+
+ Check handling of whitespace only.
+ """
+ mock_sleep.return_value = 0
+ self.dw.RunCommandOnDut = mock.Mock(side_effect=[(1, '\n',
+ 'Thermal error')])
+ self.dw.dut_config['cooldown_time'] = 10
+ self.dw.dut_config['cooldown_temp'] = 40
+ wait_time = self.dw.WaitCooldown()
+ # Check that errors are ignored.
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
+ # No wait.
+ mock_sleep.assert_not_called()
+ self.assertEqual(wait_time, 0)
+
+ def test_stop_ui(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '', ''))
+ self.dw.StopUI()
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ 'stop ui', ignore_status=True)
+
+ def test_start_ui(self):
+ self.dw.RunCommandOnDut = mock.Mock(return_value=(0, '', ''))
+ self.dw.StartUI()
+ self.dw.RunCommandOnDut.assert_called_once_with(
+ 'start ui', ignore_status=True)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/crosperf/benchmark.py b/crosperf/benchmark.py
index 5c11e27e..0413b593 100644
--- a/crosperf/benchmark.py
+++ b/crosperf/benchmark.py
@@ -9,8 +9,8 @@ from __future__ import division
from __future__ import print_function
import math
-#FIXME(denik): Fix the import in chroot.
-#pylint: disable=import-error
+# FIXME(denik): Fix the import in chroot.
+# pylint: disable=import-error
from scipy import stats
# See crbug.com/673558 for how these are estimated.
@@ -65,12 +65,11 @@ class Benchmark(object):
retries=0,
run_local=False,
cwp_dso='',
- weight=0,
- turbostat=True):
+ weight=0):
self.name = name
- #For telemetry, this is the benchmark name.
+ # For telemetry, this is the benchmark name.
self.test_name = test_name
- #For telemetry, this is the data.
+ # For telemetry, this is the data.
self.test_args = test_args
self.iterations = iterations if iterations > 0 else _samples(name)
self.perf_args = perf_args
@@ -86,4 +85,3 @@ class Benchmark(object):
self.run_local = run_local
self.cwp_dso = cwp_dso
self.weight = weight
- self.turbostat = turbostat
diff --git a/crosperf/benchmark_run.py b/crosperf/benchmark_run.py
index 6512b8ea..f17de1be 100644
--- a/crosperf/benchmark_run.py
+++ b/crosperf/benchmark_run.py
@@ -31,18 +31,9 @@ STATUS_PENDING = 'PENDING'
class BenchmarkRun(threading.Thread):
"""The benchmarkrun class."""
- def __init__(self,
- name,
- benchmark,
- label,
- iteration,
- cache_conditions,
- machine_manager,
- logger_to_use,
- log_level,
- share_cache,
- dut_config,
- enable_aslr=False):
+ def __init__(self, name, benchmark, label, iteration, cache_conditions,
+ machine_manager, logger_to_use, log_level, share_cache,
+ dut_config):
threading.Thread.__init__(self)
self.name = name
self._logger = logger_to_use
@@ -55,8 +46,7 @@ class BenchmarkRun(threading.Thread):
self.retval = None
self.run_completed = False
self.machine_manager = machine_manager
- self.suite_runner = SuiteRunner(
- dut_config, self._logger, self.log_level, enable_aslr=enable_aslr)
+ self.suite_runner = SuiteRunner(dut_config, self._logger, self.log_level)
self.machine = None
self.cache_conditions = cache_conditions
self.runs_complete = 0
@@ -118,7 +108,6 @@ class BenchmarkRun(threading.Thread):
self.machine = self.AcquireMachine()
self.cache.machine = self.machine
self.result = self.RunTest(self.machine)
- # TODO(denik): Add Top5 report into html.
self.cache.remote = self.machine.name
self.label.chrome_version = self.machine_manager.GetChromeVersion(
@@ -220,9 +209,8 @@ class BenchmarkRun(threading.Thread):
else:
self.machine_manager.ImageMachine(machine, self.label)
self.timeline.Record(STATUS_RUNNING)
- retval, out, err = self.suite_runner.Run(machine.name, self.label,
- self.benchmark, self.test_args,
- self.profiler_args)
+ retval, out, err = self.suite_runner.Run(
+ machine, self.label, self.benchmark, self.test_args, self.profiler_args)
self.run_completed = True
return Result.CreateFromRun(self._logger, self.log_level, self.label,
self.machine, out, err, retval,
@@ -270,9 +258,8 @@ class MockBenchmarkRun(BenchmarkRun):
self.timeline.Record(STATUS_IMAGING)
self.machine_manager.ImageMachine(machine, self.label)
self.timeline.Record(STATUS_RUNNING)
- [retval, out,
- err] = self.suite_runner.Run(machine.name, self.label, self.benchmark,
- self.test_args, self.profiler_args)
+ [retval, out, err] = self.suite_runner.Run(
+ machine, self.label, self.benchmark, self.test_args, self.profiler_args)
self.run_completed = True
rr = MockResult('logger', self.label, self.log_level, machine)
rr.out = out
diff --git a/crosperf/benchmark_run_unittest.py b/crosperf/benchmark_run_unittest.py
index 51b287cf..5696c107 100755
--- a/crosperf/benchmark_run_unittest.py
+++ b/crosperf/benchmark_run_unittest.py
@@ -119,7 +119,7 @@ class BenchmarkRunTest(unittest.TestCase):
args_list = [
'self', 'name', 'benchmark', 'label', 'iteration', 'cache_conditions',
'machine_manager', 'logger_to_use', 'log_level', 'share_cache',
- 'dut_config', 'enable_aslr'
+ 'dut_config'
]
arg_spec = inspect.getargspec(benchmark_run.BenchmarkRun.__init__)
self.assertEqual(len(arg_spec.args), len(args_list))
@@ -410,8 +410,8 @@ class BenchmarkRunTest(unittest.TestCase):
br.machine_manager.ImageMachine.assert_called_with(mock_machine,
self.test_label)
self.assertEqual(mock_runner.call_count, 1)
- mock_runner.assert_called_with(mock_machine.name, br.label, br.benchmark,
- '', br.profiler_args)
+ mock_runner.assert_called_with(mock_machine, br.label, br.benchmark, '',
+ br.profiler_args)
self.assertEqual(mock_result.call_count, 1)
mock_result.assert_called_with(
diff --git a/crosperf/benchmark_unittest.py b/crosperf/benchmark_unittest.py
index 6c0c22f6..63c0a1c0 100755
--- a/crosperf/benchmark_unittest.py
+++ b/crosperf/benchmark_unittest.py
@@ -60,7 +60,7 @@ class BenchmarkTestCase(unittest.TestCase):
args_list = [
'self', 'name', 'test_name', 'test_args', 'iterations', 'rm_chroot_tmp',
'perf_args', 'suite', 'show_all_results', 'retries', 'run_local',
- 'cwp_dso', 'weight', 'turbostat'
+ 'cwp_dso', 'weight'
]
arg_spec = inspect.getargspec(Benchmark.__init__)
self.assertEqual(len(arg_spec.args), len(args_list))
diff --git a/crosperf/crosperf_unittest.py b/crosperf/crosperf_unittest.py
index 4f40d139..f7ffa1b7 100755
--- a/crosperf/crosperf_unittest.py
+++ b/crosperf/crosperf_unittest.py
@@ -25,6 +25,7 @@ import experiment_file
EXPERIMENT_FILE_1 = """
board: x86-alex
remote: chromeos-alex3
+ locks_dir: /tmp
perf_args: record -a -e cycles
benchmark: PageCycler {
iterations: 3
@@ -69,7 +70,7 @@ class CrosperfTest(unittest.TestCase):
settings = crosperf.ConvertOptionsToSettings(options)
self.assertIsNotNone(settings)
self.assertIsInstance(settings, settings_factory.GlobalSettings)
- self.assertEqual(len(settings.fields), 37)
+ self.assertEqual(len(settings.fields), 38)
self.assertTrue(settings.GetField('rerun'))
argv = ['crosperf/crosperf.py', 'temp.exp']
options, _ = parser.parse_known_args(argv)
diff --git a/crosperf/default-telemetry-results.json b/crosperf/default-telemetry-results.json
index b5ea45a6..c4fe0d44 100644
--- a/crosperf/default-telemetry-results.json
+++ b/crosperf/default-telemetry-results.json
@@ -163,9 +163,11 @@
"Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin4_avg"
],
"rendering.desktop@@aquarium$": [
- "avg_surface_fps"
+ "avg_surface_fps",
+ "exp_avg_surface_fps"
],
"rendering.desktop@@aquarium_20k$": [
- "avg_surface_fps"
+ "avg_surface_fps",
+ "exp_avg_surface_fps"
]
}
diff --git a/crosperf/download_images.py b/crosperf/download_images.py
index e02c5817..f855cb60 100644
--- a/crosperf/download_images.py
+++ b/crosperf/download_images.py
@@ -293,7 +293,7 @@ class ImageDownloader(object):
return debug_rel_path
def Run(self, chromeos_root, xbuddy_label, autotest_path, debug_path,
- perf_args):
+ download_debug):
build_id = self.GetBuildID(chromeos_root, xbuddy_label)
image_name = ('gs://chromeos-image-archive/%s/chromiumos_test_image.tar.xz'
% build_id)
@@ -317,7 +317,7 @@ class ImageDownloader(object):
if autotest_path == '':
autotest_path = self.DownloadAutotestFiles(chromeos_root, build_id)
- if debug_path == '' and perf_args:
+ if debug_path == '' and download_debug:
debug_path = self.DownloadDebugFile(chromeos_root, build_id)
return image_path, autotest_path, debug_path
diff --git a/crosperf/download_images_unittest.py b/crosperf/download_images_unittest.py
index 68a84676..dd83c3fa 100755
--- a/crosperf/download_images_unittest.py
+++ b/crosperf/download_images_unittest.py
@@ -167,7 +167,7 @@ class ImageDownloaderTestcast(unittest.TestCase):
test_empty_debug_path = ''
test_autotest_path = '/tmp/autotest'
test_debug_path = '/tmp/debug'
- perf_args = '-a'
+ download_debug = True
# Set values to test/check.
self.called_download_image = False
@@ -224,7 +224,7 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Call Run.
image_path, autotest_path, debug_path = downloader.Run(
test_chroot, test_build_id, test_empty_autotest_path,
- test_empty_debug_path, perf_args)
+ test_empty_debug_path, download_debug)
# Make sure it called both _DownloadImage and _UncompressImage
self.assertTrue(self.called_download_image)
@@ -244,7 +244,7 @@ class ImageDownloaderTestcast(unittest.TestCase):
image_path, autotest_path, debug_path = downloader.Run(
test_chroot, test_build_id, test_autotest_path, test_debug_path,
- perf_args)
+ download_debug)
# Verify that downloadAutotestFiles was not called
self.assertFalse(self.called_download_autotest_files)
@@ -263,7 +263,7 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Call Run again.
self.assertRaises(download_images.MissingImage, downloader.Run, test_chroot,
test_autotest_path, test_debug_path, test_build_id,
- perf_args)
+ download_debug)
# Verify that UncompressImage and downloadAutotestFiles were not called,
# since _DownloadImage "failed"
diff --git a/crosperf/experiment.py b/crosperf/experiment.py
index 1d87b6e4..d6d9ee4c 100644
--- a/crosperf/experiment.py
+++ b/crosperf/experiment.py
@@ -28,8 +28,8 @@ class Experiment(object):
def __init__(self, name, remote, working_directory, chromeos_root,
cache_conditions, labels, benchmarks, experiment_file, email_to,
acquire_timeout, log_dir, log_level, share_cache,
- results_directory, locks_directory, cwp_dso, enable_aslr,
- ignore_min_max, skylab, dut_config):
+ results_directory, locks_directory, cwp_dso, ignore_min_max,
+ skylab, dut_config):
self.name = name
self.working_directory = working_directory
self.remote = remote
@@ -54,7 +54,6 @@ class Experiment(object):
self.locked_machines = []
self.lock_mgr = None
self.cwp_dso = cwp_dso
- self.enable_aslr = enable_aslr
self.ignore_min_max = ignore_min_max
self.skylab = skylab
self.l = logger.GetLogger(log_dir)
@@ -124,11 +123,10 @@ class Experiment(object):
logger_to_use = logger.Logger(self.log_dir, 'run.%s' % (full_name),
True)
benchmark_runs.append(
- benchmark_run.BenchmarkRun(benchmark_run_name, benchmark, label,
- iteration, self.cache_conditions,
- self.machine_manager, logger_to_use,
- self.log_level, self.share_cache,
- dut_config, self.enable_aslr))
+ benchmark_run.BenchmarkRun(
+ benchmark_run_name, benchmark, label, iteration,
+ self.cache_conditions, self.machine_manager, logger_to_use,
+ self.log_level, self.share_cache, dut_config))
return benchmark_runs
diff --git a/crosperf/experiment_factory.py b/crosperf/experiment_factory.py
index 5b4d4b0d..7d1689cc 100644
--- a/crosperf/experiment_factory.py
+++ b/crosperf/experiment_factory.py
@@ -70,7 +70,7 @@ telemetry_crosbolt_perf_tests = [
'speedometer2',
'jetstream',
'loading.desktop',
- #'rendering.desktop',
+ # 'rendering.desktop',
]
crosbolt_perf_tests = [
@@ -82,7 +82,7 @@ crosbolt_perf_tests = [
# 'cheets_PerfBootServer',
# 'cheets_CandyCrushTest',
# 'cheets_LinpackTest',
-#]
+# ]
dso_list = [
'all',
@@ -101,14 +101,12 @@ class ExperimentFactory(object):
def AppendBenchmarkSet(self, benchmarks, benchmark_list, test_args,
iterations, rm_chroot_tmp, perf_args, suite,
- show_all_results, retries, run_local, cwp_dso, weight,
- turbostat):
+ show_all_results, retries, run_local, cwp_dso, weight):
"""Add all the tests in a set to the benchmarks list."""
for test_name in benchmark_list:
- telemetry_benchmark = Benchmark(test_name, test_name, test_args,
- iterations, rm_chroot_tmp, perf_args,
- suite, show_all_results, retries,
- run_local, cwp_dso, weight, turbostat)
+ telemetry_benchmark = Benchmark(
+ test_name, test_name, test_args, iterations, rm_chroot_tmp, perf_args,
+ suite, show_all_results, retries, run_local, cwp_dso, weight)
benchmarks.append(telemetry_benchmark)
def GetExperiment(self, experiment_file, working_directory, log_dir):
@@ -137,6 +135,10 @@ class ExperimentFactory(object):
remote = new_remote
rm_chroot_tmp = global_settings.GetField('rm_chroot_tmp')
perf_args = global_settings.GetField('perf_args')
+ download_debug = global_settings.GetField('download_debug')
+ # Do not download debug symbols when perf_args is not specified.
+ if not perf_args and download_debug:
+ download_debug = False
acquire_timeout = global_settings.GetField('acquire_timeout')
cache_dir = global_settings.GetField('cache_dir')
cache_only = global_settings.GetField('cache_only')
@@ -162,16 +164,16 @@ class ExperimentFactory(object):
cwp_dso = global_settings.GetField('cwp_dso')
if cwp_dso and not cwp_dso in dso_list:
raise RuntimeError('The DSO specified is not supported')
- enable_aslr = global_settings.GetField('enable_aslr')
ignore_min_max = global_settings.GetField('ignore_min_max')
- turbostat_opt = global_settings.GetField('turbostat')
dut_config = {
+ 'enable_aslr': global_settings.GetField('enable_aslr'),
'intel_pstate': global_settings.GetField('intel_pstate'),
'cooldown_time': global_settings.GetField('cooldown_time'),
'cooldown_temp': global_settings.GetField('cooldown_temp'),
'governor': global_settings.GetField('governor'),
'cpu_usage': global_settings.GetField('cpu_usage'),
'cpu_freq_pct': global_settings.GetField('cpu_freq_pct'),
+ 'turbostat': global_settings.GetField('turbostat'),
'top_interval': global_settings.GetField('top_interval'),
}
@@ -253,50 +255,20 @@ class ExperimentFactory(object):
if suite == 'telemetry_Crosperf':
if test_name == 'all_perfv2':
- self.AppendBenchmarkSet(
- benchmarks,
- telemetry_perfv2_tests,
- test_args,
- iterations,
- rm_chroot_tmp,
- perf_args,
- suite,
- show_all_results,
- retries,
- run_local,
- cwp_dso,
- weight,
- turbostat=turbostat_opt)
+ self.AppendBenchmarkSet(benchmarks, telemetry_perfv2_tests, test_args,
+ iterations, rm_chroot_tmp, perf_args, suite,
+ show_all_results, retries, run_local, cwp_dso,
+ weight)
elif test_name == 'all_pagecyclers':
- self.AppendBenchmarkSet(
- benchmarks,
- telemetry_pagecycler_tests,
- test_args,
- iterations,
- rm_chroot_tmp,
- perf_args,
- suite,
- show_all_results,
- retries,
- run_local,
- cwp_dso,
- weight,
- turbostat=turbostat_opt)
+ self.AppendBenchmarkSet(benchmarks, telemetry_pagecycler_tests,
+ test_args, iterations, rm_chroot_tmp,
+ perf_args, suite, show_all_results, retries,
+ run_local, cwp_dso, weight)
elif test_name == 'all_crosbolt_perf':
self.AppendBenchmarkSet(
- benchmarks,
- telemetry_crosbolt_perf_tests,
- test_args,
- iterations,
- rm_chroot_tmp,
- perf_args,
- 'telemetry_Crosperf',
- show_all_results,
- retries,
- run_local,
- cwp_dso,
- weight,
- turbostat=turbostat_opt)
+ benchmarks, telemetry_crosbolt_perf_tests, test_args, iterations,
+ rm_chroot_tmp, perf_args, 'telemetry_Crosperf', show_all_results,
+ retries, run_local, cwp_dso, weight)
self.AppendBenchmarkSet(
benchmarks,
crosbolt_perf_tests,
@@ -309,23 +281,12 @@ class ExperimentFactory(object):
retries,
run_local=False,
cwp_dso=cwp_dso,
- weight=weight,
- turbostat=turbostat_opt)
+ weight=weight)
elif test_name == 'all_toolchain_perf':
- self.AppendBenchmarkSet(
- benchmarks,
- telemetry_toolchain_perf_tests,
- test_args,
- iterations,
- rm_chroot_tmp,
- perf_args,
- suite,
- show_all_results,
- retries,
- run_local,
- cwp_dso,
- weight,
- turbostat=turbostat_opt)
+ self.AppendBenchmarkSet(benchmarks, telemetry_toolchain_perf_tests,
+ test_args, iterations, rm_chroot_tmp,
+ perf_args, suite, show_all_results, retries,
+ run_local, cwp_dso, weight)
# Add non-telemetry toolchain-perf benchmarks:
benchmarks.append(
Benchmark(
@@ -340,28 +301,17 @@ class ExperimentFactory(object):
retries,
run_local=False,
cwp_dso=cwp_dso,
- weight=weight,
- turbostat=turbostat_opt))
+ weight=weight))
elif test_name == 'all_toolchain_perf_old':
self.AppendBenchmarkSet(
- benchmarks,
- telemetry_toolchain_old_perf_tests,
- test_args,
- iterations,
- rm_chroot_tmp,
- perf_args,
- suite,
- show_all_results,
- retries,
- run_local,
- cwp_dso,
- weight,
- turbostat=turbostat_opt)
+ benchmarks, telemetry_toolchain_old_perf_tests, test_args,
+ iterations, rm_chroot_tmp, perf_args, suite, show_all_results,
+ retries, run_local, cwp_dso, weight)
else:
benchmark = Benchmark(benchmark_name, test_name, test_args,
iterations, rm_chroot_tmp, perf_args, suite,
show_all_results, retries, run_local, cwp_dso,
- weight, turbostat_opt)
+ weight)
benchmarks.append(benchmark)
else:
if test_name == 'all_graphics_perf':
@@ -377,8 +327,7 @@ class ExperimentFactory(object):
retries,
run_local=False,
cwp_dso=cwp_dso,
- weight=weight,
- turbostat=turbostat_opt)
+ weight=weight)
else:
# Add the single benchmark.
benchmark = Benchmark(
@@ -393,8 +342,7 @@ class ExperimentFactory(object):
retries,
run_local=False,
cwp_dso=cwp_dso,
- weight=weight,
- turbostat=turbostat_opt)
+ weight=weight)
benchmarks.append(benchmark)
if not benchmarks:
@@ -433,7 +381,7 @@ class ExperimentFactory(object):
raise RuntimeError("Can not have empty 'build' field!")
image, autotest_path, debug_path = label_settings.GetXbuddyPath(
build, autotest_path, debug_path, board, chromeos_root, log_level,
- perf_args)
+ download_debug)
cache_dir = label_settings.GetField('cache_dir')
chrome_src = label_settings.GetField('chrome_src')
@@ -473,8 +421,8 @@ class ExperimentFactory(object):
chromeos_root, cache_conditions, labels, benchmarks,
experiment_file.Canonicalize(), email,
acquire_timeout, log_dir, log_level, share_cache,
- results_dir, locks_dir, cwp_dso, enable_aslr,
- ignore_min_max, skylab, dut_config)
+ results_dir, locks_dir, cwp_dso, ignore_min_max,
+ skylab, dut_config)
return experiment
diff --git a/crosperf/experiment_factory_unittest.py b/crosperf/experiment_factory_unittest.py
index 32813357..69e34fcc 100755
--- a/crosperf/experiment_factory_unittest.py
+++ b/crosperf/experiment_factory_unittest.py
@@ -29,6 +29,7 @@ import settings_factory
EXPERIMENT_FILE_1 = """
board: x86-alex
remote: chromeos-alex3
+ locks_dir: /tmp
benchmark: PageCycler {
iterations: 3
@@ -51,6 +52,7 @@ EXPERIMENT_FILE_1 = """
EXPERIMENT_FILE_2 = """
board: x86-alex
remote: chromeos-alex3
+ locks_dir: /tmp
cwp_dso: kallsyms
@@ -111,7 +113,7 @@ class ExperimentFactoryTest(unittest.TestCase):
self.assertEqual(exp.benchmarks[1].weight, 0.2)
def testDuplecateBenchmark(self):
- mock_experiment_file = ExperimentFile(io.BytesIO(''))
+ mock_experiment_file = ExperimentFile(io.BytesIO(EXPERIMENT_FILE_1))
mock_experiment_file.all_settings = []
benchmark_settings1 = settings_factory.BenchmarkSettings('name')
mock_experiment_file.all_settings.append(benchmark_settings1)
@@ -126,6 +128,7 @@ class ExperimentFactoryTest(unittest.TestCase):
mock_experiment_file = ExperimentFile(io.BytesIO(''))
mock_experiment_file.all_settings = []
global_settings = settings_factory.GlobalSettings('test_name')
+ global_settings.SetField('locks_dir', '/tmp')
# Test 1: DSO type not supported
global_settings.SetField('cwp_dso', 'test')
@@ -240,7 +243,7 @@ class ExperimentFactoryTest(unittest.TestCase):
bench_list = []
ef.AppendBenchmarkSet(bench_list, experiment_factory.telemetry_perfv2_tests,
'', 1, False, '', 'telemetry_Crosperf', False, 0,
- False, '', 0, False)
+ False, '', 0)
self.assertEqual(
len(bench_list), len(experiment_factory.telemetry_perfv2_tests))
self.assertTrue(isinstance(bench_list[0], benchmark.Benchmark))
@@ -248,7 +251,7 @@ class ExperimentFactoryTest(unittest.TestCase):
bench_list = []
ef.AppendBenchmarkSet(
bench_list, experiment_factory.telemetry_pagecycler_tests, '', 1, False,
- '', 'telemetry_Crosperf', False, 0, False, '', 0, False)
+ '', 'telemetry_Crosperf', False, 0, False, '', 0)
self.assertEqual(
len(bench_list), len(experiment_factory.telemetry_pagecycler_tests))
self.assertTrue(isinstance(bench_list[0], benchmark.Benchmark))
@@ -256,7 +259,7 @@ class ExperimentFactoryTest(unittest.TestCase):
bench_list = []
ef.AppendBenchmarkSet(
bench_list, experiment_factory.telemetry_toolchain_perf_tests, '', 1,
- False, '', 'telemetry_Crosperf', False, 0, False, '', 0, False)
+ False, '', 'telemetry_Crosperf', False, 0, False, '', 0)
self.assertEqual(
len(bench_list), len(experiment_factory.telemetry_toolchain_perf_tests))
self.assertTrue(isinstance(bench_list[0], benchmark.Benchmark))
@@ -309,6 +312,7 @@ class ExperimentFactoryTest(unittest.TestCase):
# Basic test.
global_settings.SetField('name', 'unittest_test')
global_settings.SetField('board', 'lumpy')
+ global_settings.SetField('locks_dir', '/tmp')
global_settings.SetField('remote', '123.45.67.89 123.45.76.80')
benchmark_settings.SetField('test_name', 'kraken')
benchmark_settings.SetField('suite', 'telemetry_Crosperf')
diff --git a/crosperf/experiment_file.py b/crosperf/experiment_file.py
index 41a2b809..33459d11 100644
--- a/crosperf/experiment_file.py
+++ b/crosperf/experiment_file.py
@@ -170,13 +170,12 @@ class ExperimentFile(object):
debug_path = ''
if debug_field.assigned:
debug_path = autotest_field.GetString()
- perf_args_field = self.global_settings.fields['perf_args']
- perf_args = ''
- if perf_args_field.assigned:
- perf_args = perf_args_field.GetString()
+ # Do not download the debug symbols since this function is for
+ # canonicalizing experiment file.
+ downlad_debug = False
image_path, autotest_path, debug_path = settings.GetXbuddyPath(
value, autotest_path, debug_path, board, chromeos_root,
- 'quiet', perf_args)
+ 'quiet', downlad_debug)
res += '\t#actual_image: %s\n' % image_path
if not autotest_field.assigned:
res += '\t#actual_autotest_path: %s\n' % autotest_path
diff --git a/crosperf/experiment_runner.py b/crosperf/experiment_runner.py
index cb6e9785..a536f161 100644
--- a/crosperf/experiment_runner.py
+++ b/crosperf/experiment_runner.py
@@ -148,7 +148,7 @@ class ExperimentRunner(object):
experiment.locked_machines = self.locked_machines
self._UpdateMachineList(self.locked_machines)
experiment.machine_manager.RemoveNonLockedMachines(self.locked_machines)
- if len(self.locked_machines) == 0:
+ if not self.locked_machines:
raise RuntimeError('Unable to lock any machines.')
def _ClearCacheEntries(self, experiment):
@@ -168,7 +168,13 @@ class ExperimentRunner(object):
def _Run(self, experiment):
try:
- self._LockAllMachines(experiment)
+ # We should not lease machines if tests are launched via `skylab
+ # create-test`. This is because leasing DUT in skylab will create a
+ # dummy task on the DUT and new test created will be hanging there.
+ # TODO(zhizhouy): Need to check whether machine is ready or not before
+ # assigning a test to it.
+ if not experiment.skylab:
+ self._LockAllMachines(experiment)
# Calculate all checksums of avaiable/locked machines, to ensure same
# label has same machines for testing
experiment.SetCheckSums(forceSameImage=True)
diff --git a/crosperf/experiment_runner_unittest.py b/crosperf/experiment_runner_unittest.py
index 2ec11ccd..8747de45 100755
--- a/crosperf/experiment_runner_unittest.py
+++ b/crosperf/experiment_runner_unittest.py
@@ -36,6 +36,7 @@ from cros_utils.file_utils import FileUtils
EXPERIMENT_FILE_1 = """
board: parrot
remote: chromeos-parrot1.cros chromreos-parrot2.cros
+ locks_dir: /tmp
benchmark: kraken {
suite: telemetry_Crosperf
diff --git a/crosperf/machine_manager.py b/crosperf/machine_manager.py
index ea3d105a..2cdaca3f 100644
--- a/crosperf/machine_manager.py
+++ b/crosperf/machine_manager.py
@@ -62,6 +62,7 @@ class CrosMachine(object):
self.checksum_string = None
self.meminfo = None
self.phys_kbytes = None
+ self.cooldown_wait_time = 0
self.ce = cmd_exec or command_executer.GetCommandExecuter(
log_level=self.log_level)
self.SetUpChecksumInfo()
@@ -85,6 +86,12 @@ class CrosMachine(object):
return False
return True
+ def AddCooldownWaitTime(self, wait_time):
+ self.cooldown_wait_time += wait_time
+
+ def GetCooldownWaitTime(self):
+ return self.cooldown_wait_time
+
def _ParseMemoryInfo(self):
line = self.meminfo.splitlines()[0]
usable_kbytes = int(line.split()[1])
@@ -627,6 +634,7 @@ power management:
self.machine_checksum = self._GetMD5Checksum(self.checksum_string)
self.log_level = log_level
self.label = None
+ self.cooldown_wait_time = 0
self.ce = command_executer.GetCommandExecuter(log_level=self.log_level)
self._GetCPUInfo()
diff --git a/crosperf/machine_manager_unittest.py b/crosperf/machine_manager_unittest.py
index 0f64a714..f6a77bb8 100755
--- a/crosperf/machine_manager_unittest.py
+++ b/crosperf/machine_manager_unittest.py
@@ -12,9 +12,9 @@ from __future__ import print_function
import os.path
import time
import hashlib
+import unittest
import mock
-import unittest
import label
import machine_manager
@@ -184,7 +184,7 @@ class MachineManagerTest(unittest.TestCase):
self.assertEqual(mock_run_cmd.call_count, 0)
self.assertEqual(mock_run_croscmd.call_count, 0)
- #Test 2: label.image_type == "trybot"
+ # Test 2: label.image_type == "trybot"
ResetValues()
LABEL_LUMPY.image_type = 'trybot'
mock_run_cmd.return_value = 0
@@ -456,7 +456,7 @@ class MachineManagerTest(unittest.TestCase):
suite='telemetry_Crosperf') # suite
test_run = MockBenchmarkRun('test run', bench, LABEL_LUMPY, 1, [], self.mm,
- mock_logger, 'verbose', '', {}, False)
+ mock_logger, 'verbose', '', {})
self.mm._machines = [
self.mock_lumpy1, self.mock_lumpy2, self.mock_lumpy3, self.mock_daisy1,
@@ -840,6 +840,15 @@ class CrosMachineTest(unittest.TestCase):
mock_run_cmd.return_value = [0, 'invalid hardware config', '']
self.assertRaises(cm._GetMachineID)
+ def test_add_cooldown_waittime(self):
+ cm = machine_manager.CrosMachine('1.2.3.4.cros', '/usr/local/chromeos',
+ 'average')
+ self.assertEqual(cm.GetCooldownWaitTime(), 0)
+ cm.AddCooldownWaitTime(250)
+ self.assertEqual(cm.GetCooldownWaitTime(), 250)
+ cm.AddCooldownWaitTime(1)
+ self.assertEqual(cm.GetCooldownWaitTime(), 251)
+
if __name__ == '__main__':
unittest.main()
diff --git a/crosperf/results_report.py b/crosperf/results_report.py
index edbdd4d7..22719027 100644
--- a/crosperf/results_report.py
+++ b/crosperf/results_report.py
@@ -12,6 +12,7 @@ import itertools
import json
import os
import re
+import time
from cros_utils.tabulator import AmeanResult
from cros_utils.tabulator import Cell
@@ -371,10 +372,16 @@ class TextResultsReport(ResultsReport):
cell_table = TableFormatter(table, columns).GetCellTable('status')
return [cell_table]
- def _GetTotalWaitCooldownTime(self):
- """Get cooldown wait time in seconds from experiment benchmark runs."""
- return sum(br.suite_runner.GetCooldownWaitTime()
- for br in self.experiment.benchmark_runs)
+ def GetTotalWaitCooldownTime(self):
+ """Get cooldown wait time in seconds from experiment benchmark runs.
+
+ Returns:
+ Dictionary {'dut': int(wait_time_in_seconds)}
+ """
+ waittime_dict = {}
+ for dut in self.experiment.machine_manager.GetMachines():
+ waittime_dict[dut.name] = dut.GetCooldownWaitTime()
+ return waittime_dict
def GetReport(self):
"""Generate the report for email and console."""
@@ -411,8 +418,20 @@ class TextResultsReport(ResultsReport):
cpu_info = experiment.machine_manager.GetAllCPUInfo(experiment.labels)
sections.append(self._MakeSection('CPUInfo', cpu_info))
- waittime_str = '%d min' % (self._GetTotalWaitCooldownTime() // 60)
- sections.append(self._MakeSection('Cooldown wait time', waittime_str))
+ totaltime = (
+ time.time() - experiment.start_time) if experiment.start_time else 0
+ totaltime_str = 'Total experiment time:\n%d min' % (totaltime // 60)
+ cooldown_waittime_list = ['Cooldown wait time:']
+ # When running experiment on multiple DUTs cooldown wait time may vary
+ # on different devices. In addition its combined time may exceed total
+ # experiment time which will look weird but it is reasonable.
+ # For this matter print cooldown time per DUT.
+ for dut, waittime in sorted(self.GetTotalWaitCooldownTime().items()):
+ cooldown_waittime_list.append('DUT %s: %d min' % (dut, waittime // 60))
+ cooldown_waittime_str = '\n'.join(cooldown_waittime_list)
+ sections.append(
+ self._MakeSection('Duration', '\n\n'.join(
+ [totaltime_str, cooldown_waittime_str])))
return '\n'.join(sections)
@@ -667,8 +686,8 @@ class JSONResultsReport(ResultsReport):
def __init__(self,
benchmark_results,
- date=None,
- time=None,
+ benchmark_date=None,
+ benchmark_time=None,
experiment=None,
json_args=None):
"""Construct a JSONResultsReport.
@@ -689,19 +708,22 @@ class JSONResultsReport(ResultsReport):
self.json_args = json_args
self.experiment = experiment
- if not date:
+ if not benchmark_date:
timestamp = datetime.datetime.strftime(datetime.datetime.now(),
'%Y-%m-%d %H:%M:%S')
- date, time = timestamp.split(' ')
- self.date = date
- self.time = time
+ benchmark_date, benchmark_time = timestamp.split(' ')
+ self.date = benchmark_date
+ self.time = benchmark_time
@staticmethod
- def FromExperiment(experiment, date=None, time=None, json_args=None):
+ def FromExperiment(experiment,
+ benchmark_date=None,
+ benchmark_time=None,
+ json_args=None):
benchmark_results = BenchmarkResults.FromExperiment(
experiment, for_json_report=True)
- return JSONResultsReport(benchmark_results, date, time, experiment,
- json_args)
+ return JSONResultsReport(benchmark_results, benchmark_date, benchmark_time,
+ experiment, json_args)
def GetReportObjectIgnoringExperiment(self):
"""Gets the JSON report object specifically for the output data.
diff --git a/crosperf/results_report_unittest.py b/crosperf/results_report_unittest.py
index ae51fda6..48fa0c38 100755
--- a/crosperf/results_report_unittest.py
+++ b/crosperf/results_report_unittest.py
@@ -86,6 +86,7 @@ def MakeMockExperiment(compiler='gcc'):
mock_experiment_file = io.BytesIO("""
board: x86-alex
remote: 127.0.0.1
+ locks_dir: /tmp
perf_args: record -a -e cycles
benchmark: PageCycler {
iterations: 3
@@ -109,8 +110,7 @@ def MakeMockExperiment(compiler='gcc'):
return experiment
-def _InjectSuccesses(experiment, how_many, keyvals, for_benchmark=0,
- label=None):
+def _InjectSuccesses(experiment, how_many, keyvals, for_benchmark=0):
"""Injects successful experiment runs (for each label) into the experiment."""
# Defensive copy of keyvals, so if it's modified, we'll know.
keyvals = dict(keyvals)
@@ -146,12 +146,6 @@ def _InjectSuccesses(experiment, how_many, keyvals, for_benchmark=0,
return experiment
-def _InjectCooldownTime(experiment, cooldown_time):
- """Inject cooldown wait time in every benchmark run."""
- for br in experiment.benchmark_runs:
- br.suite_runner.cooldown_wait_time = cooldown_time
-
-
class TextResultsReportTest(unittest.TestCase):
"""Tests that the output of a text report contains the things we pass in.
@@ -159,33 +153,48 @@ class TextResultsReportTest(unittest.TestCase):
things are displayed. It just cares that they're present.
"""
- def _checkReport(self, email):
+ def _checkReport(self, mock_getcooldown, email):
num_success = 2
success_keyvals = {'retval': 0, 'machine': 'some bot', 'a_float': 3.96}
experiment = _InjectSuccesses(MakeMockExperiment(), num_success,
success_keyvals)
- # Set 120 sec cooldown time for every benchmark run.
- cooldown_time = 120
- _InjectCooldownTime(experiment, cooldown_time)
+ SECONDS_IN_MIN = 60
+ mock_getcooldown.return_value = {
+ experiment.remote[0]: 12 * SECONDS_IN_MIN,
+ experiment.remote[1]: 8 * SECONDS_IN_MIN
+ }
+
text_report = TextResultsReport.FromExperiment(
experiment, email=email).GetReport()
self.assertIn(str(success_keyvals['a_float']), text_report)
self.assertIn(success_keyvals['machine'], text_report)
self.assertIn(MockCrosMachine.CPUINFO_STRING, text_report)
- self.assertIn('Cooldown wait time', text_report)
- self.assertIn(
- '%d min' % (len(experiment.benchmark_runs) * cooldown_time // 60),
- text_report)
+ self.assertIn('\nDuration\n', text_report)
+ self.assertIn('Total experiment time:\n', text_report)
+ self.assertIn('Cooldown wait time:\n', text_report)
+ self.assertIn('DUT %s: %d min' % (experiment.remote[0], 12), text_report)
+ self.assertIn('DUT %s: %d min' % (experiment.remote[1], 8), text_report)
return text_report
- def testOutput(self):
- email_report = self._checkReport(email=True)
- text_report = self._checkReport(email=False)
+ @mock.patch.object(TextResultsReport, 'GetTotalWaitCooldownTime')
+ def testOutput(self, mock_getcooldown):
+ email_report = self._checkReport(mock_getcooldown, email=True)
+ text_report = self._checkReport(mock_getcooldown, email=False)
# Ensure that the reports somehow different. Otherwise, having the
# distinction is useless.
self.assertNotEqual(email_report, text_report)
+ def test_get_totalwait_cooldowntime(self):
+ experiment = MakeMockExperiment()
+ cros_machines = experiment.machine_manager.GetMachines()
+ cros_machines[0].AddCooldownWaitTime(120)
+ cros_machines[1].AddCooldownWaitTime(240)
+ text_results = TextResultsReport.FromExperiment(experiment, email=False)
+ total = text_results.GetTotalWaitCooldownTime()
+ self.assertEqual(total[experiment.remote[0]], 120)
+ self.assertEqual(total[experiment.remote[1]], 240)
+
class HTMLResultsReportTest(unittest.TestCase):
"""Tests that the output of a HTML report contains the things we pass in.
@@ -222,9 +231,9 @@ class HTMLResultsReportTest(unittest.TestCase):
else:
HTMLResultsReport(benchmark_results).GetReport()
mod_mock = standin
- self.assertEquals(mod_mock.call_count, 1)
+ self.assertEqual(mod_mock.call_count, 1)
# call_args[0] is positional args, call_args[1] is kwargs.
- self.assertEquals(mod_mock.call_args[0], tuple())
+ self.assertEqual(mod_mock.call_args[0], tuple())
fmt_args = mod_mock.call_args[1]
return self._GetTestOutput(**fmt_args)
diff --git a/crosperf/schedv2.py b/crosperf/schedv2.py
index 768d29d8..d15f18c0 100644
--- a/crosperf/schedv2.py
+++ b/crosperf/schedv2.py
@@ -9,7 +9,6 @@ from __future__ import division
from __future__ import print_function
import sys
-import time
import traceback
from collections import defaultdict
@@ -21,6 +20,7 @@ import test_flag
from machine_image_manager import MachineImageManager
from cros_utils import command_executer
from cros_utils import logger
+from cros_utils.device_setup_utils import DutWrapper
class DutWorker(Thread):
@@ -49,153 +49,6 @@ class DutWorker(Thread):
# suite_runner.Terminate and updates timeline.
self._active_br.Terminate()
- def _kerncmd_update_needed(self, intel_pstate):
- """Check whether kernel cmdline update is needed.
-
- Args:
- intel_pstate: kernel command line argument (active, passive, no_hwp)
-
- Returns:
- True if update is needed.
- """
-
- ce = command_executer.GetCommandExecuter()
- good = 0
-
- # Check that dut platform supports hwp
- cmd = "grep -q '^flags.*hwp' /proc/cpuinfo"
- ret_code = ce.CrosRunCommand(
- cmd,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- if ret_code != good:
- # Intel hwp is not supported, update is not needed.
- return False
-
- kern_cmdline_cmd = 'grep -q "intel_pstate=%s" /proc/cmdline' % intel_pstate
- ret_code = ce.CrosRunCommand(
- kern_cmdline_cmd,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- self._logger.LogOutput('grep /proc/cmdline returned %d' % ret_code)
- if (intel_pstate and ret_code == good or
- not intel_pstate and ret_code != good):
- # No need to updated cmdline if:
- # 1. We are setting intel_pstate and we found it is already set.
- # 2. Not using intel_pstate and it is not in cmdline.
- return False
-
- # Otherwise we need to update intel_pstate.
- return True
-
- def _update_kerncmd_intel_pstate(self, intel_pstate):
- """Update kernel command line.
-
- Args:
- intel_pstate: kernel command line argument (active, passive, no_hwp)
- """
-
- ce = command_executer.GetCommandExecuter()
- good = 0
-
- # First phase is to remove rootfs verification to allow cmdline change.
- remove_verif_cmd = ' '.join([
- '/usr/share/vboot/bin/make_dev_ssd.sh',
- '--remove_rootfs_verification',
- '--partition %d',
- ])
- # Command for partition 2.
- verif_part2_failed = ce.CrosRunCommand(
- remove_verif_cmd % 2,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- # Command for partition 4
- # Some machines in the lab use partition 4 to boot from,
- # so cmdline should be update for both partitions.
- verif_part4_failed = ce.CrosRunCommand(
- remove_verif_cmd % 4,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- if verif_part2_failed or verif_part4_failed:
- self._logger.LogFatal(
- 'ERROR. Failed to update kernel cmdline on partition %d.\n'
- 'Remove verification failed with status %d' %
- (2 if verif_part2_failed else 4, verif_part2_failed or
- verif_part4_failed))
-
- ce.CrosRunCommand(
- 'reboot && exit',
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- # Give enough time for dut to complete reboot
- # TODO(denik): Replace with the function checking machine availability.
- time.sleep(30)
-
- # Second phase to update intel_pstate in kernel cmdline.
- kern_cmdline = '\n'.join([
- 'tmpfile=$(mktemp)',
- 'partnumb=%d',
- 'pstate=%s',
- # Store kernel cmdline in a temp file.
- '/usr/share/vboot/bin/make_dev_ssd.sh --partition ${partnumb}'
- ' --save_config ${tmpfile}',
- # Remove intel_pstate argument if present.
- "sed -i -r 's/ intel_pstate=[A-Za-z_]+//g' ${tmpfile}.${partnumb}",
- # Insert intel_pstate with a new value if it is set.
- '[[ -n ${pstate} ]] &&'
- ' sed -i -e \"s/ *$/ intel_pstate=${pstate}/\" ${tmpfile}.${partnumb}',
- # Save the change in kernel cmdline.
- # After completion we have to reboot.
- '/usr/share/vboot/bin/make_dev_ssd.sh --partition ${partnumb}'
- ' --set_config ${tmpfile}'
- ])
- kern_part2_cmdline_cmd = kern_cmdline % (2, intel_pstate)
- self._logger.LogOutput(
- 'Command to change kernel command line: %s' % kern_part2_cmdline_cmd)
- upd_part2_failed = ce.CrosRunCommand(
- kern_part2_cmdline_cmd,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- # Again here we are updating cmdline for partition 4
- # in addition to partition 2. Without this some machines
- # in the lab might fail.
- kern_part4_cmdline_cmd = kern_cmdline % (4, intel_pstate)
- self._logger.LogOutput(
- 'Command to change kernel command line: %s' % kern_part4_cmdline_cmd)
- upd_part4_failed = ce.CrosRunCommand(
- kern_part4_cmdline_cmd,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- if upd_part2_failed or upd_part4_failed:
- self._logger.LogFatal(
- 'ERROR. Failed to update kernel cmdline on partition %d.\n'
- 'intel_pstate update failed with status %d' %
- (2 if upd_part2_failed else 4, upd_part2_failed or upd_part4_failed))
-
- ce.CrosRunCommand(
- 'reboot && exit',
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- # Wait 30s after reboot.
- time.sleep(30)
-
- # Verification phase.
- # Check that cmdline was updated.
- # Throw an exception if not.
- kern_cmdline_cmd = 'grep -q "intel_pstate=%s" /proc/cmdline' % intel_pstate
- ret_code = ce.CrosRunCommand(
- kern_cmdline_cmd,
- chromeos_root=self._sched.get_labels(0).chromeos_root,
- machine=self._dut.name)
- if (intel_pstate and ret_code != good or
- not intel_pstate and ret_code == good):
- # Kernel cmdline doesn't match input intel_pstate.
- self._logger.LogFatal(
- 'ERROR. Failed to update kernel cmdline. '
- 'Final verification failed with status %d' % ret_code)
-
- self._logger.LogOutput('Kernel cmdline updated successfully.')
-
def run(self):
"""Do the "run-test->(optionally reimage)->run-test" chore.
@@ -205,8 +58,6 @@ class DutWorker(Thread):
intel_pstate = self._sched.get_experiment().intel_pstate
# Firstly, handle benchmarkruns that have cache hit.
br = self._sched.get_cached_benchmark_run()
- # Total wait time for cooling down.
- total_waittime = 0
while br:
try:
self._stat_annotation = 'finishing cached {}'.format(br)
@@ -240,20 +91,16 @@ class DutWorker(Thread):
else:
self._logger.LogOutput('Update kernel cmdline if necessary '
'and reboot')
- if self._kerncmd_update_needed(intel_pstate):
- self._update_kerncmd_intel_pstate(intel_pstate)
-
- # When calculating cooldown wait time we assume that suite_runner is
- # never reused so we can sum up the values across all benchmark_runs.
- # If implementation changes causing the assert below to fail the
- # calculation should be adjusted accordingly.
- assert br.suite_runner.GetCooldownWaitTime() == 0
+ run_on_dut = DutWrapper(
+ self._sched.get_labels(0).chromeos_root,
+ self._dut.name,
+ logger=self._logger)
+ if run_on_dut.KerncmdUpdateNeeded(intel_pstate):
+ run_on_dut.UpdateKerncmdIntelPstate(intel_pstate)
+
# Execute the br.
self._execute_benchmark_run(br)
- total_waittime += br.suite_runner.GetCooldownWaitTime()
finally:
- self._logger.LogOutput(
- 'Total wait time for cooldown: %d min' % (total_waittime // 60))
self._stat_annotation = 'finished'
# Thread finishes. Notify scheduler that I'm done.
self._sched.dut_worker_finished(self)
diff --git a/crosperf/schedv2_unittest.py b/crosperf/schedv2_unittest.py
index 4aced646..3ccf6fa4 100755
--- a/crosperf/schedv2_unittest.py
+++ b/crosperf/schedv2_unittest.py
@@ -26,6 +26,7 @@ from schedv2 import Schedv2
EXPERIMENT_FILE_1 = """\
board: daisy
remote: chromeos-daisy1.cros chromeos-daisy2.cros
+locks_dir: /tmp
benchmark: kraken {
suite: telemetry_Crosperf
@@ -46,6 +47,7 @@ image2 {
EXPERIMENT_FILE_WITH_FORMAT = """\
board: daisy
remote: chromeos-daisy1.cros chromeos-daisy2.cros
+locks_dir: /tmp
benchmark: kraken {{
suite: telemetry_Crosperf
@@ -131,16 +133,16 @@ class Schedv2Test(unittest.TestCase):
# We have 9 * 2 == 18 brs, we use 5 threads, each reading 4, 4, 4,
# 4, 2 brs respectively.
# Assert that BenchmarkRunCacheReader() is called 5 times.
- self.assertEquals(reader.call_count, 5)
+ self.assertEqual(reader.call_count, 5)
# reader.call_args_list[n] - nth call.
# reader.call_args_list[n][0] - positioned args in nth call.
# reader.call_args_list[n][0][1] - the 2nd arg in nth call,
# that is 'br_list' in 'schedv2.BenchmarkRunCacheReader'.
- self.assertEquals(len(reader.call_args_list[0][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[1][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[2][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[3][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[4][0][1]), 2)
+ self.assertEqual(len(reader.call_args_list[0][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[1][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[2][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[3][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[4][0][1]), 2)
@mock.patch('schedv2.BenchmarkRunCacheReader')
def test_BenchmarkRunCacheReader_2(self, reader):
@@ -151,11 +153,11 @@ class Schedv2Test(unittest.TestCase):
my_schedv2 = Schedv2(self.exp)
self.assertFalse(my_schedv2.is_complete())
# We have 8 * 2 == 16 brs, we use 4 threads, each reading 4 brs.
- self.assertEquals(reader.call_count, 4)
- self.assertEquals(len(reader.call_args_list[0][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[1][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[2][0][1]), 4)
- self.assertEquals(len(reader.call_args_list[3][0][1]), 4)
+ self.assertEqual(reader.call_count, 4)
+ self.assertEqual(len(reader.call_args_list[0][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[1][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[2][0][1]), 4)
+ self.assertEqual(len(reader.call_args_list[3][0][1]), 4)
@mock.patch('schedv2.BenchmarkRunCacheReader')
def test_BenchmarkRunCacheReader_3(self, reader):
@@ -166,9 +168,9 @@ class Schedv2Test(unittest.TestCase):
my_schedv2 = Schedv2(self.exp)
self.assertFalse(my_schedv2.is_complete())
# We have 3 * 2 == 6 brs, we use 2 threads.
- self.assertEquals(reader.call_count, 2)
- self.assertEquals(len(reader.call_args_list[0][0][1]), 3)
- self.assertEquals(len(reader.call_args_list[1][0][1]), 3)
+ self.assertEqual(reader.call_count, 2)
+ self.assertEqual(len(reader.call_args_list[0][0][1]), 3)
+ self.assertEqual(len(reader.call_args_list[1][0][1]), 3)
@mock.patch('schedv2.BenchmarkRunCacheReader')
def test_BenchmarkRunCacheReader_4(self, reader):
@@ -179,8 +181,8 @@ class Schedv2Test(unittest.TestCase):
my_schedv2 = Schedv2(self.exp)
self.assertFalse(my_schedv2.is_complete())
# We have 1 * 2 == 2 br, so only 1 instance.
- self.assertEquals(reader.call_count, 1)
- self.assertEquals(len(reader.call_args_list[0][0][1]), 2)
+ self.assertEqual(reader.call_count, 1)
+ self.assertEqual(len(reader.call_args_list[0][0][1]), 2)
def test_cachehit(self):
"""Test cache-hit and none-cache-hit brs are properly organized."""
@@ -194,9 +196,9 @@ class Schedv2Test(unittest.TestCase):
self.exp = self._make_fake_experiment(
EXPERIMENT_FILE_WITH_FORMAT.format(kraken_iterations=30))
my_schedv2 = Schedv2(self.exp)
- self.assertEquals(len(my_schedv2.get_cached_run_list()), 30)
+ self.assertEqual(len(my_schedv2.get_cached_run_list()), 30)
# The non-cache-hit brs are put into Schedv2._label_brl_map.
- self.assertEquals(
+ self.assertEqual(
functools.reduce(lambda a, x: a + len(x[1]),
my_schedv2.get_label_map().iteritems(), 0), 30)
@@ -212,9 +214,9 @@ class Schedv2Test(unittest.TestCase):
self.exp = self._make_fake_experiment(
EXPERIMENT_FILE_WITH_FORMAT.format(kraken_iterations=30))
my_schedv2 = Schedv2(self.exp)
- self.assertEquals(len(my_schedv2.get_cached_run_list()), 0)
+ self.assertEqual(len(my_schedv2.get_cached_run_list()), 0)
# The non-cache-hit brs are put into Schedv2._label_brl_map.
- self.assertEquals(
+ self.assertEqual(
functools.reduce(lambda a, x: a + len(x[1]),
my_schedv2.get_label_map().iteritems(), 0), 60)
diff --git a/crosperf/settings.py b/crosperf/settings.py
index 290abfc2..708697b1 100644
--- a/crosperf/settings.py
+++ b/crosperf/settings.py
@@ -71,7 +71,7 @@ class Settings(object):
raise SyntaxError('Field %s is invalid.' % name)
def GetXbuddyPath(self, path_str, autotest_path, debug_path, board,
- chromeos_root, log_level, perf_args):
+ chromeos_root, log_level, download_debug):
prefix = 'remote'
l = logger.GetLogger()
if (path_str.find('trybot') < 0 and path_str.find('toolchain') < 0 and
@@ -83,4 +83,4 @@ class Settings(object):
# Returns three variables: image, autotest_path, debug_path
return image_downloader.Run(
misc.CanonicalizePath(chromeos_root), xbuddy_path, autotest_path,
- debug_path, perf_args)
+ debug_path, download_debug)
diff --git a/crosperf/settings_factory.py b/crosperf/settings_factory.py
index 9057703f..1993a6c3 100644
--- a/crosperf/settings_factory.py
+++ b/crosperf/settings_factory.py
@@ -241,6 +241,14 @@ class GlobalSettings(Settings):
'related counters. It must start with perf '
'command record or stat followed by arguments.'))
self.AddField(
+ BooleanField(
+ 'download_debug',
+ default=True,
+ description='Download compressed debug symbols alongwith '
+ 'image. This can provide more info matching symbols for'
+ 'profiles, but takes larger space. By default, download'
+ 'it only when perf_args is specified.'))
+ self.AddField(
TextField(
'cache_dir',
default='',
diff --git a/crosperf/settings_factory_unittest.py b/crosperf/settings_factory_unittest.py
index d80dbb12..a303a065 100755
--- a/crosperf/settings_factory_unittest.py
+++ b/crosperf/settings_factory_unittest.py
@@ -50,7 +50,7 @@ class GlobalSettingsTest(unittest.TestCase):
def test_init(self):
res = settings_factory.GlobalSettings('g_settings')
self.assertIsNotNone(res)
- self.assertEqual(len(res.fields), 37)
+ self.assertEqual(len(res.fields), 38)
self.assertEqual(res.GetField('name'), '')
self.assertEqual(res.GetField('board'), '')
self.assertEqual(res.GetField('skylab'), False)
@@ -66,6 +66,7 @@ class GlobalSettingsTest(unittest.TestCase):
self.assertEqual(res.GetField('logging_level'), 'average')
self.assertEqual(res.GetField('acquire_timeout'), 0)
self.assertEqual(res.GetField('perf_args'), '')
+ self.assertEqual(res.GetField('download_debug'), True)
self.assertEqual(res.GetField('cache_dir'), '')
self.assertEqual(res.GetField('cache_only'), False)
self.assertEqual(res.GetField('no_email'), False)
@@ -106,7 +107,7 @@ class SettingsFactoryTest(unittest.TestCase):
g_settings = settings_factory.SettingsFactory().GetSettings(
'global', 'global')
self.assertIsInstance(g_settings, settings_factory.GlobalSettings)
- self.assertEqual(len(g_settings.fields), 37)
+ self.assertEqual(len(g_settings.fields), 38)
if __name__ == '__main__':
diff --git a/crosperf/settings_unittest.py b/crosperf/settings_unittest.py
index b9d87e9e..8140e9b9 100755
--- a/crosperf/settings_unittest.py
+++ b/crosperf/settings_unittest.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python2
-#-*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,8 +8,8 @@
from __future__ import print_function
-import mock
import unittest
+import mock
import settings
import settings_factory
@@ -201,33 +201,34 @@ class TestSettings(unittest.TestCase):
xbuddy_str = 'latest-dev'
autotest_path = ''
debug_path = ''
- perf_args = '-a'
+ download_debug = False
self.settings.GetXbuddyPath(trybot_str, autotest_path, debug_path, board,
- chromeos_root, log_level, perf_args)
+ chromeos_root, log_level, download_debug)
self.assertEqual(mock_run.call_count, 1)
self.assertEqual(mock_run.call_args_list[0][0], (
'/tmp/chromeos',
'remote/trybot-lumpy-paladin/R34-5417.0.0-b1506',
'',
'',
- '-a',
+ False,
))
mock_run.reset_mock()
self.settings.GetXbuddyPath(official_str, autotest_path, debug_path, board,
- chromeos_root, log_level, perf_args)
+ chromeos_root, log_level, download_debug)
self.assertEqual(mock_run.call_count, 1)
self.assertEqual(
mock_run.call_args_list[0][0],
- ('/tmp/chromeos', 'remote/lumpy-release/R34-5417.0.0', '', '', '-a'))
+ ('/tmp/chromeos', 'remote/lumpy-release/R34-5417.0.0', '', '', False))
mock_run.reset_mock()
self.settings.GetXbuddyPath(xbuddy_str, autotest_path, debug_path, board,
- chromeos_root, log_level, perf_args)
+ chromeos_root, log_level, download_debug)
self.assertEqual(mock_run.call_count, 1)
- self.assertEqual(mock_run.call_args_list[0][0],
- ('/tmp/chromeos', 'remote/lumpy/latest-dev', '', '', '-a'))
+ self.assertEqual(
+ mock_run.call_args_list[0][0],
+ ('/tmp/chromeos', 'remote/lumpy/latest-dev', '', '', False))
if mock_logger:
return
diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py
index 01e7114f..418358e0 100644
--- a/crosperf/suite_runner.py
+++ b/crosperf/suite_runner.py
@@ -8,12 +8,15 @@
from __future__ import division
from __future__ import print_function
+import json
import os
-import re
import shlex
import time
+from contextlib import contextmanager
+
from cros_utils import command_executer
+from cros_utils.device_setup_utils import DutWrapper
TEST_THAT_PATH = '/usr/bin/test_that'
# TODO: Need to check whether Skylab is installed and set up correctly.
@@ -57,8 +60,7 @@ class SuiteRunner(object):
logger_to_use=None,
log_level='verbose',
cmd_exec=None,
- cmd_term=None,
- enable_aslr=False):
+ cmd_term=None):
self.logger = logger_to_use
self.log_level = log_level
self._ce = cmd_exec or command_executer.GetCommandExecuter(
@@ -66,107 +68,36 @@ class SuiteRunner(object):
# DUT command executer.
# Will be initialized and used within Run.
self._ct = cmd_term or command_executer.CommandTerminator()
- self.enable_aslr = enable_aslr
self.dut_config = dut_config
- self.cooldown_wait_time = 0
-
- def ResetCooldownWaitTime(self):
- self.cooldown_wait_time = 0
-
- def GetCooldownWaitTime(self):
- return self.cooldown_wait_time
-
- def DutWrapper(self, machine_name, chromeos_root):
- """Wrap DUT parameters inside.
- Eventially CommandExecuter will reqiure only one
- argument - command.
- """
-
- def RunCommandOnDut(command, ignore_status=False):
- ret, msg, err_msg = self._ce.CrosRunCommandWOutput(
- command, machine=machine_name, chromeos_root=chromeos_root)
-
- if ret:
- err_msg = ('Command execution on DUT %s failed.\n'
- 'Failing command: %s\n'
- 'returned %d\n'
- 'Error message: %s' % (machine_name, command, ret, err_msg))
- if ignore_status:
- self.logger.LogError(err_msg +
- '\n(Failure is considered non-fatal. Continue.)')
- else:
- self.logger.LogFatal(err_msg)
-
- return ret, msg, err_msg
-
- return RunCommandOnDut
-
- def Run(self, machine, label, benchmark, test_args, profiler_args):
+ def Run(self, cros_machine, label, benchmark, test_args, profiler_args):
+ machine_name = cros_machine.name
if not label.skylab:
# Initialize command executer on DUT.
- run_on_dut = self.DutWrapper(machine, label.chromeos_root)
+ run_on_dut = DutWrapper(
+ label.chromeos_root,
+ machine_name,
+ logger=self.logger,
+ log_level=self.log_level,
+ ce=self._ce,
+ dut_config=self.dut_config)
for i in range(0, benchmark.retries + 1):
if label.skylab:
- # TODO: need to migrate DisableASLR and PinGovernorExecutionFrequencies
- # since in skylab mode, we may not know the DUT until one is assigned
+ # TODO: need to migrate Device setups to autotest for skylab.
+ # Since in skylab mode, we may not know the DUT until one is assigned
# to the test. For telemetry_Crosperf run, we can move them into the
# server test script, for client runs, need to figure out wrapper to do
# it before running.
ret_tup = self.Skylab_Run(label, benchmark, test_args, profiler_args)
else:
- # Unless the user turns on ASLR in the flag, we first disable ASLR
- # before running the benchmarks
- if not self.enable_aslr:
- self.DisableASLR(run_on_dut)
-
- # CPU usage setup comes first where we enable/disable cores.
- self.SetupCpuUsage(run_on_dut)
- cpu_online_status = self.GetCpuOnline(run_on_dut)
- # List of online cores of type int (core number).
- online_cores = [
- core for core, status in cpu_online_status.items() if status
- ]
- if self.dut_config['cooldown_time']:
- # Setup power conservative mode for effective cool down.
- # Set ignore status since powersave may no be available
- # on all platforms and we are going to handle it.
- ret = self.SetCpuGovernor('powersave', run_on_dut, ignore_status=True)
- if ret:
- # "powersave" is not available, use "ondemand".
- # Still not a fatal error if it fails.
- ret = self.SetCpuGovernor(
- 'ondemand', run_on_dut, ignore_status=True)
- # TODO(denik): Run comparison test for 'powersave' and 'ondemand'
- # on scarlet and kevin64.
- # We might have to consider reducing freq manually to the min
- # if it helps to reduce waiting time.
- self.cooldown_wait_time += self.WaitCooldown(run_on_dut)
-
- # Setup CPU governor for the benchmark run.
- # It overwrites the previous governor settings.
- governor = self.dut_config['governor']
- # FIXME(denik): Pass online cores to governor setup.
- self.SetCpuGovernor(governor, run_on_dut, ignore_status=False)
-
- # Disable Turbo and Setup CPU freq should ALWAYS proceed governor setup
- # since governor may change:
- # - frequency;
- # - turbo/boost.
- self.DisableTurbo(run_on_dut)
- self.SetupCpuFreq(run_on_dut, online_cores)
- # FIXME(denik): Currently we are not recovering the previous cpufreq
- # settings since we do reboot/setup every time anyway.
- # But it may change in the future and then we have to recover the
- # settings.
-
+ self.SetupDevice(run_on_dut, cros_machine)
if benchmark.suite == 'telemetry_Crosperf':
- self.DecreaseWaitTime(run_on_dut)
- ret_tup = self.Telemetry_Crosperf_Run(machine, label, benchmark,
+ run_on_dut.DecreaseWaitTime()
+ ret_tup = self.Telemetry_Crosperf_Run(machine_name, label, benchmark,
test_args, profiler_args)
else:
- ret_tup = self.Test_That_Run(machine, label, benchmark, test_args,
- profiler_args)
+ ret_tup = self.Test_That_Run(machine_name, label, benchmark,
+ test_args, profiler_args)
if ret_tup[0] != 0:
self.logger.LogOutput('benchmark %s failed. Retries left: %s' %
@@ -181,278 +112,68 @@ class SuiteRunner(object):
break
return ret_tup
- def DisableASLR(self, run_on_dut):
- disable_aslr = ('set -e && '
- 'stop ui; '
- 'if [[ -e /proc/sys/kernel/randomize_va_space ]]; then '
- ' echo 0 > /proc/sys/kernel/randomize_va_space; '
- 'fi; '
- 'start ui ')
- if self.log_level == 'average':
- self.logger.LogOutput('Disable ASLR.')
- run_on_dut(disable_aslr)
-
- def SetCpuGovernor(self, governor, run_on_dut, ignore_status=False):
- set_gov_cmd = (
- 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
- # Skip writing scaling_governor if cpu is offline.
- ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
- ' && continue; '
- ' cd $f; '
- ' if [[ -e scaling_governor ]]; then '
- ' echo %s > scaling_governor; fi; '
- 'done; ')
- if self.log_level == 'average':
- self.logger.LogOutput('Setup CPU Governor: %s.' % governor)
- ret, _, _ = run_on_dut(set_gov_cmd % governor, ignore_status=ignore_status)
- return ret
-
- def DisableTurbo(self, run_on_dut):
- dis_turbo_cmd = (
- 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then '
- ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then '
- ' echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo; '
- ' fi; '
- 'fi; ')
- if self.log_level == 'average':
- self.logger.LogOutput('Disable Turbo.')
- run_on_dut(dis_turbo_cmd)
-
- def WaitCooldown(self, run_on_dut):
- waittime = 0
- timeout_in_sec = int(self.dut_config['cooldown_time']) * 60
- # Temperature from sensors come in uCelsius units.
- temp_in_ucels = int(self.dut_config['cooldown_temp']) * 1000
- sleep_interval = 30
-
- # Wait until any of two events occurs:
- # 1. CPU cools down to a specified temperature.
- # 2. Timeout cooldown_time expires.
- # For the case when targeted temperature is not reached within specified
- # timeout the benchmark is going to start with higher initial CPU temp.
- # In the worst case it may affect test results but at the same time we
- # guarantee the upper bound of waiting time.
- # TODO(denik): Report (or highlight) "high" CPU temperature in test results.
- # "high" should be calculated based on empirical data per platform.
- # Based on such reports we can adjust CPU configuration or
- # cooldown limits accordingly.
- while waittime < timeout_in_sec:
- _, temp_output, _ = run_on_dut(
- 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
- if any(int(temp) > temp_in_ucels for temp in temp_output.split()):
- time.sleep(sleep_interval)
- waittime += sleep_interval
- else:
- # Exit the loop when:
- # 1. Reported temp numbers from all thermal sensors do not exceed
- # 'cooldown_temp' or
- # 2. No data from the sensors.
- break
-
- self.logger.LogOutput('Cooldown wait time: %.1f min' % (waittime / 60))
- return waittime
-
- def SetupCpuUsage(self, run_on_dut):
- """Setup CPU usage.
+ @contextmanager
+ def PauseUI(self, run_on_dut):
+ """Stop UI before and Start UI after the context block.
- Based on self.dut_config['cpu_usage'] configure CPU cores
- utilization.
+ Context manager will make sure UI is always resumed at the end.
"""
-
- if (self.dut_config['cpu_usage'] == 'big_only' or
- self.dut_config['cpu_usage'] == 'little_only'):
- _, arch, _ = run_on_dut('uname -m')
-
- if arch.lower().startswith('arm') or arch.lower().startswith('aarch64'):
- self.SetupArmCores(run_on_dut)
-
- def SetupArmCores(self, run_on_dut):
- """Setup ARM big/little cores."""
-
- # CPU implemeters/part numbers of big/LITTLE CPU.
- # Format: dict(CPU implementer: set(CPU part numbers))
- LITTLE_CORES = {
- '0x41': {
- '0xd01', # Cortex A32
- '0xd03', # Cortex A53
- '0xd04', # Cortex A35
- '0xd05', # Cortex A55
- },
- }
- BIG_CORES = {
- '0x41': {
- '0xd07', # Cortex A57
- '0xd08', # Cortex A72
- '0xd09', # Cortex A73
- '0xd0a', # Cortex A75
- '0xd0b', # Cortex A76
- },
- }
-
- # Values of CPU Implementer and CPU part number are exposed by cpuinfo.
- # Format:
- # =================
- # processor : 0
- # model name : ARMv8 Processor rev 4 (v8l)
- # BogoMIPS : 48.00
- # Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
- # CPU implementer : 0x41
- # CPU architecture: 8
- # CPU variant : 0x0
- # CPU part : 0xd03
- # CPU revision : 4
-
- _, cpuinfo, _ = run_on_dut('cat /proc/cpuinfo')
-
- # List of all CPU cores: 0, 1, ..
- proc_matches = re.findall(r'^processor\s*: (\d+)$', cpuinfo, re.MULTILINE)
- # List of all corresponding CPU implementers
- impl_matches = re.findall(r'^CPU implementer\s*: (0x[\da-f]+)$', cpuinfo,
- re.MULTILINE)
- # List of all corresponding CPU part numbers
- part_matches = re.findall(r'^CPU part\s*: (0x[\da-f]+)$', cpuinfo,
- re.MULTILINE)
- assert len(proc_matches) == len(impl_matches)
- assert len(part_matches) == len(impl_matches)
-
- all_cores = set(proc_matches)
- dut_big_cores = {
- core
- for core, impl, part in zip(proc_matches, impl_matches, part_matches)
- if impl in BIG_CORES and part in BIG_CORES[impl]
- }
- dut_lit_cores = {
- core
- for core, impl, part in zip(proc_matches, impl_matches, part_matches)
- if impl in LITTLE_CORES and part in LITTLE_CORES[impl]
- }
-
- if self.dut_config['cpu_usage'] == 'big_only':
- cores_to_enable = dut_big_cores
- cores_to_disable = all_cores - dut_big_cores
- elif self.dut_config['cpu_usage'] == 'little_only':
- cores_to_enable = dut_lit_cores
- cores_to_disable = all_cores - dut_lit_cores
- else:
- self.logger.LogError(
- 'cpu_usage=%s is not supported on ARM.\n'
- 'Ignore ARM CPU setup and continue.' % self.dut_config['cpu_usage'])
- return
-
- if cores_to_enable:
- cmd_enable_cores = ('echo 1 | tee /sys/devices/system/cpu/cpu{%s}/online'
- % ','.join(sorted(cores_to_enable)))
-
- cmd_disable_cores = ''
- if cores_to_disable:
- cmd_disable_cores = (
- 'echo 0 | tee /sys/devices/system/cpu/cpu{%s}/online' % ','.join(
- sorted(cores_to_disable)))
-
- run_on_dut('; '.join([cmd_enable_cores, cmd_disable_cores]))
- else:
- # If there are no cores enabled by dut_config then configuration
- # is invalid for current platform and should be ignored.
- self.logger.LogError(
- '"cpu_usage" is invalid for targeted platform.\n'
- 'dut_config[cpu_usage]=%s\n'
- 'dut big cores: %s\n'
- 'dut little cores: %s\n'
- 'Ignore ARM CPU setup and continue.' % (self.dut_config['cpu_usage'],
- dut_big_cores, dut_lit_cores))
-
- def GetCpuOnline(self, run_on_dut):
- """Get online status of CPU cores.
-
- Return dict of {int(cpu_num): <0|1>}.
- """
- get_cpu_online_cmd = ('paste -d" "'
- ' <(ls /sys/devices/system/cpu/cpu*/online)'
- ' <(cat /sys/devices/system/cpu/cpu*/online)')
- _, online_output_str, _ = run_on_dut(get_cpu_online_cmd)
-
- # Here is the output we expect to see:
- # -----------------
- # /sys/devices/system/cpu/cpu0/online 0
- # /sys/devices/system/cpu/cpu1/online 1
-
- cpu_online = {}
- cpu_online_match = re.compile(r'^[/\S]+/cpu(\d+)/[/\S]+\s+(\d+)$')
- for line in online_output_str.splitlines():
- match = cpu_online_match.match(line)
- if match:
- cpu = int(match.group(1))
- status = int(match.group(2))
- cpu_online[cpu] = status
- # At least one CPU has to be online.
- assert cpu_online
-
- return cpu_online
-
- def SetupCpuFreq(self, run_on_dut, online_cores):
- """Setup CPU frequency.
-
- Based on self.dut_config['cpu_freq_pct'] setup frequency of online CPU cores
- to a supported value which is less or equal to (freq_pct * max_freq / 100)
- limited by min_freq.
-
- NOTE: scaling_available_frequencies support is required.
- Otherwise the function has no effect.
- """
- freq_percent = self.dut_config['cpu_freq_pct']
- list_all_avail_freq_cmd = ('ls /sys/devices/system/cpu/cpu{%s}/cpufreq/'
- 'scaling_available_frequencies')
- # Ignore error to support general usage of frequency setup.
- # Not all platforms support scaling_available_frequencies.
- ret, all_avail_freq_str, _ = run_on_dut(
- list_all_avail_freq_cmd % ','.join(str(core) for core in online_cores),
- ignore_status=True)
- if ret or not all_avail_freq_str:
- # No scalable frequencies available for the core.
- return ret
- for avail_freq_path in all_avail_freq_str.split():
- # Get available freq from every scaling_available_frequency path.
- # Error is considered fatal in run_on_dut().
- _, avail_freq_str, _ = run_on_dut('cat ' + avail_freq_path)
- assert avail_freq_str
-
- all_avail_freq = sorted(
- int(freq_str) for freq_str in avail_freq_str.split())
- min_freq = all_avail_freq[0]
- max_freq = all_avail_freq[-1]
- # Calculate the frequency we are targeting.
- target_freq = round(max_freq * freq_percent / 100)
- # More likely it's not in the list of supported frequencies
- # and our goal is to find the one which is less or equal.
- # Default is min and we will try to maximize it.
- avail_ngt_target = min_freq
- # Find the largest not greater than the target.
- for next_largest in reversed(all_avail_freq):
- if next_largest <= target_freq:
- avail_ngt_target = next_largest
- break
-
- max_freq_path = avail_freq_path.replace('scaling_available_frequencies',
- 'scaling_max_freq')
- min_freq_path = avail_freq_path.replace('scaling_available_frequencies',
- 'scaling_min_freq')
- # With default ignore_status=False we expect 0 status or Fatal error.
- run_on_dut('echo %s | tee %s %s' % (avail_ngt_target, max_freq_path,
- min_freq_path))
-
- def DecreaseWaitTime(self, run_on_dut):
- """Change the ten seconds wait time for pagecycler to two seconds."""
- FILE = '/usr/local/telemetry/src/tools/perf/page_sets/page_cycler_story.py'
- ret = run_on_dut('ls ' + FILE)
-
- if not ret:
- sed_command = 'sed -i "s/_TTI_WAIT_TIME = 10/_TTI_WAIT_TIME = 2/g" '
- run_on_dut(sed_command + FILE)
-
- def RestartUI(self, machine_name, chromeos_root):
- command = 'stop ui; sleep 5; start ui'
- self._ce.CrosRunCommand(
- command, machine=machine_name, chromeos_root=chromeos_root)
+ run_on_dut.StopUI()
+ try:
+ yield
+
+ finally:
+ run_on_dut.StartUI()
+
+ def SetupDevice(self, run_on_dut, cros_machine):
+ # Pause UI while configuring the DUT.
+ # This will accelerate setup (waiting for cooldown has x10 drop)
+ # and help to reset a Chrome state left after the previous test.
+ with self.PauseUI(run_on_dut):
+ # Unless the user turns on ASLR in the flag, we first disable ASLR
+ # before running the benchmarks
+ if not self.dut_config['enable_aslr']:
+ run_on_dut.DisableASLR()
+
+ # CPU usage setup comes first where we enable/disable cores.
+ run_on_dut.SetupCpuUsage()
+ cpu_online_status = run_on_dut.GetCpuOnline()
+ # List of online cores of type int (core number).
+ online_cores = [
+ core for core, status in cpu_online_status.items() if status
+ ]
+ if self.dut_config['cooldown_time']:
+ # Setup power conservative mode for effective cool down.
+ # Set ignore status since powersave may no be available
+ # on all platforms and we are going to handle it.
+ ret = run_on_dut.SetCpuGovernor('powersave', ignore_status=True)
+ if ret:
+ # "powersave" is not available, use "ondemand".
+ # Still not a fatal error if it fails.
+ ret = run_on_dut.SetCpuGovernor('ondemand', ignore_status=True)
+ # TODO(denik): Run comparison test for 'powersave' and 'ondemand'
+ # on scarlet and kevin64.
+ # We might have to consider reducing freq manually to the min
+ # if it helps to reduce waiting time.
+ wait_time = run_on_dut.WaitCooldown()
+ cros_machine.AddCooldownWaitTime(wait_time)
+
+ # Setup CPU governor for the benchmark run.
+ # It overwrites the previous governor settings.
+ governor = self.dut_config['governor']
+ # FIXME(denik): Pass online cores to governor setup.
+ run_on_dut.SetCpuGovernor(governor, ignore_status=False)
+
+ # Disable Turbo and Setup CPU freq should ALWAYS proceed governor setup
+ # since governor may change:
+ # - frequency;
+ # - turbo/boost.
+ run_on_dut.DisableTurbo()
+ run_on_dut.SetupCpuFreq(online_cores)
+ # FIXME(denik): Currently we are not recovering the previous cpufreq
+ # settings since we do reboot/setup every time anyway.
+ # But it may change in the future and then we have to recover the
+ # settings.
def Test_That_Run(self, machine, label, benchmark, test_args, profiler_args):
"""Run the test_that test.."""
@@ -467,11 +188,6 @@ class SuiteRunner(object):
self._ce.CrosRunCommand(
command, machine=machine, chromeos_root=label.chromeos_root)
- # We do this because some tests leave the machine in weird states.
- # Rebooting between iterations has proven to help with this.
- # But the beep is anoying, we will try restart ui.
- self.RestartUI(machine, label.chromeos_root)
-
autotest_dir = AUTOTEST_DIR
if label.autotest_path != '':
autotest_dir = label.autotest_path
@@ -506,9 +222,10 @@ class SuiteRunner(object):
cp_command = '%s -mq cp -r %s %s' % (gsutil_cmd, result_dir, download_path)
# Server sometimes will not be able to generate the result directory right
- # after the test. Will try to access this gs location every 60s for 5 mins.
+ # after the test. Will try to access this gs location every 60s for
+ # RETRY_LIMIT mins.
t = 0
- RETRY_LIMIT = 5
+ RETRY_LIMIT = 10
while t < RETRY_LIMIT:
t += 1
status = self._ce.RunCommand(ls_command, print_to_console=False)
@@ -528,23 +245,20 @@ class SuiteRunner(object):
status = self._ce.RunCommand(cp_command)
if status != 0:
self.logger.LogOutput('Cannot download results from task %s' % task_id)
+ else:
+ self.logger.LogOutput('Result downloaded for task %s' % task_id)
return status
def Skylab_Run(self, label, benchmark, test_args, profiler_args):
"""Run the test via skylab.."""
- # Skylab by default uses cros_test_platform to start test.
- # We don't use it for now since we want to directly interact with dut.
- options = '-bb=false'
-
- if benchmark.suite != 'telemetry_Crosperf':
- options += ' -client-test'
+ options = ''
if label.board:
- options += ' -board=%s' % label.board
+ options += '-board=%s' % label.board
if label.build:
options += ' -image=%s' % label.build
- # TODO: now only put quota pool here, user need to be able to specify which
- # pool to use. Need to request feature to not use this option at all.
- options += ' -pool=DUT_POOL_QUOTA'
+ # TODO: now only put toolchain pool here, user need to be able to specify
+ # which pool to use. Need to request feature to not use this option at all.
+ options += ' -pool=toolchain'
if benchmark.suite == 'telemetry_Crosperf':
if test_args:
# Strip double quotes off args (so we can wrap them in single
@@ -567,7 +281,7 @@ class SuiteRunner(object):
for dut in label.remote:
dimensions += ' -dim dut_name:%s' % dut.rstrip('.cros')
- command = (('%s create-test %s %s %s') % \
+ command = (('%s create-test%s %s %s') % \
(SKYLAB_PATH, dimensions, options, benchmark.test_name))
if self.log_level != 'verbose':
@@ -580,17 +294,40 @@ class SuiteRunner(object):
return ret_tup
# Std output of the command will look like:
- # Created Swarming task https://chromeos-swarming.appspot.com/task?id=12345
- # We want to parse it and get the id number of the task.
- task_id = ret_tup[1].strip().split('id=')[1]
+ # Created request at https://ci.chromium.org/../cros_test_platform/b12345
+ # We want to parse it and get the id number of the task, which is the
+ # number in the very end of the link address.
+ task_id = ret_tup[1].strip().split('b')[-1]
- command = ('skylab wait-task -bb=false %s' % (task_id))
+ command = ('skylab wait-task %s' % task_id)
if self.log_level != 'verbose':
self.logger.LogOutput('Waiting for skylab test to finish.')
self.logger.LogOutput('CMD: %s' % command)
ret_tup = self._ce.RunCommandWOutput(command, command_terminator=self._ct)
- if '"success":true' in ret_tup[1]:
+
+ # The output of `wait-task` command will be a combination of verbose and a
+ # json format result in the end. The json result looks like this:
+ # {"task-result":
+ # {"name":"Test Platform Invocation",
+ # "state":"", "failure":false, "success":true,
+ # "task-run-id":"12345",
+ # "task-run-url":"https://ci.chromium.org/.../cros_test_platform/b12345",
+ # "task-logs-url":""
+ # },
+ # "stdout":"",
+ # "child-results":
+ # [{"name":"graphics_WebGLAquarium",
+ # "state":"", "failure":false, "success":true, "task-run-id":"",
+ # "task-run-url":"https://chromeos-swarming.appspot.com/task?id=1234",
+ # "task-logs-url":"https://stainless.corp.google.com/1234/"}
+ # ]
+ # }
+ # We need the task id of the child-results to download result.
+ output = json.loads(ret_tup[1].split('\n')[-1])
+ output = output['child-results'][0]
+ if output['success']:
+ task_id = output['task-run-url'].split('=')[-1]
if self.DownloadResult(label, task_id) == 0:
result_dir = '\nResults placed in tmp/swarming-%s\n' % task_id
return (ret_tup[0], result_dir, ret_tup[2])
@@ -631,11 +368,12 @@ class SuiteRunner(object):
args_string = "test_args='%s'" % test_args
top_interval = self.dut_config['top_interval']
+ turbostat = self.dut_config['turbostat']
cmd = ('{} {} {} --board={} --args="{} run_local={} test={} '
'turbostat={} top_interval={} {}" {} telemetry_Crosperf'.format(
TEST_THAT_PATH, autotest_dir_arg, fast_arg, label.board,
- args_string, benchmark.run_local, benchmark.test_name,
- benchmark.turbostat, top_interval, profiler_args, machine))
+ args_string, benchmark.run_local, benchmark.test_name, turbostat,
+ top_interval, profiler_args, machine))
# Use --no-ns-pid so that cros_sdk does not create a different
# process namespace and we can kill process created easily by their
diff --git a/crosperf/suite_runner_unittest.py b/crosperf/suite_runner_unittest.py
index 8b336eda..c2e33226 100755
--- a/crosperf/suite_runner_unittest.py
+++ b/crosperf/suite_runner_unittest.py
@@ -9,6 +9,7 @@
from __future__ import print_function
+import json
import os.path
import time
@@ -22,86 +23,15 @@ from benchmark import Benchmark
from cros_utils import command_executer
from cros_utils import logger
-
-BIG_LITTLE_CPUINFO = """processor : 0
-model name : ARMv8 Processor rev 4 (v8l)
-BogoMIPS : 48.00
-Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 8
-CPU variant : 0x0
-CPU part : 0xd03
-CPU revision : 4
-
-processor : 1
-model name : ARMv8 Processor rev 4 (v8l)
-BogoMIPS : 48.00
-Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 8
-CPU variant : 0x0
-CPU part : 0xd03
-CPU revision : 4
-
-processor : 2
-model name : ARMv8 Processor rev 2 (v8l)
-BogoMIPS : 48.00
-Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 8
-CPU variant : 0x0
-CPU part : 0xd08
-CPU revision : 2
-"""
-LITTLE_ONLY_CPUINFO = """processor : 0
-model name : ARMv8 Processor rev 4 (v8l)
-BogoMIPS : 48.00
-Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 8
-CPU variant : 0x0
-CPU part : 0xd03
-CPU revision : 4
-
-processor : 1
-model name : ARMv8 Processor rev 4 (v8l)
-BogoMIPS : 48.00
-Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 8
-CPU variant : 0x0
-CPU part : 0xd03
-CPU revision : 4
-"""
-
-NOT_BIG_LITTLE_CPUINFO = """processor : 0
-model name : ARMv7 Processor rev 1 (v7l)
-Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 7
-CPU variant : 0x0
-CPU part : 0xc0d
-CPU revision : 1
-
-processor : 1
-model name : ARMv7 Processor rev 1 (v7l)
-Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4
-CPU implementer : 0x41
-CPU architecture: 7
-CPU variant : 0x0
-CPU part : 0xc0d
-CPU revision : 1
-
-Hardware : Rockchip (Device Tree)
-Revision : 0000
-Serial : 0000000000000000
-"""
+from cros_utils.device_setup_utils import DutWrapper
+from machine_manager import MockCrosMachine
class SuiteRunnerTest(unittest.TestCase):
"""Class of SuiteRunner test."""
real_logger = logger.GetLogger()
+ mock_json = mock.Mock(spec=json)
mock_cmd_exec = mock.Mock(spec=command_executer.CommandExecuter)
mock_cmd_term = mock.Mock(spec=command_executer.CommandTerminator)
mock_logger = mock.Mock(spec=logger.Logger)
@@ -146,7 +76,6 @@ class SuiteRunnerTest(unittest.TestCase):
self.telemetry_crosperf_args = []
self.call_skylab_run = False
self.call_telemetry_crosperf_run = False
- self.call_disable_aslr = False
def setUp(self):
self.runner = suite_runner.SuiteRunner(
@@ -166,17 +95,11 @@ class SuiteRunnerTest(unittest.TestCase):
self.call_test_that_run = False
self.call_skylab_run = False
self.call_telemetry_crosperf_run = False
- self.call_disable_aslr = False
self.skylab_run_args = []
self.test_that_args = []
self.telemetry_run_args = []
self.telemetry_crosperf_args = []
- def FakeDisableASLR(runner):
- # pylint fix for unused variable.
- del runner
- self.call_disable_aslr = True
-
def FakeSkylabRun(test_label, benchmark, test_args, profiler_args):
self.skylab_run_args = [test_label, benchmark, test_args, profiler_args]
self.call_skylab_run = True
@@ -203,610 +126,146 @@ class SuiteRunnerTest(unittest.TestCase):
del command, ignore_status
return 0, '', ''
- self.runner.DisableASLR = FakeDisableASLR
self.runner.Skylab_Run = FakeSkylabRun
self.runner.Telemetry_Crosperf_Run = FakeTelemetryCrosperfRun
self.runner.Test_That_Run = FakeTestThatRun
- self.runner.SetupCpuUsage = mock.Mock()
- self.runner.SetupCpuFreq = mock.Mock()
- self.runner.DutWrapper = mock.Mock(return_value=FakeRunner)
- self.runner.DisableTurbo = mock.Mock()
- self.runner.SetCpuGovernor = mock.Mock()
- self.runner.WaitCooldown = mock.Mock(return_value=0)
- self.runner.GetCpuOnline = mock.Mock(return_value={0: 1, 1: 1, 2: 0})
+ self.runner.SetupDevice = mock.Mock()
+ DutWrapper.RunCommandOnDut = mock.Mock(return_value=FakeRunner)
+
+ self.runner.dut_config['enable_aslr'] = False
self.runner.dut_config['cooldown_time'] = 0
self.runner.dut_config['governor'] = 'fake_governor'
self.runner.dut_config['cpu_freq_pct'] = 65
machine = 'fake_machine'
+ cros_machine = MockCrosMachine(machine, self.mock_label.chromeos_root,
+ self.mock_logger)
test_args = ''
profiler_args = ''
reset()
self.mock_label.skylab = True
- self.runner.Run(machine, self.mock_label, self.telemetry_bench, test_args,
- profiler_args)
- self.assertFalse(self.call_disable_aslr)
+ self.runner.Run(cros_machine, self.mock_label, self.telemetry_bench,
+ test_args, profiler_args)
self.assertTrue(self.call_skylab_run)
self.assertFalse(self.call_test_that_run)
self.assertFalse(self.call_telemetry_crosperf_run)
self.assertEqual(self.skylab_run_args,
[self.mock_label, self.telemetry_bench, '', ''])
- self.runner.SetupCpuUsage.assert_not_called()
- self.runner.SetupCpuFreq.assert_not_called()
- self.runner.GetCpuOnline.assert_not_called()
- self.runner.DutWrapper.assert_not_called()
- self.runner.SetCpuGovernor.assert_not_called()
- self.runner.DisableTurbo.assert_not_called()
- self.runner.WaitCooldown.assert_not_called()
+ self.runner.SetupDevice.assert_not_called()
self.mock_label.skylab = False
reset()
- self.runner.Run(machine, self.mock_label, self.test_that_bench, test_args,
- profiler_args)
- self.assertTrue(self.call_disable_aslr)
+ self.runner.Run(cros_machine, self.mock_label, self.test_that_bench,
+ test_args, profiler_args)
self.assertTrue(self.call_test_that_run)
self.assertFalse(self.call_telemetry_crosperf_run)
self.assertEqual(
self.test_that_args,
['fake_machine', self.mock_label, self.test_that_bench, '', ''])
- self.runner.SetupCpuUsage.assert_called_once_with(FakeRunner)
- self.runner.SetupCpuFreq.assert_called_once_with(FakeRunner, [0, 1])
- self.runner.GetCpuOnline.assert_called_once_with(FakeRunner)
- self.runner.DutWrapper.assert_called_once_with(
- machine, self.mock_label.chromeos_root)
- self.runner.SetCpuGovernor.assert_called_once_with(
- 'fake_governor', FakeRunner, ignore_status=False)
- self.runner.DisableTurbo.assert_called_once_with(FakeRunner)
- self.runner.WaitCooldown.assert_not_called()
reset()
- self.runner.Run(machine, self.mock_label, self.telemetry_crosperf_bench,
- test_args, profiler_args)
- self.assertTrue(self.call_disable_aslr)
+ self.runner.Run(cros_machine, self.mock_label,
+ self.telemetry_crosperf_bench, test_args, profiler_args)
self.assertFalse(self.call_test_that_run)
self.assertTrue(self.call_telemetry_crosperf_run)
self.assertEqual(self.telemetry_crosperf_args, [
'fake_machine', self.mock_label, self.telemetry_crosperf_bench, '', ''
])
- self.runner.DutWrapper.assert_called_with(machine,
- self.mock_label.chromeos_root)
- def test_run_with_cooldown(self):
+ def test_setup_device(self):
def FakeRunner(command, ignore_status=False):
# pylint fix for unused variable.
del command, ignore_status
return 0, '', ''
- self.runner.DisableASLR = mock.Mock()
- self.runner.DutWrapper = mock.Mock(return_value=FakeRunner)
- self.runner.DisableTurbo = mock.Mock()
- self.runner.SetCpuGovernor = mock.Mock()
- self.runner.SetupCpuUsage = mock.Mock()
- self.runner.SetupCpuFreq = mock.Mock()
- self.runner.WaitCooldown = mock.Mock(return_value=0)
- self.runner.GetCpuOnline = mock.Mock(return_value={0: 0, 1: 1})
- self.runner.Telemetry_Crosperf_Run = mock.Mock(return_value=(0, '', ''))
- self.runner.dut_config['cooldown_time'] = 10
- self.runner.dut_config['governor'] = 'fake_governor'
- self.runner.dut_config['cpu_freq_pct'] = 75
-
- self.runner.Run('fake_machine', self.mock_label,
- self.telemetry_crosperf_bench, '', '')
-
- self.runner.WaitCooldown.assert_called_once_with(FakeRunner)
- self.runner.DisableASLR.assert_called_once()
- self.runner.Telemetry_Crosperf_Run.assert_called_once()
- self.runner.DisableTurbo.assert_called_once_with(FakeRunner)
- self.runner.SetupCpuUsage.assert_called_once_with(FakeRunner)
- self.runner.SetupCpuFreq.assert_called_once_with(FakeRunner, [1])
- self.runner.SetCpuGovernor.assert_called()
- self.runner.GetCpuOnline.assert_called_once_with(FakeRunner)
- self.assertGreater(self.runner.SetCpuGovernor.call_count, 1)
- self.assertEqual(
- self.runner.SetCpuGovernor.call_args,
- mock.call('fake_governor', FakeRunner, ignore_status=False))
-
- @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
- def test_dut_wrapper(self, mock_cros_runcmd):
- self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
- mock_cros_runcmd.return_value = (0, '', '')
- run_on_dut = self.runner.DutWrapper('lumpy.cros2', '/tmp/chromeos')
- mock_cros_runcmd.assert_not_called()
- run_on_dut('run command;')
- mock_cros_runcmd.assert_called_once_with(
- 'run command;', chromeos_root='/tmp/chromeos', machine='lumpy.cros2')
-
- @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
- def test_dut_wrapper_fatal_error(self, mock_cros_runcmd):
- self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
- # Command returns error 1.
- mock_cros_runcmd.return_value = (1, '', 'Error!')
- run_on_dut = self.runner.DutWrapper('lumpy.cros2', '/tmp/chromeos')
- mock_cros_runcmd.assert_not_called()
- run_on_dut('run command;')
- mock_cros_runcmd.assert_called_once_with(
- 'run command;', chromeos_root='/tmp/chromeos', machine='lumpy.cros2')
- # Error status causes log fatal.
- self.assertEqual(
- self.mock_logger.method_calls[-1],
- mock.call.LogFatal('Command execution on DUT lumpy.cros2 failed.\n'
- 'Failing command: run command;\nreturned 1\n'
- 'Error message: Error!'))
-
- @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
- def test_dut_wrapper_ignore_error(self, mock_cros_runcmd):
- self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
- # Command returns error 1.
- mock_cros_runcmd.return_value = (1, '', 'Error!')
- run_on_dut = self.runner.DutWrapper('lumpy.cros2', '/tmp/chromeos')
- run_on_dut('run command;', ignore_status=True)
- mock_cros_runcmd.assert_called_once_with(
- 'run command;', chromeos_root='/tmp/chromeos', machine='lumpy.cros2')
- # Error status is not fatal. LogError records the error message.
- self.assertEqual(
- self.mock_logger.method_calls[-1],
- mock.call.LogError('Command execution on DUT lumpy.cros2 failed.\n'
- 'Failing command: run command;\nreturned 1\n'
- 'Error message: Error!\n'
- '(Failure is considered non-fatal. Continue.)'))
-
- def test_disable_aslr(self):
- run_on_dut = mock.Mock()
- self.runner.DisableASLR(run_on_dut)
- # pyformat: disable
- set_cpu_cmd = ('set -e && '
- 'stop ui; '
- 'if [[ -e /proc/sys/kernel/randomize_va_space ]]; then '
- ' echo 0 > /proc/sys/kernel/randomize_va_space; '
- 'fi; '
- 'start ui ')
- run_on_dut.assert_called_once_with(set_cpu_cmd)
-
- def test_set_cpu_governor(self):
- dut_runner = mock.Mock(return_value=(0, '', ''))
- self.runner.SetCpuGovernor('new_governor', dut_runner, ignore_status=False)
- set_cpu_cmd = (
- 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
- # Skip writing scaling_governor if cpu is not online.
- ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
- ' && continue; '
- ' cd $f; '
- ' if [[ -e scaling_governor ]]; then '
- ' echo %s > scaling_governor; fi; '
- 'done; ')
- dut_runner.assert_called_once_with(
- set_cpu_cmd % 'new_governor', ignore_status=False)
-
- def test_set_cpu_governor_propagate_error(self):
- dut_runner = mock.Mock(return_value=(1, '', 'Error.'))
- self.runner.SetCpuGovernor('non-exist_governor', dut_runner)
- set_cpu_cmd = (
- 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
- # Skip writing scaling_governor if cpu is not online.
- ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
- ' && continue; '
- ' cd $f; '
- ' if [[ -e scaling_governor ]]; then '
- ' echo %s > scaling_governor; fi; '
- 'done; ')
- # By default error status is fatal.
- dut_runner.assert_called_once_with(
- set_cpu_cmd % 'non-exist_governor', ignore_status=False)
-
- def test_set_cpu_governor_ignore_status(self):
- dut_runner = mock.Mock(return_value=(1, '', 'Error.'))
- ret_code = self.runner.SetCpuGovernor(
- 'non-exist_governor', dut_runner, ignore_status=True)
- set_cpu_cmd = (
- 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do '
- # Skip writing scaling_governor if cpu is not online.
- ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} '
- ' && continue; '
- ' cd $f; '
- ' if [[ -e scaling_governor ]]; then '
- ' echo %s > scaling_governor; fi; '
- 'done; ')
- dut_runner.assert_called_once_with(
- set_cpu_cmd % 'non-exist_governor', ignore_status=True)
- self.assertEqual(ret_code, 1)
-
- def test_disable_turbo(self):
- dut_runner = mock.Mock(return_value=(0, '', ''))
- self.runner.DisableTurbo(dut_runner)
- set_cpu_cmd = (
- # Disable Turbo in Intel pstate driver
- 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then '
- ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then '
- ' echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo; '
- ' fi; '
- 'fi; ')
- dut_runner.assert_called_once_with(set_cpu_cmd)
-
- def test_get_cpu_online_two(self):
- """Test one digit CPU #."""
- dut_runner = mock.Mock(
- return_value=(0, '/sys/devices/system/cpu/cpu0/online 0\n'
- '/sys/devices/system/cpu/cpu1/online 1\n', ''))
- cpu_online = self.runner.GetCpuOnline(dut_runner)
- self.assertEqual(cpu_online, {0: 0, 1: 1})
-
- def test_get_cpu_online_twelve(self):
- """Test two digit CPU #."""
- dut_runner = mock.Mock(
- return_value=(0, '/sys/devices/system/cpu/cpu0/online 1\n'
- '/sys/devices/system/cpu/cpu1/online 0\n'
- '/sys/devices/system/cpu/cpu10/online 1\n'
- '/sys/devices/system/cpu/cpu11/online 1\n'
- '/sys/devices/system/cpu/cpu2/online 1\n'
- '/sys/devices/system/cpu/cpu3/online 0\n'
- '/sys/devices/system/cpu/cpu4/online 1\n'
- '/sys/devices/system/cpu/cpu5/online 0\n'
- '/sys/devices/system/cpu/cpu6/online 1\n'
- '/sys/devices/system/cpu/cpu7/online 0\n'
- '/sys/devices/system/cpu/cpu8/online 1\n'
- '/sys/devices/system/cpu/cpu9/online 0\n', ''))
- cpu_online = self.runner.GetCpuOnline(dut_runner)
- self.assertEqual(cpu_online, {
- 0: 1,
- 1: 0,
- 2: 1,
- 3: 0,
- 4: 1,
- 5: 0,
- 6: 1,
- 7: 0,
- 8: 1,
- 9: 0,
- 10: 1,
- 11: 1
- })
-
- def test_get_cpu_online_no_output(self):
- """Test error case, no output."""
- dut_runner = mock.Mock(return_value=(0, '', ''))
- with self.assertRaises(AssertionError):
- self.runner.GetCpuOnline(dut_runner)
-
- def test_get_cpu_online_command_error(self):
- """Test error case, command error."""
- dut_runner = mock.Mock(side_effect=AssertionError)
- with self.assertRaises(AssertionError):
- self.runner.GetCpuOnline(dut_runner)
-
- @mock.patch.object(suite_runner.SuiteRunner, 'SetupArmCores')
- def test_setup_cpu_usage_little_on_arm(self, mock_setup_arm):
- self.runner.SetupArmCores = mock_setup_arm
- dut_runner = mock.Mock(return_value=(0, 'armv7l', ''))
- self.runner.dut_config['cpu_usage'] = 'little_only'
- self.runner.SetupCpuUsage(dut_runner)
- self.runner.SetupArmCores.assert_called_once_with(dut_runner)
-
- @mock.patch.object(suite_runner.SuiteRunner, 'SetupArmCores')
- def test_setup_cpu_usage_big_on_aarch64(self, mock_setup_arm):
- self.runner.SetupArmCores = mock_setup_arm
- dut_runner = mock.Mock(return_value=(0, 'aarch64', ''))
- self.runner.dut_config['cpu_usage'] = 'big_only'
- self.runner.SetupCpuUsage(dut_runner)
- self.runner.SetupArmCores.assert_called_once_with(dut_runner)
-
- @mock.patch.object(suite_runner.SuiteRunner, 'SetupArmCores')
- def test_setup_cpu_usage_big_on_intel(self, mock_setup_arm):
- self.runner.SetupArmCores = mock_setup_arm
- dut_runner = mock.Mock(return_value=(0, 'x86_64', ''))
- self.runner.dut_config['cpu_usage'] = 'big_only'
- self.runner.SetupCpuUsage(dut_runner)
- # Check that SetupArmCores not called with invalid setup.
- self.runner.SetupArmCores.assert_not_called()
-
- @mock.patch.object(suite_runner.SuiteRunner, 'SetupArmCores')
- def test_setup_cpu_usage_all_on_intel(self, mock_setup_arm):
- self.runner.SetupArmCores = mock_setup_arm
- dut_runner = mock.Mock(return_value=(0, 'x86_64', ''))
- self.runner.dut_config['cpu_usage'] = 'all'
- self.runner.SetupCpuUsage(dut_runner)
- # Check that SetupArmCores not called in general case.
- self.runner.SetupArmCores.assert_not_called()
-
- def test_setup_arm_cores_big_on_big_little(self):
- dut_runner = mock.Mock(side_effect=[
- (0, BIG_LITTLE_CPUINFO, ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_usage'] = 'big_only'
- self.runner.SetupArmCores(dut_runner)
- dut_runner.assert_called_with(
- 'echo 1 | tee /sys/devices/system/cpu/cpu{2}/online; '
- 'echo 0 | tee /sys/devices/system/cpu/cpu{0,1}/online')
-
- def test_setup_arm_cores_little_on_big_little(self):
- dut_runner = mock.Mock(side_effect=[
- (0, BIG_LITTLE_CPUINFO, ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_usage'] = 'little_only'
- self.runner.SetupArmCores(dut_runner)
- dut_runner.assert_called_with(
- 'echo 1 | tee /sys/devices/system/cpu/cpu{0,1}/online; '
- 'echo 0 | tee /sys/devices/system/cpu/cpu{2}/online')
-
- def test_setup_arm_cores_invalid_config(self):
- dut_runner = mock.Mock(side_effect=[
- (0, LITTLE_ONLY_CPUINFO, ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_usage'] = 'big_only'
- self.runner.SetupArmCores(dut_runner)
- # Check that setup command is not sent when trying
- # to use 'big_only' on a platform with all little cores.
- dut_runner.assert_called_once_with('cat /proc/cpuinfo')
-
- def test_setup_arm_cores_not_big_little(self):
- dut_runner = mock.Mock(side_effect=[
- (0, NOT_BIG_LITTLE_CPUINFO, ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_usage'] = 'big_only'
- self.runner.SetupArmCores(dut_runner)
- # Check that setup command is not sent when trying
- # to use 'big_only' on a platform w/o support of big/little.
- dut_runner.assert_called_once_with('cat /proc/cpuinfo')
-
- def test_setup_arm_cores_unsupported_cpu_usage(self):
- dut_runner = mock.Mock(side_effect=[
- (0, BIG_LITTLE_CPUINFO, ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_usage'] = 'exclusive_cores'
- self.runner.SetupArmCores(dut_runner)
- # Check that setup command is not sent when trying to use
- # 'exclusive_cores' on ARM CPU setup.
- dut_runner.assert_called_once_with('cat /proc/cpuinfo')
-
- def test_setup_cpu_freq_single_full(self):
- online = [0]
- dut_runner = mock.Mock(side_effect=[
- (0,
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n',
- ''),
- (0, '1 2 3 4 5 6 7 8 9 10', ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_freq_pct'] = 100
- self.runner.SetupCpuFreq(dut_runner, online)
- self.assertGreaterEqual(dut_runner.call_count, 3)
- self.assertEqual(
- dut_runner.call_args,
- mock.call('echo 10 | tee '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
-
- def test_setup_cpu_freq_middle(self):
- online = [0]
- dut_runner = mock.Mock(side_effect=[
- (0,
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n',
- ''),
- (0, '1 2 3 4 5 6 7 8 9 10', ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_freq_pct'] = 60
- self.runner.SetupCpuFreq(dut_runner, online)
- self.assertGreaterEqual(dut_runner.call_count, 2)
- self.assertEqual(
- dut_runner.call_args,
- mock.call('echo 6 | tee '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
-
- def test_setup_cpu_freq_lowest(self):
- online = [0]
- dut_runner = mock.Mock(side_effect=[
- (0,
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n',
- ''),
- (0, '1 2 3 4 5 6 7 8 9 10', ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_freq_pct'] = 0
- self.runner.SetupCpuFreq(dut_runner, online)
- self.assertGreaterEqual(dut_runner.call_count, 2)
- self.assertEqual(
- dut_runner.call_args,
- mock.call('echo 1 | tee '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
-
- def test_setup_cpu_freq_multiple_middle(self):
- online = [0, 1]
- dut_runner = mock.Mock(side_effect=[
- (0,
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n'
- '/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n',
- ''),
- (0, '1 2 3 4 5 6 7 8 9 10', ''),
- (0, '', ''),
- (0, '1 4 6 8 10 12 14 16 18 20', ''),
- (0, '', ''),
- ])
- self.runner.dut_config['cpu_freq_pct'] = 70
- self.runner.SetupCpuFreq(dut_runner, online)
- self.assertEqual(dut_runner.call_count, 5)
- self.assertEqual(
- dut_runner.call_args_list[2],
- mock.call('echo 7 | tee '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq '
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq'))
- self.assertEqual(
- dut_runner.call_args_list[4],
- mock.call('echo 14 | tee '
- '/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq '
- '/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq'))
-
- def test_setup_cpu_freq_no_scaling_available(self):
- online = [0, 1]
- dut_runner = mock.Mock(return_value=(2, '', 'No such file or directory'))
- self.runner.dut_config['cpu_freq_pct'] = 50
- self.runner.SetupCpuFreq(dut_runner, online)
- dut_runner.assert_called_once()
- self.assertNotRegexpMatches(dut_runner.call_args_list[0][0][0],
- '^echo.*scaling_max_freq$')
-
- def test_setup_cpu_freq_multiple_no_access(self):
- online = [0, 1]
- dut_runner = mock.Mock(side_effect=[
- (0,
- '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies\n'
- '/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies\n',
- ''),
- (0, '1 4 6 8 10 12 14 16 18 20', ''),
- AssertionError(),
- ])
- self.runner.dut_config['cpu_freq_pct'] = 30
- # Error status causes log fatal.
- with self.assertRaises(AssertionError):
- self.runner.SetupCpuFreq(dut_runner, online)
+ machine = 'fake_machine'
+ mock_run_on_dut = mock.Mock(spec=DutWrapper)
+ cros_machine = MockCrosMachine(machine, self.mock_label.chromeos_root,
+ self.mock_logger)
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_nowait(self, mock_sleep):
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(return_value=(0, '39000', ''))
- self.runner.dut_config['cooldown_time'] = 10
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- # Send command to DUT only once to check temperature
- # and make sure it does not exceed the threshold.
- dut_runner.assert_called_once()
- mock_sleep.assert_not_called()
- self.assertEqual(wait_time, 0)
+ mock_run_on_dut.RunCommandOnDut = mock.Mock(return_value=FakeRunner)
+ mock_run_on_dut.WaitCooldown = mock.Mock(return_value=0)
+ mock_run_on_dut.GetCpuOnline = mock.Mock(return_value={0: 1, 1: 1, 2: 0})
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_needwait_once(self, mock_sleep):
- """Wait one iteration for cooldown.
-
- Set large enough timeout and changing temperature
- output. Make sure it exits when expected value
- received.
- Expect that WaitCooldown check temp twice.
- """
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(side_effect=[(0, '41000', ''), (0, '39999', '')])
- self.runner.dut_config['cooldown_time'] = 100
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- dut_runner.assert_called()
- self.assertEqual(dut_runner.call_count, 2)
- mock_sleep.assert_called()
- self.assertGreater(wait_time, 0)
+ self.runner.dut_config['enable_aslr'] = False
+ self.runner.dut_config['cooldown_time'] = 0
+ self.runner.dut_config['governor'] = 'fake_governor'
+ self.runner.dut_config['cpu_freq_pct'] = 65
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_needwait(self, mock_sleep):
- """Test exit by timeout.
+ self.runner.SetupDevice(mock_run_on_dut, cros_machine)
- Send command to DUT checking the temperature and
- check repeatedly until timeout goes off.
- Output from temperature sensor never changes.
- """
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(return_value=(0, '41000', ''))
- self.runner.dut_config['cooldown_time'] = 60
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- dut_runner.assert_called()
- self.assertGreater(dut_runner.call_count, 2)
- mock_sleep.assert_called()
- self.assertGreater(wait_time, 0)
+ mock_run_on_dut.SetupCpuUsage.assert_called_once_with()
+ mock_run_on_dut.SetupCpuFreq.assert_called_once_with([0, 1])
+ mock_run_on_dut.GetCpuOnline.assert_called_once_with()
+ mock_run_on_dut.SetCpuGovernor.assert_called_once_with(
+ 'fake_governor', ignore_status=False)
+ mock_run_on_dut.DisableTurbo.assert_called_once_with()
+ mock_run_on_dut.StopUI.assert_called_once_with()
+ mock_run_on_dut.StartUI.assert_called_once_with()
+ mock_run_on_dut.WaitCooldown.assert_not_called()
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_needwait_multtemp(self, mock_sleep):
- """Wait until all temps go down.
-
- Set large enough timeout and changing temperature
- output. Make sure it exits when expected value
- for all temperatures received.
- Expect 3 checks.
- """
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(side_effect=[
- (0, '41000\n20000\n30000\n45000', ''),
- (0, '39000\n20000\n30000\n41000', ''),
- (0, '39000\n20000\n30000\n31000', ''),
- ])
- self.runner.dut_config['cooldown_time'] = 100
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- dut_runner.assert_called()
- self.assertEqual(dut_runner.call_count, 3)
- mock_sleep.assert_called()
- self.assertGreater(wait_time, 0)
+ def test_setup_device_with_cooldown(self):
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_thermal_error(self, mock_sleep):
- """Handle error status.
+ def FakeRunner(command, ignore_status=False):
+ # pylint fix for unused variable.
+ del command, ignore_status
+ return 0, '', ''
- Any error should be considered non-fatal.
- """
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(side_effect=[
- (1, '39000\n20000\n30000\n41000', 'Thermal error'),
- (1, '39000\n20000\n30000\n31000', 'Thermal error'),
- ])
- self.runner.dut_config['cooldown_time'] = 10
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- # Check that errors are ignored.
- dut_runner.assert_called_with(
- 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
- self.assertEqual(dut_runner.call_count, 2)
- # Check that we are waiting even when an error is returned
- # as soon as data is coming.
- mock_sleep.assert_called()
- self.assertGreater(wait_time, 0)
+ machine = 'fake_machine'
+ mock_run_on_dut = mock.Mock(spec=DutWrapper)
+ cros_machine = MockCrosMachine(machine, self.mock_label.chromeos_root,
+ self.mock_logger)
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_thermal_no_output(self, mock_sleep):
- """Handle no output.
+ mock_run_on_dut.RunCommandOnDut = mock.Mock(return_value=FakeRunner)
+ mock_run_on_dut.WaitCooldown = mock.Mock(return_value=0)
+ mock_run_on_dut.GetCpuOnline = mock.Mock(return_value={0: 0, 1: 1})
- Check handling of empty stdout.
- """
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(side_effect=[(1, '', 'Thermal error')])
+ self.runner.dut_config['enable_aslr'] = False
self.runner.dut_config['cooldown_time'] = 10
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- # Check that errors are ignored.
- dut_runner.assert_called_once_with(
- 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
- # No wait.
- mock_sleep.assert_not_called()
- self.assertEqual(wait_time, 0)
+ self.runner.dut_config['governor'] = 'fake_governor'
+ self.runner.dut_config['cpu_freq_pct'] = 75
- @mock.patch.object(time, 'sleep')
- def test_wait_cooldown_thermal_ws_output(self, mock_sleep):
- """Handle whitespace output.
+ self.runner.SetupDevice(mock_run_on_dut, cros_machine)
- Check handling of whitespace only.
- """
- mock_sleep.return_value = 0
- dut_runner = mock.Mock(side_effect=[(1, '\n', 'Thermal error')])
- self.runner.dut_config['cooldown_time'] = 10
- self.runner.dut_config['cooldown_temp'] = 40
- wait_time = self.runner.WaitCooldown(dut_runner)
- # Check that errors are ignored.
- dut_runner.assert_called_once_with(
- 'cat /sys/class/thermal/thermal_zone*/temp', ignore_status=True)
- # No wait.
- mock_sleep.assert_not_called()
- self.assertEqual(wait_time, 0)
+ mock_run_on_dut.WaitCooldown.assert_called_once_with()
+ mock_run_on_dut.DisableASLR.assert_called_once()
+ mock_run_on_dut.DisableTurbo.assert_called_once_with()
+ mock_run_on_dut.SetupCpuUsage.assert_called_once_with()
+ mock_run_on_dut.SetupCpuFreq.assert_called_once_with([1])
+ mock_run_on_dut.SetCpuGovernor.assert_called()
+ mock_run_on_dut.GetCpuOnline.assert_called_once_with()
+ mock_run_on_dut.StopUI.assert_called_once_with()
+ mock_run_on_dut.StartUI.assert_called_once_with()
+ self.assertGreater(mock_run_on_dut.SetCpuGovernor.call_count, 1)
+ self.assertEqual(mock_run_on_dut.SetCpuGovernor.call_args,
+ mock.call('fake_governor', ignore_status=False))
- @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommand')
- def test_restart_ui(self, mock_cros_runcmd):
- self.mock_cmd_exec.CrosRunCommand = mock_cros_runcmd
- self.runner.RestartUI('lumpy1.cros', '/tmp/chromeos')
- mock_cros_runcmd.assert_called_once_with(
- 'stop ui; sleep 5; start ui',
- chromeos_root='/tmp/chromeos',
- machine='lumpy1.cros')
+ def test_setup_device_with_exception(self):
+ """Test SetupDevice with an exception."""
+
+ machine = 'fake_machine'
+ mock_run_on_dut = mock.Mock(spec=DutWrapper)
+ cros_machine = MockCrosMachine(machine, self.mock_label.chromeos_root,
+ self.mock_logger)
+
+ mock_run_on_dut.SetupCpuUsage = mock.Mock(side_effect=RuntimeError())
+ self.runner.dut_config['enable_aslr'] = False
+
+ with self.assertRaises(RuntimeError):
+ self.runner.SetupDevice(mock_run_on_dut, cros_machine)
+
+ # This called injected an exception.
+ mock_run_on_dut.SetupCpuUsage.assert_called_once_with()
+ # Calls following the expeption are skipped.
+ mock_run_on_dut.WaitCooldown.assert_not_called()
+ mock_run_on_dut.DisableTurbo.assert_not_called()
+ mock_run_on_dut.SetupCpuFreq.assert_not_called()
+ mock_run_on_dut.SetCpuGovernor.assert_not_called()
+ mock_run_on_dut.GetCpuOnline.assert_not_called()
+ # Check that Stop/Start UI are always called.
+ mock_run_on_dut.StopUI.assert_called_once_with()
+ mock_run_on_dut.StartUI.assert_called_once_with()
@mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommand')
@mock.patch.object(command_executer.CommandExecuter,
@@ -834,7 +293,7 @@ class SuiteRunnerTest(unittest.TestCase):
self.mock_cmd_exec.CrosRunCommand = mock_cros_runcmd
res = self.runner.Test_That_Run('lumpy1.cros', self.mock_label,
self.test_that_bench, '--iterations=2', '')
- self.assertEqual(mock_cros_runcmd.call_count, 2)
+ self.assertEqual(mock_cros_runcmd.call_count, 1)
self.assertEqual(mock_chroot_runcmd.call_count, 1)
self.assertEqual(res, 0)
self.assertEqual(mock_cros_runcmd.call_args_list[0][0],
@@ -859,6 +318,7 @@ class SuiteRunnerTest(unittest.TestCase):
self.mock_cmd_exec.ChrootRunCommandWOutput = mock_chroot_runcmd
profiler_args = ("--profiler=custom_perf --profiler_args='perf_options"
'="record -a -e cycles,instructions"\'')
+ self.runner.dut_config['turbostat'] = True
self.runner.dut_config['top_interval'] = 3
res = self.runner.Telemetry_Crosperf_Run('lumpy1.cros', self.mock_label,
self.telemetry_crosperf_bench, '',
@@ -883,7 +343,8 @@ class SuiteRunnerTest(unittest.TestCase):
self.assertEqual(len(args_dict), 2)
@mock.patch.object(command_executer.CommandExecuter, 'RunCommandWOutput')
- def test_skylab_run(self, mock_runcmd):
+ @mock.patch.object(json, 'loads')
+ def test_skylab_run(self, mock_json_loads, mock_runcmd):
def FakeDownloadResult(l, task_id):
if l and task_id:
@@ -892,9 +353,18 @@ class SuiteRunnerTest(unittest.TestCase):
mock_runcmd.return_value = \
(0,
- '"success":true\nCreated Swarming task https://swarming/task?id=12345',
+ 'Created Swarming task https://swarming/task/b12345',
'')
self.mock_cmd_exec.RunCommandWOutput = mock_runcmd
+
+ mock_json_loads.return_value = {
+ 'child-results': [{
+ 'success': True,
+ 'task-run-url': 'https://swarming/task?id=12345'
+ }]
+ }
+ self.mock_json.loads = mock_json_loads
+
self.mock_label.skylab = True
self.runner.DownloadResult = FakeDownloadResult
res = self.runner.Skylab_Run(self.mock_label, self.test_that_bench, '', '')
@@ -905,14 +375,14 @@ class SuiteRunnerTest(unittest.TestCase):
args_list = mock_runcmd.call_args_list[0][0]
args_dict = mock_runcmd.call_args_list[0][1]
self.assertEqual(args_list[0],
- ('/usr/local/bin/skylab create-test '
+ ('/usr/local/bin/skylab create-test '
'-dim dut_name:lumpy1 -dim dut_name:lumpy.cros2 '
- '-bb=false -client-test -board=lumpy -image=build '
- '-pool=DUT_POOL_QUOTA octane'))
+ '-board=lumpy -image=build '
+ '-pool=toolchain octane'))
self.assertEqual(args_dict['command_terminator'], self.mock_cmd_term)
args_list = mock_runcmd.call_args_list[1][0]
- self.assertEqual(args_list[0], ('skylab wait-task -bb=false 12345'))
+ self.assertEqual(args_list[0], ('skylab wait-task 12345'))
self.assertEqual(args_dict['command_terminator'], self.mock_cmd_term)
@mock.patch.object(time, 'sleep')
diff --git a/crosperf/translate_xbuddy.py b/crosperf/translate_xbuddy.py
index a32854e1..20fcc704 100644
--- a/crosperf/translate_xbuddy.py
+++ b/crosperf/translate_xbuddy.py
@@ -6,7 +6,7 @@ import os
import sys
if '/mnt/host/source/src/third_party/toolchain-utils/crosperf' in sys.path:
- dev_path = os.path.expanduser('~/trunk/src/platform/dev')
+ dev_path = os.path.expanduser('~/trunk/chromite/lib/xbuddy')
sys.path.append(dev_path)
else:
print('This script can only be run from inside a ChromeOS chroot. Please '
@@ -20,8 +20,8 @@ import xbuddy
def Main(xbuddy_string):
if not os.path.exists('./xbuddy_config.ini'):
- config_path = os.path.expanduser('~/trunk/src/platform/dev/'
- 'xbuddy_config.ini')
+ config_path = os.path.expanduser(
+ '~/trunk/chromite/lib/xbuddy/xbuddy_config.ini')
os.symlink(config_path, './xbuddy_config.ini')
x = xbuddy.XBuddy(manage_builds=False, static_dir='/tmp/devserver/static')
build_id = x.Translate(os.path.split(xbuddy_string))
diff --git a/llvm_tools/README.md b/llvm_tools/README.md
index abf7a6f9..52bc263f 100644
--- a/llvm_tools/README.md
+++ b/llvm_tools/README.md
@@ -463,14 +463,6 @@ from get_llvm_hash import LLVMHash
LLVMHash().GetLLVMHash(<svn_version>)
```
-For example, to retrieve the commit message of a git hash of LLVM:
-
-```
-from get_llvm_hash import LLVMHash
-
-LLVMHash.GetCommitMessageForHash(<git_hash>)
-```
-
For example, to retrieve the latest google3 LLVM version:
```
diff --git a/llvm_tools/get_llvm_hash.py b/llvm_tools/get_llvm_hash.py
index 914bbfbf..01acbfaf 100755
--- a/llvm_tools/get_llvm_hash.py
+++ b/llvm_tools/get_llvm_hash.py
@@ -15,6 +15,7 @@ import shutil
import subprocess
import sys
import tempfile
+import git_llvm_rev
from contextlib import contextmanager
from subprocess_helpers import CheckCommand
@@ -28,6 +29,44 @@ _LLVM_GIT_URL = ('https://chromium.googlesource.com/external/github.com/llvm'
KNOWN_HASH_SOURCES = {'google3', 'google3-unstable', 'tot'}
+def GetVersionFrom(src_dir, git_hash):
+ """Obtain an SVN-style version number based on the LLVM git hash passed in.
+
+ Args:
+ git_hash: The git hash.
+
+ Returns:
+ An SVN-style version number associated with the git hash.
+ """
+
+ args = ['--llvm_dir', src_dir, '--sha', git_hash]
+ version = git_llvm_rev.main(args).strip()
+ assert version.startswith('r')
+ return int(version[1:])
+
+
+def GetGitHashFrom(src_dir, version):
+ """Finds the commit hash(es) of the LLVM version in the git log history.
+
+ Args:
+ src_dir: The LLVM source tree.
+ version: The version number.
+
+ Returns:
+ A git hash string corresponding to the version number.
+
+ Raises:
+ subprocess.CalledProcessError: Failed to find a git hash.
+ """
+
+ assert isinstance(version, int)
+ args = ['--llvm_dir', src_dir, '--rev', 'r' + str(version)]
+
+ git_hash = git_llvm_rev.main(args).rstrip()
+
+ return git_hash
+
+
@contextmanager
def CreateTempLLVMRepo(temp_dir):
"""Adds a LLVM worktree to 'temp_dir'.
@@ -134,18 +173,19 @@ def GetGoogle3LLVMVersion(stable):
"""
subdir = 'stable' if stable else 'llvm_unstable'
- path_to_google3_llvm_version = os.path.join(
- '/google/src/head/depot/google3/third_party/crosstool/v18', subdir,
- 'installs/llvm/revision')
# Cmd to get latest google3 LLVM version.
- cat_cmd = ['cat', path_to_google3_llvm_version]
+ cmd = [
+ 'cat',
+ os.path.join('/google/src/head/depot/google3/third_party/crosstool/v18',
+ subdir, 'installs/llvm/git_origin_rev_id')
+ ]
# Get latest version.
- g3_version = check_output(cat_cmd)
+ git_hash = check_output(cmd)
# Change type to an integer
- return int(g3_version.rstrip())
+ return GetVersionFrom(GetAndUpdateLLVMProjectInLLVMTools(), git_hash.strip())
def is_svn_option(svn_option):
@@ -192,24 +232,18 @@ def GetLLVMHashAndVersionFromSVNOption(svn_option):
# Determine which LLVM git hash to retrieve.
if svn_option == 'tot':
- llvm_hash = new_llvm_hash.GetTopOfTrunkGitHash()
-
- tot_commit_message = new_llvm_hash.GetCommitMessageForHash(llvm_hash)
-
- llvm_version = new_llvm_hash.GetSVNVersionFromCommitMessage(
- tot_commit_message)
+ git_hash = new_llvm_hash.GetTopOfTrunkGitHash()
+ version = GetVersionFrom(GetAndUpdateLLVMProjectInLLVMTools(), git_hash)
elif isinstance(svn_option, int):
- llvm_version = svn_option
- llvm_hash = new_llvm_hash.GetGitHashForVersion(
- GetAndUpdateLLVMProjectInLLVMTools(), llvm_version)
+ version = svn_option
+ git_hash = GetGitHashFrom(GetAndUpdateLLVMProjectInLLVMTools(), version)
else:
assert svn_option in ('google3', 'google3-unstable')
- llvm_version = GetGoogle3LLVMVersion(stable=svn_option == 'google3')
+ version = GetGoogle3LLVMVersion(stable=svn_option == 'google3')
- llvm_hash = new_llvm_hash.GetGitHashForVersion(
- GetAndUpdateLLVMProjectInLLVMTools(), llvm_version)
+ git_hash = GetGitHashFrom(GetAndUpdateLLVMProjectInLLVMTools(), version)
- return llvm_hash, llvm_version
+ return git_hash, version
class LLVMHash(object):
@@ -244,135 +278,17 @@ class LLVMHash(object):
if clone_cmd_obj.returncode:
raise ValueError('Failed to clone the LLVM repo: %s' % stderr)
- def GetCommitMessageForHash(self, git_hash):
- """Gets the commit message from the git hash.
-
- Args:
- git_hash: A git hash of LLVM.
-
- Returns:
- The commit message of the git hash.
-
- Raises:
- ValueError: Unable to retrieve json contents from the LLVM commit URL.
- """
-
- llvm_commit_url = ('https://api.github.com/repos/llvm/llvm-project/git/'
- 'commits/')
-
- commit_url = os.path.join(llvm_commit_url, git_hash)
-
- url_response = requests.get(commit_url)
-
- if not url_response:
- raise ValueError('Failed to get response from url %s: Status Code %d' %
- (commit_url, url_response.status_code))
-
- unicode_json_contents = url_response.json()
-
- return str(unicode_json_contents['message'])
-
- def GetSVNVersionFromCommitMessage(self, commit_message):
- """Gets the 'llvm-svn' from the commit message.
-
- A commit message may contain multiple 'llvm-svn' (reverting commits), so
- the last 'llvm-svn' is the real 'llvm-svn' for that commit message.
-
- Args:
- commit_message: A commit message that contains a 'llvm-svn:'.
-
- Returns:
- The last LLVM version as an integer or 'None' if there is no 'llvm-svn'.
- """
-
- # Find all "llvm-svn:" instances.
- llvm_versions = re.findall(r'llvm-svn: ([0-9]+)', commit_message)
-
- if llvm_versions:
- return int(llvm_versions[-1])
-
- return None
-
- def _ParseCommitMessages(self, subdir, hash_vals, llvm_version):
- """Parses the hashes that match the LLVM version.
-
- Args:
- subdir: The directory where the git history resides.
- hash_vals: All the hashes that match the LLVM version.
- llvm_version: The version to compare to in the commit message.
-
- Returns:
- The hash that matches the LLVM version.
-
- Raises:
- subprocess.CalledProcessError: Failed to retrieve the commit message body.
- ValueError: Failed to parse a commit message or did not find a commit
- hash.
- """
-
- # For each hash, grab the last "llvm-svn:" line
- # and compare the llvm version of that line against
- # the llvm version we are looking for and return
- # that hash only if they match.
- for cur_commit in hash_vals.splitlines():
- cur_hash = cur_commit.split()[0] # Get hash.
-
- # Cmd to output the commit body.
- find_llvm_cmd = [
- 'git', '-C', subdir, 'log', '--format=%B', '-n', '1', cur_hash
- ]
-
- out = check_output(find_llvm_cmd)
-
- commit_svn_version = self.GetSVNVersionFromCommitMessage(out.rstrip())
-
- # Check the svn version from the commit message against the llvm version
- # we are looking for.
- if commit_svn_version and commit_svn_version == llvm_version:
- return cur_hash
-
- # Failed to find the commit hash.
- raise ValueError('Could not find commit hash.')
-
- def GetGitHashForVersion(self, llvm_git_dir, llvm_version):
- """Finds the commit hash(es) of the LLVM version in the git log history.
-
- Args:
- llvm_git_dir: The LLVM git directory.
- llvm_version: The version to search for in the git log history.
-
- Returns:
- A string of the hash corresponding to the LLVM version.
-
- Raises:
- subprocess.CalledProcessError: Failed to retrieve git hashes that match
- 'llvm_version'.
- """
-
- # Get all the git hashes that match 'llvm_version'.
- hash_cmd = [
- 'git', '-C', llvm_git_dir, 'log', '--oneline', '--no-abbrev', '--grep',
- 'llvm-svn: %d' % llvm_version
- ]
-
- hash_vals = check_output(hash_cmd)
-
- return self._ParseCommitMessages(llvm_git_dir, hash_vals.rstrip(),
- llvm_version)
-
- def GetLLVMHash(self, llvm_version):
+ def GetLLVMHash(self, version):
"""Retrieves the LLVM hash corresponding to the LLVM version passed in.
Args:
- llvm_version: The LLVM version to use as a delimiter.
+ version: The LLVM version to use as a delimiter.
Returns:
The hash as a string that corresponds to the LLVM version.
"""
- hash_value = self.GetGitHashForVersion(GetAndUpdateLLVMProjectInLLVMTools(),
- llvm_version)
-
+ hash_value = GetGitHashFrom(GetAndUpdateLLVMProjectInLLVMTools(), version)
return hash_value
def GetGoogle3LLVMHash(self):
diff --git a/llvm_tools/get_llvm_hash_unittest.py b/llvm_tools/get_llvm_hash_unittest.py
index 895ee2b6..c828f433 100755
--- a/llvm_tools/get_llvm_hash_unittest.py
+++ b/llvm_tools/get_llvm_hash_unittest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@@ -8,13 +8,13 @@
from __future__ import print_function
+import get_llvm_hash
import subprocess
import unittest
+import unittest.mock as mock
+import test_helpers
-import get_llvm_hash
from get_llvm_hash import LLVMHash
-import mock
-import test_helpers
# We grab protected stuff from get_llvm_hash. That's OK.
# pylint: disable=protected-access
@@ -55,71 +55,17 @@ class TestGetLLVMHash(unittest.TestCase):
with self.assertRaises(ValueError) as err:
LLVMHash().CloneLLVMRepo('/tmp/tmp1')
- self.assertIn('Failed to clone', err.exception.message)
- self.assertIn('some stderr', err.exception.message)
-
- @mock.patch.object(subprocess, 'check_output')
- def testParseCommitMessageWithoutAHashFails(self, check_output_mock):
- check_output_mock.return_value = ('[Test] Test sentence.\n\n'
- 'A change was made.\n\n'
- 'llvm-svn: 1000')
-
- # Verify the exception is raised when failed to find the commit hash.
- with self.assertRaises(ValueError) as err:
- LLVMHash()._ParseCommitMessages('/tmp/tmpTest',
- 'a13testhash2 This is a test', 100)
+ self.assertIn('Failed to clone', str(err.exception.args))
+ self.assertIn('some stderr', str(err.exception.args))
- self.assertEqual(err.exception.message, 'Could not find commit hash.')
- check_output_mock.assert_called_once()
-
- @mock.patch.object(subprocess, 'check_output')
- def testParseCommitMessageIgnoresSVNMarkersInReverts(self, check_output_mock):
- output_messages = [
- '[Test] Test sentence.\n\n'
- 'A change was made.\n\n'
- 'llvm-svn: 1001',
- '[Revert] Reverted commit.\n\n'
- 'This reverts r1000:\n\n'
- ' [Test2] Update.\n\n'
- ' This updates stuff.\n\n'
- ' llvm-svn: 1000\n\n'
- 'llvm-svn: 58',
- '[Revert] Reverted commit.\n\n'
- 'This reverts r958:\n\n'
- ' [Test2] Update.\n\n'
- ' This updates stuff.\n\n'
- ' llvm-svn: 958\n\n'
- 'llvm-svn: 1000',
- ]
-
- @test_helpers.CallCountsToMockFunctions
- def MultipleCommitMessages(call_count, *_args, **_kwargs):
- return output_messages[call_count]
-
- check_output_mock.side_effect = MultipleCommitMessages
-
- hash_vals = ('a13testhash2 [Test] Test sentence.\n'
- 'a13testhash3 [Revert] Reverted commit.\n'
- 'a13testhash4 [Revert] Reverted commit.')
+ @mock.patch.object(get_llvm_hash, 'GetGitHashFrom')
+ def testGetGitHashWorks(self, mock_get_git_hash):
+ mock_get_git_hash.return_value = 'a13testhash2'
self.assertEqual(
- LLVMHash()._ParseCommitMessages('/tmp/tmpTest', hash_vals, 1000),
- 'a13testhash4')
+ get_llvm_hash.GetGitHashFrom('/tmp/tmpTest', 100), 'a13testhash2')
- self.assertEqual(check_output_mock.call_count, 3)
-
- @mock.patch.object(subprocess, 'check_output')
- @mock.patch.object(LLVMHash, '_ParseCommitMessages')
- def testGetGitHashWorks(self, mock_return_hash_val, mock_check_output):
- mock_check_output.return_value = 'a13testhash2 [Test] Test sentence.'
- mock_return_hash_val.return_value = 'a13testhash2'
-
- self.assertEqual(LLVMHash().GetGitHashForVersion('/tmp/tmpTest', 100),
- 'a13testhash2')
-
- mock_return_hash_val.assert_called_once_with(
- '/tmp/tmpTest', 'a13testhash2 [Test] Test sentence.', 100)
- mock_check_output.assert_called_once()
+ mock_get_git_hash.assert_called_once()
@mock.patch.object(LLVMHash, 'GetLLVMHash')
@mock.patch.object(get_llvm_hash, 'GetGoogle3LLVMVersion')
diff --git a/llvm_tools/git_llvm_rev.py b/llvm_tools/git_llvm_rev.py
new file mode 100755
index 00000000..76a67d65
--- /dev/null
+++ b/llvm_tools/git_llvm_rev.py
@@ -0,0 +1,356 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Maps LLVM git SHAs to synthetic revision numbers and back.
+
+Revision numbers are all of the form '(branch_name, r1234)'. As a shorthand,
+r1234 is parsed as '(master, 1234)'.
+"""
+
+import argparse
+import re
+import subprocess
+import sys
+import typing as t
+
+# Note that after base_llvm_sha, we reach The Wild West(TM) of commits.
+# So reasonable input that could break us includes:
+#
+# Revert foo
+#
+# This reverts foo, which had the commit message:
+#
+# bar
+# llvm-svn: 375505
+#
+# While saddening, this is something we should probably try to handle
+# reasonably.
+base_llvm_revision = 375505
+base_llvm_sha = '186155b89c2d2a2f62337081e3ca15f676c9434b'
+
+# Represents an LLVM git checkout:
+# - |dir| is the directory of the LLVM checkout
+# - |remote| is the name of the LLVM remote. Generally it's "origin".
+LLVMConfig = t.NamedTuple('LLVMConfig', (('remote', str), ('dir', str)))
+
+
+class Rev(t.NamedTuple('Rev', (('branch', str), ('number', int)))):
+ """Represents a LLVM 'revision', a shorthand identifies a LLVM commit."""
+
+ @staticmethod
+ def parse(rev: str) -> 'Rev':
+ """Parses a Rev from the given string.
+
+ Raises a ValueError on a failed parse.
+ """
+ # Revs are parsed into (${branch_name}, r${commits_since_base_commit})
+ # pairs.
+ #
+ # We support r${commits_since_base_commit} as shorthand for
+ # (master, r${commits_since_base_commit}).
+ if rev.startswith('r'):
+ branch_name = 'master'
+ rev_string = rev[1:]
+ else:
+ match = re.match(r'\((.+), r(\d+)\)', rev)
+ if not match:
+ raise ValueError("%r isn't a valid revision" % rev)
+
+ branch_name, rev_string = match.groups()
+
+ return Rev(branch=branch_name, number=int(rev_string))
+
+ def __str__(self) -> str:
+ branch_name, number = self
+ if branch_name == 'master':
+ return 'r%d' % number
+ return '(%s, r%d)' % (branch_name, number)
+
+
+def is_git_sha(xs: str) -> bool:
+ """Returns whether the given string looks like a valid git commit SHA."""
+ return len(xs) > 6 and len(xs) <= 40 and all(
+ x.isdigit() or 'a' <= x.lower() <= 'f' for x in xs)
+
+
+def check_output(command: t.List[str], cwd: str) -> str:
+ """Shorthand for subprocess.check_output. Auto-decodes any stdout."""
+ result = subprocess.run(
+ command,
+ cwd=cwd,
+ check=True,
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.PIPE,
+ encoding='utf-8',
+ )
+ return result.stdout
+
+
+def translate_prebase_sha_to_rev_number(llvm_config: LLVMConfig,
+ sha: str) -> int:
+ """Translates a sha to a revision number (e.g., "llvm-svn: 1234").
+
+ This function assumes that the given SHA is an ancestor of |base_llvm_sha|.
+ """
+ commit_message = check_output(
+ ['git', 'log', '-n1', '--format=%B', sha],
+ cwd=llvm_config.dir,
+ )
+ last_line = commit_message.strip().splitlines()[-1]
+ svn_match = re.match(r'^llvm-svn: (\d+)$', last_line)
+
+ if not svn_match:
+ raise ValueError(
+ f"No llvm-svn line found for {sha}, which... shouldn't happen?")
+
+ return int(svn_match.group(1))
+
+
+def translate_sha_to_rev(llvm_config: LLVMConfig, sha_or_ref: str) -> Rev:
+ """Translates a sha or git ref to a Rev."""
+
+ if is_git_sha(sha_or_ref):
+ sha = sha_or_ref
+ else:
+ sha = check_output(
+ ['git', 'rev-parse', sha_or_ref],
+ cwd=llvm_config.dir,
+ )
+ sha = sha.strip()
+
+ merge_base = check_output(
+ ['git', 'merge-base', base_llvm_sha, sha],
+ cwd=llvm_config.dir,
+ )
+ merge_base = merge_base.strip()
+
+ if merge_base == base_llvm_sha:
+ result = check_output(
+ ['git', 'rev-list', '--count', f'{base_llvm_sha}..{sha}'],
+ cwd=llvm_config.dir,
+ )
+ count = int(result.strip())
+ return Rev(branch='master', number=count + base_llvm_revision)
+
+ # Otherwise, either:
+ # - |merge_base| is |sha| (we have a guaranteed llvm-svn number on |sha|)
+ # - |merge_base| is neither (we have a guaranteed llvm-svn number on
+ # |merge_base|, but not |sha|)
+ merge_base_number = translate_prebase_sha_to_rev_number(
+ llvm_config, merge_base)
+ if merge_base == sha:
+ return Rev(branch='master', number=merge_base_number)
+
+ distance_from_base = check_output(
+ ['git', 'rev-list', '--count', f'{merge_base}..{sha}'],
+ cwd=llvm_config.dir,
+ )
+
+ revision_number = merge_base_number + int(distance_from_base.strip())
+ branches_containing = check_output(
+ ['git', 'branch', '-r', '--contains', sha],
+ cwd=llvm_config.dir,
+ )
+
+ candidates = []
+
+ prefix = llvm_config.remote + '/'
+ for branch in branches_containing.splitlines():
+ branch = branch.strip()
+ if branch.startswith(prefix):
+ candidates.append(branch[len(prefix):])
+
+ if not candidates:
+ raise ValueError(
+ f'No viable branches found from {llvm_config.remote} with {sha}')
+
+ if len(candidates) != 1:
+ raise ValueError(
+ f'Ambiguity: multiple branches from {llvm_config.remote} have {sha}: '
+ f'{sorted(candidates)}')
+
+ branch, = candidates
+ return Rev(branch=branch, number=revision_number)
+
+
+def parse_git_commit_messages(stream: t.Iterable[str],
+ separator: str) -> t.Iterable[t.Tuple[str, str]]:
+ """Parses a stream of git log messages.
+
+ These are expected to be in the format:
+
+ 40 character sha
+ commit
+ message
+ body
+ separator
+ 40 character sha
+ commit
+ message
+ body
+ separator
+ """
+
+ lines = iter(stream)
+ while True:
+ sha = next(lines, None)
+ if sha is None:
+ return
+
+ sha = sha.strip()
+ assert is_git_sha(sha), f'Invalid git SHA: {sha}'
+
+ message = []
+ for line in lines:
+ if line.strip() == separator:
+ break
+ message.append(line)
+
+ yield sha, ''.join(message)
+
+
+def translate_prebase_rev_to_sha(llvm_config: LLVMConfig, rev: Rev) -> str:
+ """Translates a Rev to a SHA.
+
+ This function assumes that the given rev refers to a commit that's an
+ ancestor of |base_llvm_sha|.
+ """
+ # Because reverts may include reverted commit messages, we can't just |-n1|
+ # and pick that.
+ separator = '>!' * 80
+ looking_for = f'llvm-svn: {rev.number}'
+
+ git_command = [
+ 'git', 'log', '--grep', f'^{looking_for}$', f'--format=%H%n%B{separator}',
+ base_llvm_sha
+ ]
+
+ subp = subprocess.Popen(
+ git_command,
+ cwd=llvm_config.dir,
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.PIPE,
+ encoding='utf-8',
+ )
+
+ with subp:
+ for sha, message in parse_git_commit_messages(subp.stdout, separator):
+ last_line = message.splitlines()[-1]
+ if last_line.strip() == looking_for:
+ subp.terminate()
+ return sha
+
+ if subp.returncode:
+ raise subprocess.CalledProcessError(subp.returncode, git_command)
+ raise ValueError(f'No commit with revision {rev} found')
+
+
+def translate_rev_to_sha(llvm_config: LLVMConfig, rev: Rev) -> str:
+ """Translates a Rev to a SHA.
+
+ Raises a ValueError if the given Rev doesn't exist in the given config.
+ """
+ branch, number = rev
+
+ if branch == 'master':
+ if number < base_llvm_revision:
+ return translate_prebase_rev_to_sha(llvm_config, rev)
+ base_sha = base_llvm_sha
+ base_revision_number = base_llvm_revision
+ else:
+ base_sha = check_output(
+ ['git', 'merge-base', base_llvm_sha, f'{llvm_config.remote}/{branch}'],
+ cwd=llvm_config.dir,
+ )
+ base_sha = base_sha.strip()
+ if base_sha == base_llvm_sha:
+ base_revision_number = base_llvm_revision
+ else:
+ base_revision_number = translate_prebase_sha_to_rev_number(
+ llvm_config, base_sha)
+
+ # Alternatively, we could |git log --format=%H|, but git is *super* fast
+ # about rev walking/counting locally compared to long |log|s, so we walk back
+ # twice.
+ head = check_output(
+ ['git', 'rev-parse', f'{llvm_config.remote}/{branch}'],
+ cwd=llvm_config.dir,
+ )
+ branch_head_sha = head.strip()
+
+ commit_number = number - base_revision_number
+ revs_between_str = check_output(
+ ['git', 'rev-list', '--count', f'{base_sha}..{branch_head_sha}'],
+ cwd=llvm_config.dir,
+ )
+ revs_between = int(revs_between_str.strip())
+
+ commits_behind_head = revs_between - commit_number
+ if commits_behind_head < 0:
+ raise ValueError(
+ f'Revision {rev} is past {llvm_config.remote}/{branch}. Try updating '
+ 'your tree?')
+
+ result = check_output(
+ ['git', 'rev-parse', f'{branch_head_sha}~{commits_behind_head}'],
+ cwd=llvm_config.dir,
+ )
+
+ return result.strip()
+
+
+def find_root_llvm_dir(root_dir: str = '.') -> str:
+ """Finds the root of an LLVM directory starting at |root_dir|.
+
+ Raises a subprocess.CalledProcessError if no git directory is found.
+ """
+ result = check_output(
+ ['git', 'rev-parse', '--show-toplevel'],
+ cwd=root_dir,
+ )
+ return result.strip()
+
+
+def main(argv: t.List[str]) -> None:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ '--llvm_dir',
+ help='LLVM directory to consult for git history, etc. Autodetected '
+ 'if cwd is inside of an LLVM tree')
+ parser.add_argument(
+ '--upstream',
+ default='origin',
+ help="LLVM upstream's remote name. Defaults to %(default)s.")
+ sha_or_rev = parser.add_mutually_exclusive_group(required=True)
+ sha_or_rev.add_argument(
+ '--sha', help='A git SHA (or ref) to convert to a rev')
+ sha_or_rev.add_argument('--rev', help='A rev to convert into a sha')
+ opts = parser.parse_args(argv)
+
+ llvm_dir = opts.llvm_dir
+ if llvm_dir is None:
+ try:
+ llvm_dir = find_root_llvm_dir()
+ except subprocess.CalledProcessError:
+ parser.error("Couldn't autodetect an LLVM tree; please use --llvm_dir")
+
+ config = LLVMConfig(
+ remote=opts.upstream,
+ dir=opts.llvm_dir or find_root_llvm_dir(),
+ )
+
+ if opts.sha:
+ rev = str(translate_sha_to_rev(config, opts.sha))
+ print(rev)
+ return rev
+ else:
+ sha = str(translate_rev_to_sha(config, Rev.parse(opts.rev)))
+ print(sha)
+ return sha
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
diff --git a/llvm_tools/git_llvm_rev_test.py b/llvm_tools/git_llvm_rev_test.py
new file mode 100755
index 00000000..ebb654ff
--- /dev/null
+++ b/llvm_tools/git_llvm_rev_test.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+import unittest
+
+import git_llvm_rev
+
+
+def get_llvm_checkout() -> str:
+ my_dir = os.path.dirname(os.path.abspath(__file__))
+ return os.path.join(my_dir, 'llvm-project-copy')
+
+
+def get_llvm_config() -> git_llvm_rev.LLVMConfig:
+ return git_llvm_rev.LLVMConfig(dir=get_llvm_checkout(), remote='origin')
+
+
+class Test(unittest.TestCase):
+
+ def rev_to_sha_with_round_trip(self, rev: git_llvm_rev.Rev) -> str:
+ config = get_llvm_config()
+ sha = git_llvm_rev.translate_rev_to_sha(config, rev)
+ roundtrip_rev = git_llvm_rev.translate_sha_to_rev(config, sha)
+ self.assertEqual(roundtrip_rev, rev)
+ return sha
+
+ def test_sha_to_rev_on_base_sha_works(self) -> None:
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(
+ branch='master', number=git_llvm_rev.base_llvm_revision))
+ self.assertEqual(sha, git_llvm_rev.base_llvm_sha)
+
+ def test_sha_to_rev_prior_to_base_rev_works(self) -> None:
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='master', number=375000))
+ self.assertEqual(sha, '2f6da767f13b8fd81f840c211d405fea32ac9db7')
+
+ def test_sha_to_rev_after_base_rev_works(self) -> None:
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='master', number=375506))
+ self.assertEqual(sha, '3bf7fddeb05655d9baed4cc69e13535c677ed1dd')
+
+ def test_llvm_svn_parsing_runs_ignore_reverts(self) -> None:
+ # This commit has a revert that mentions the reverted llvm-svn in the
+ # commit message.
+
+ # Commit which performed the revert
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='master', number=374895))
+ self.assertEqual(sha, '1731fc88d1fa1fa55edd056db73a339b415dd5d6')
+
+ # Commit that was reverted
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='master', number=374841))
+ self.assertEqual(sha, '2a1386c81de504b5bda44fbecf3f7b4cdfd748fc')
+
+ def test_imaginary_revs_raise(self) -> None:
+ with self.assertRaises(ValueError) as r:
+ git_llvm_rev.translate_rev_to_sha(
+ get_llvm_config(), git_llvm_rev.Rev(branch='master', number=9999999))
+
+ self.assertIn('Try updating your tree?', str(r.exception))
+
+ # NOTE: The below tests have _zz_ in their name as an optimization. Iterating
+ # on a quick test is painful when these larger tests come before it and take
+ # 7secs to run. Python's unittest module guarantees tests are run in
+ # alphabetical order by their method name, so...
+ #
+ # If you're wondering, the slow part is `git branch -r --contains`. I imagine
+ # it's going to be very cold code, so I'm not inclined to optimize it much.
+
+ def test_zz_branch_revs_work_after_merge_points_and_svn_cutoff(self) -> None:
+ # Arbitrary 9.x commit without an attached llvm-svn: value.
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='release/9.x', number=366670))
+ self.assertEqual(sha, '4e858e4ac00b59f064da4e1f7e276916e7d296aa')
+
+ def test_zz_branch_revs_work_at_merge_points(self) -> None:
+ rev_number = 366426
+ backing_sha = 'c89a3d78f43d81b9cff7b9248772ddf14d21b749'
+
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='master', number=rev_number))
+ self.assertEqual(sha, backing_sha)
+
+ # Note that this won't round-trip: since this commit is on the master
+ # branch, we'll pick master for this. That's fine
+ sha = git_llvm_rev.translate_rev_to_sha(
+ get_llvm_config(),
+ git_llvm_rev.Rev(branch='release/9.x', number=rev_number))
+ self.assertEqual(sha, backing_sha)
+
+ def test_zz_branch_revs_work_after_merge_points(self) -> None:
+ # Picking the commit on the 9.x branch after the merge-base for that +
+ # master. Note that this is where llvm-svn numbers should diverge from
+ # ours, and are therefore untrustworthy. The commit for this *does* have a
+ # different `llvm-svn:` string than we should have.
+ sha = self.rev_to_sha_with_round_trip(
+ git_llvm_rev.Rev(branch='release/9.x', number=366427))
+ self.assertEqual(sha, '2cf681a11aea459b50d712abc7136f7129e4d57f')
+
+
+# FIXME: When release/10.x happens, it may be nice to have a test-case
+# generally covering that, since it's the first branch that we have to travel
+# back to the base commit for.
+
+if __name__ == '__main__':
+ # We have exactly one concrete target that we often have checked out anyway.
+ # Rather than building tests that hopefully match that target, use it
+ # directly.
+ if not os.path.isdir(get_llvm_checkout()):
+ print(
+ 'Please checkout llvm-project-copy to run these tests. A simple way '
+ 'to do that is running `./get_llvm_hash.py --llvm_version 370000`',
+ file=sys.stderr)
+ sys.exit(1)
+ unittest.main()
diff --git a/llvm_tools/llvm_bisection.py b/llvm_tools/llvm_bisection.py
index b45be0aa..4ff921d2 100755
--- a/llvm_tools/llvm_bisection.py
+++ b/llvm_tools/llvm_bisection.py
@@ -11,6 +11,7 @@ from __future__ import print_function
import argparse
import enum
import errno
+import get_llvm_hash
import json
import os
import sys
@@ -268,7 +269,7 @@ def GetRevisionsBetweenBisection(start, end, parallel, src_path,
cur_revision not in skip_revisions:
# Verify that the current revision exists by finding its corresponding
# git hash in the LLVM source tree.
- new_llvm.GetGitHashForVersion(src_path, cur_revision)
+ get_llvm_hash.GetGitHashFrom(src_path, cur_revision)
valid_revisions.append(cur_revision)
except ValueError:
# Could not find the git hash for the current revision.
@@ -302,9 +303,7 @@ def GetRevisionsListAndHashList(start, end, parallel, src_path,
revisions = GetRevisionsBetweenBisection(
start, end, parallel, src_path, pending_revisions, skip_revisions)
- git_hashes = [
- new_llvm.GetGitHashForVersion(src_path, rev) for rev in revisions
- ]
+ git_hashes = [get_llvm_hash.GetGitHashFrom(src_path, rev) for rev in revisions]
return revisions, git_hashes
@@ -363,7 +362,7 @@ def _NoteCompletedBisection(last_tested, src_path, end):
print('Finished bisecting for %s' % last_tested)
if src_path:
- bad_llvm_hash = LLVMHash().GetGitHashForVersion(src_path, end)
+ bad_llvm_hash = get_llvm_hash.GetGitHashFrom(src_path, end)
else:
bad_llvm_hash = LLVMHash().GetLLVMHash(end)
diff --git a/llvm_tools/llvm_bisection_unittest.py b/llvm_tools/llvm_bisection_unittest.py
index 946a56ff..ccef649c 100755
--- a/llvm_tools/llvm_bisection_unittest.py
+++ b/llvm_tools/llvm_bisection_unittest.py
@@ -8,7 +8,9 @@
from __future__ import print_function
+import get_llvm_hash
import json
+import llvm_bisection
import unittest
import unittest.mock as mock
@@ -17,7 +19,6 @@ from test_helpers import ArgsOutputTest
from test_helpers import CallCountsToMockFunctions
from test_helpers import CreateTemporaryJsonFile
from test_helpers import WritePrettyJsonFile
-import llvm_bisection
class LLVMBisectionTest(unittest.TestCase):
@@ -144,7 +145,7 @@ class LLVMBisectionTest(unittest.TestCase):
llvm_bisection.GetStartAndEndRevision(start, end, test_tryjobs),
expected_revisions_tuple)
- @mock.patch.object(LLVMHash, 'GetGitHashForVersion')
+ @mock.patch.object(get_llvm_hash, 'GetGitHashFrom')
def testNoRevisionsBetweenStartAndEnd(self, mock_get_git_hash):
start = 100
end = 110
@@ -152,7 +153,7 @@ class LLVMBisectionTest(unittest.TestCase):
test_pending_revisions = {107}
test_skip_revisions = {101, 102, 103, 104, 108, 109}
- # Simulate behavior of `GetGitHashForVersion()` when the revision does not
+ # Simulate behavior of `GetGitHashFrom()` when the revision does not
# exist in the LLVM source tree.
def MockGetGitHashForRevisionRaiseException(src_path, revision):
raise ValueError('Revision does not exist')
@@ -168,7 +169,8 @@ class LLVMBisectionTest(unittest.TestCase):
start, end, parallel, abs_path_to_src, test_pending_revisions,
test_skip_revisions), [])
- @mock.patch.object(LLVMHash, 'GetGitHashForVersion')
+ # Assume llvm_bisection module has imported GetGitHashFrom
+ @mock.patch.object(get_llvm_hash, 'GetGitHashFrom')
def testSuccessfullyRetrievedRevisionsBetweenStartAndEnd(
self, mock_get_git_hash):
@@ -193,9 +195,10 @@ class LLVMBisectionTest(unittest.TestCase):
self.assertEqual(mock_get_git_hash.call_count, 2)
- # Simulate behavior of `GetGitHashForVersion()` when successfully retrieved
+ # Simulate behavior of `GetGitHashFrom()` when successfully retrieved
# a list git hashes for each revision in the revisions list.
- @mock.patch.object(LLVMHash, 'GetGitHashForVersion')
+ # Assume llvm_bisection module has imported GetGitHashFrom
+ @mock.patch.object(get_llvm_hash, 'GetGitHashFrom')
# Simulate behavior of `GetRevisionsBetweenBisection()` when successfully
# retrieved a list of valid revisions between 'start' and 'end'.
@mock.patch.object(llvm_bisection, 'GetRevisionsBetweenBisection')
@@ -216,7 +219,7 @@ class LLVMBisectionTest(unittest.TestCase):
if call_count < 3:
return expected_revisions_and_hash_tuple[1][call_count]
- assert False, 'Called `GetGitHashForVersion()` more than expected.'
+ assert False, 'Called `GetGitHashFrom()` more than expected.'
temp_worktree = '/abs/path/to/tmpDir'
@@ -227,7 +230,7 @@ class LLVMBisectionTest(unittest.TestCase):
mock_get_revisions_between_bisection.return_value = \
expected_revisions_and_hash_tuple[0]
- # Simulate behavior of `GetGitHashForVersion()` by using the testing
+ # Simulate behavior of `GetGitHashFrom()` by using the testing
# function.
mock_get_git_hash.side_effect = MockGetGitHashForRevision
@@ -370,10 +373,11 @@ class LLVMBisectionTest(unittest.TestCase):
self.assertEqual(mock_add_tryjob.call_count, 3)
- # Simulate behavior of `GetGitHashForVersion()` when successfully retrieved
- # the git hash of the bad revision.
+ # Simulate behavior of `GetGitHashFrom()` when successfully retrieved
+ # the git hash of the bad revision. Assume llvm_bisection has imported
+ # GetGitHashFrom
@mock.patch.object(
- LLVMHash, 'GetGitHashForVersion', return_value='a123testhash4')
+ get_llvm_hash, 'GetGitHashFrom', return_value='a123testhash4')
def testCompletedBisectionWhenProvidedSrcPath(self, mock_get_git_hash):
last_tested = '/some/last/tested_file.json'
diff --git a/llvm_tools/llvm_patch_management.py b/llvm_tools/llvm_patch_management.py
index dff992a5..ef8b65c8 100755
--- a/llvm_tools/llvm_patch_management.py
+++ b/llvm_tools/llvm_patch_management.py
@@ -9,10 +9,10 @@
from __future__ import print_function
import argparse
+import get_llvm_hash
import os
-from pipes import quote
-
import patch_manager
+
from assert_not_in_chroot import VerifyOutsideChroot
from failure_modes import FailureModes
from get_llvm_hash import CreateTempLLVMRepo
@@ -97,8 +97,8 @@ def GetCommandLineArgs():
# Duplicate packages were passed into the command line
if len(unique_packages) != len(args_output.packages):
- raise ValueError('Duplicate packages were passed in: %s' %
- ' '.join(args_output.packages))
+ raise ValueError('Duplicate packages were passed in: %s' % ' '.join(
+ args_output.packages))
args_output.packages = unique_packages
@@ -212,7 +212,7 @@ def UpdatePackagesPatchMetadataFile(chroot_path, svn_version,
with CreateTempLLVMRepo(temp_dir) as src_path:
# Ensure that 'svn_version' exists in the chromiumum mirror of LLVM by
# finding its corresponding git hash.
- git_hash = llvm_hash.GetGitHashForVersion(src_path, svn_version)
+ git_hash = get_llvm_hash.GetGitHashFrom(src_path, svn_version)
# Git hash of 'svn_version' exists, so move the source tree's HEAD to
# 'git_hash' via `git checkout`.
@@ -232,10 +232,8 @@ def UpdatePackagesPatchMetadataFile(chroot_path, svn_version,
patch_manager.CleanSrcTree(src_path)
# Get the patch results for the current package.
- patches_info = patch_manager.HandlePatches(svn_version,
- patch_metadata_path,
- filesdir_path, src_path,
- mode)
+ patches_info = patch_manager.HandlePatches(
+ svn_version, patch_metadata_path, filesdir_path, src_path, mode)
package_info[cur_package] = patches_info._asdict()
diff --git a/llvm_tools/llvm_patch_management_unittest.py b/llvm_tools/llvm_patch_management_unittest.py
index c9bc7fce..75f003e9 100755
--- a/llvm_tools/llvm_patch_management_unittest.py
+++ b/llvm_tools/llvm_patch_management_unittest.py
@@ -7,16 +7,17 @@
"""Unit tests when creating the arguments for the patch manager."""
from __future__ import print_function
-
from collections import namedtuple
+from failure_modes import FailureModes
+
+import get_llvm_hash
+import llvm_patch_management
import os
+import patch_manager
+import subprocess
import unittest
import unittest.mock as mock
-from failure_modes import FailureModes
-from get_llvm_hash import LLVMHash
-import llvm_patch_management
-import patch_manager
class LlvmPatchManagementTest(unittest.TestCase):
@@ -142,10 +143,10 @@ class LlvmPatchManagementTest(unittest.TestCase):
mock_isfile.assert_called_once()
- # Simulate `GetGitHashForVersion()` when successfully retrieved the git hash
+ # Simulate `GetGitHashFrom()` when successfully retrieved the git hash
# of the version passed in.
@mock.patch.object(
- LLVMHash, 'GetGitHashForVersion', return_value='a123testhash1')
+ get_llvm_hash, 'GetGitHashFrom', return_value='a123testhash1')
# Simulate `CreateTempLLVMRepo()` when successfully created a work tree from
# the LLVM repo copy in `llvm_tools` directory.
@mock.patch.object(llvm_patch_management, 'CreateTempLLVMRepo')
@@ -215,10 +216,10 @@ class LlvmPatchManagementTest(unittest.TestCase):
# Simulate `CleanSrcTree()` when successfully removed changes from the
# worktree.
@mock.patch.object(patch_manager, 'CleanSrcTree')
- # Simulate `GetGitHashForVersion()` when successfully retrieved the git hash
+ # Simulate `GetGitHashFrom()` when successfully retrieved the git hash
# of the version passed in.
@mock.patch.object(
- LLVMHash, 'GetGitHashForVersion', return_value='a123testhash1')
+ get_llvm_hash, 'GetGitHashFrom', return_value='a123testhash1')
# Simulate `CreateTempLLVMRepo()` when successfully created a work tree from
# the LLVM repo copy in `llvm_tools` directory.
@mock.patch.object(llvm_patch_management, 'CreateTempLLVMRepo')
diff --git a/llvm_tools/patch_manager.py b/llvm_tools/patch_manager.py
index 806b944f..c51ba200 100755
--- a/llvm_tools/patch_manager.py
+++ b/llvm_tools/patch_manager.py
@@ -147,14 +147,13 @@ def GetCommandLineArgs():
def GetHEADSVNVersion(src_path):
"""Gets the SVN version of HEAD in the src tree."""
- get_head_cmd = ['git', '-C', src_path, 'log', '-1', '--pretty=%B']
+ cmd = ['git', '-C', src_path, 'rev-parse', 'HEAD']
- head_commit_message = check_output(get_head_cmd)
+ git_hash = check_output(cmd)
- head_svn_version = LLVMHash().GetSVNVersionFromCommitMessage(
- head_commit_message)
+ version = GetVersionFrom(src_path, git_hash)
- return head_svn_version
+ return version
def VerifyHEADIsTheSameAsSVNVersion(src_path, svn_version):
@@ -282,11 +281,9 @@ def GetCommitHashesForBisection(src_path, good_svn_version, bad_svn_version):
new_llvm_hash = LLVMHash()
- bad_commit_hash = new_llvm_hash.GetGitHashForVersion(src_path,
- bad_svn_version)
+ bad_commit_hash = get_llvm_hash.GetGitHashFrom(src_path, bad_svn_version)
- good_commit_hash = new_llvm_hash.GetGitHashForVersion(src_path,
- good_svn_version)
+ good_commit_hash = get_llvm_hash.GetGitHashFrom(src_path, good_svn_version)
return good_commit_hash, bad_commit_hash
@@ -295,13 +292,13 @@ def PerformBisection(src_path, good_commit, bad_commit, svn_version,
patch_metadata_file, filesdir_path, num_patches):
"""Performs bisection to determine where a patch stops applying."""
- bisect_start_cmd = [
+ start_cmd = [
'git', '-C', src_path, 'bisect', 'start', bad_commit, good_commit
]
- check_output(bisect_start_cmd)
+ check_output(start_cmd)
- bisect_run_cmd = [
+ run_cmd = [
'git', '-C', src_path, 'bisect', 'run',
os.path.abspath(__file__), '--svn_version',
'%d' % svn_version, '--patch_metadata_file', patch_metadata_file,
@@ -310,25 +307,24 @@ def PerformBisection(src_path, good_commit, bad_commit, svn_version,
'%d' % num_patches
]
- check_call(bisect_run_cmd)
+ check_call(run_cmd)
# Successfully bisected the patch, so retrieve the SVN version from the
# commit message.
- get_bad_commit_from_bisect_run_cmd = [
- 'git', '-C', src_path, 'show', 'refs/bisect/bad'
+ get_bad_commit_hash_cmd = [
+ 'git', '-C', src_path, 'rev-parse', 'refs/bisect/bad'
]
- bad_commit_message = check_output(get_bad_commit_from_bisect_run_cmd)
+ git_hash = check_output(get_bad_commit_hash_cmd)
- end_bisection_cmd = ['git', '-C', src_path, 'bisect', 'reset']
+ end_cmd = ['git', '-C', src_path, 'bisect', 'reset']
- check_output(end_bisection_cmd)
+ check_output(end_cmd)
# `git bisect run` returns the bad commit hash and the commit message.
- bad_version = LLVMHash().GetSVNVersionFromCommitMessage(
- bad_commit_message.rstrip())
+ version = GetVersionFrom(src_path, git_hash)
- return bad_version
+ return version
def CleanSrcTree(src_path):
diff --git a/lock_machine.py b/lock_machine.py
index 40c7d8fd..eca4bd57 100755
--- a/lock_machine.py
+++ b/lock_machine.py
@@ -69,7 +69,11 @@ class LockManager(object):
"""
SKYLAB_PATH = '/usr/local/bin/skylab'
- LEASE_MINS = 600
+
+ # TODO(zhizhouy): lease time may needs to be dynamically adjusted. For now we
+ # set it long enough to cover the period to finish nightly rotation tests.
+ LEASE_MINS = 1440
+
SKYLAB_CREDENTIAL = '/usr/local/google/home/mobiletc-prebuild' \
'/sheriff_utils/skylab_credential' \
'/chromeos-swarming-credential.json'
diff --git a/toolchain_utils_githooks/check-format b/toolchain_utils_githooks/check-format
deleted file mode 100755
index 372cc483..00000000
--- a/toolchain_utils_githooks/check-format
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/bin/bash -e
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# This script checks the format of the given files. If any look incorrectly
-# formatted, this will complain about them and exit. At the moment, it only
-# checks the format of Python.
-#
-# FIXME: It would be nice if YAPF supported tweaking quotes:
-# https://github.com/google/yapf/issues/399
-
-if [[ $# -eq 0 ]]; then
- echo "No files were given to check the format of." >&2
- echo "Usage: $0 file1 file2 ..." >&2
- exit 1
-fi
-
-yapf=yapf
-gofmt=gofmt
-
-if ! type "${yapf}" >/dev/null 2>&1; then
- echo "${yapf} isn't on your \$PATH. Please either enter a chroot, or place" \
- "depot_tools on your \$PATH." >&2
- exit 1
-fi
-
-if ! type "${gofmt}" >/dev/null 2>&1; then
- echo "${gofmt} isn't on your \$PATH. Please either enter a chroot, or add " \
- "the go binaries to your \$PATH." >&2
- exit 1
-fi
-
-status_to_tf() {
- if "$@" >& /dev/null; then
- echo true
- else
- echo false
- fi
-}
-
-complain_about_missing=$(status_to_tf test -z "${IGNORE_MISSING}")
-
-check_python_file_header() {
- local py_file="$1"
- local needs_hashbang=$(status_to_tf test -x "${py_file}")
- local has_hashbang=$(status_to_tf grep -q '^#!' <(head -n1 "${py_file}"))
-
- if [[ "${needs_hashbang}" == "${has_hashbang}" ]]; then
- return 0
- fi
-
- if "${needs_hashbang}"; then
- echo "File ${py_file} needs a #!; please run" \
- "\`sed -i '1i#!/usr/bin/env python' ${py_file}\`"
- else
- echo "File ${py_file} has an unnecessary #!; please run" \
- "\`sed -i 1d ${py_file}\`"
- fi
- return 1
-}
-
-everything_passed=true
-python_files=()
-go_files=()
-
-for f in "$@"; do
- if [[ ! -e "${f}" ]]; then
- if "${complain_about_missing}"; then
- echo "error: no such file: ${f}" >&2
- everything_passed=false
- fi
- continue
- fi
-
- if [[ "${f}" == *.py ]]; then
- python_files+=( "${f}" )
-
- if ! check_python_file_header "${f}"; then
- everything_passed=false
- fi
- elif [[ "${f}" == *.go ]]; then
- go_files+=( "${f}" )
- fi
-done
-
-if [[ "${#python_files[@]}" -ne 0 ]]; then
- # yapf will give us a full unified (git-like) diff. We parse out the file
- # names, e.g.,
- #
- # --- foo (original)
- #
- # Sed makes it so that bad_files consists only of those lines, but with the
- # leading '--- ' and trailing ' (original)' removed.
- #
- # FIXME: Ideally, we should pass yapf the `-p` arg, so it'll format things in
- # parallel. This requires concurrent.futures in python2 (which isn't
- # available in the chroot by default), and is purely an optimization, so we
- # can handle it later.
- bad_files=(
- $("${yapf}" -d "${python_files[@]}" |
- sed -n '/^--- /{ s/^--- //; s/ *(original)$//p }')
- )
- if [[ "${#bad_files[@]}" -ne 0 ]]; then
- echo "One or more python files appear to be incorrectly formatted."
- echo "Please run \`${yapf} -i ${bad_files[@]}\` to rectify this."
- everything_passed=false
- fi
-fi
-
-if [[ "${#go_files[@]}" -ne 0 ]]; then
- bad_files=(
- $("${gofmt}" -l "${go_files[@]}")
- )
- if [[ "${#bad_files[@]}" -ne 0 ]]; then
- echo "One or more go files appear to be incorrectly formatted."
- echo "Please run \`${gofmt} -w ${bad_files[@]}\` to rectify this."
- everything_passed=false
- fi
-fi
-
-"${everything_passed}"
diff --git a/toolchain_utils_githooks/check-lint b/toolchain_utils_githooks/check-lint
deleted file mode 100755
index e4ba934b..00000000
--- a/toolchain_utils_githooks/check-lint
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/bash -ue
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# This script runs `cros lint` on everything it's handed.
-
-if [[ $# -eq 0 ]]; then
- echo "No files were given to lint." >&2
- echo "Usage: $0 file1 file2 ..." >&2
- exit 1
-fi
-
-cros=cros
-golint=golint
-
-if ! type "${cros}" >&/dev/null; then
- echo "${cros} isn't on your \$PATH. Please either enter a chroot, or place" \
- "depot_tools on your \$PATH." >&2
- exit 1
-fi
-
-lint_args=( "$@" )
-
-# Trys to lint our sources. If `cros` tooling isn't properly found, returns. If
-# anything else happens, this will exit the script with the exit code of
-# `cros`.
-try_lint() {
- local output last_exit_code cros_binary
-
- cros_binary="$1"
-
- set +e
- output="$("${cros_binary}" lint -- "${lint_args[@]}" 2>&1)"
- last_exit_code="$?"
- set -e
-
- # `cros` exits with 127 specifically if it failed due to not finding a Chrome
- # OS checkout.
- if [[ "${last_exit_code}" -ne 127 ]]; then
- if [[ -n "${output}" ]]; then
- echo "${output}"
- fi
- exit "${last_exit_code}"
- fi
-}
-
-try_lint "${cros}"
-
-# If the user's given us a root directory to fall back on, try that
-if [[ -n "${CHROMEOS_ROOT_DIRECTORY:-}" ]]; then
- user_cros="${CHROMEOS_ROOT_DIRECTORY}/chromite/bin/cros"
- if [[ -x "${user_cros}" ]]; then
- try_lint "${user_cros}"
- fi
-fi
-
-# So, `cros` outside of the chroot defers to other tools inside of Chromite. If
-# `cros` couldn't find the real `cros` tool, we fall back to pylint on each
-# Python file. It appears that `cros` uses depot_tools' pylint configuration, so
-# this should get us most of the way there, and is probably the best we can
-# reasonably expect to do for users who want to develop without the source
-# tree.
-echo "WARNING: No Chrome OS checkout detected, and no viable CrOS tree " >&2
-echo "found; falling back to linting only python and go. If you have a " >&2
-echo "Chrome OS checkout, please either develop from inside of the source ">&2
-echo "tree, or set \$CHROMEOS_ROOT_DIRECTORY to the root of it." >&2
-
-python_files=()
-go_files=()
-for file in "$@"; do
- if [[ "${file}" == *.py ]]; then
- python_files+=( "${file}" )
- fi
- if [[ "${file}" == *.go ]]; then
- go_files+=( "${file}" )
- fi
-done
-
-if [[ "${#python_files[@]}" -ne 0 ]]; then
- # We saw `cros` above, so assume that `pylint` is in our PATH (depot_tools
- # packages it, and provides a reasonable default config).
- pylint "${python_files[@]}"
-fi
-
-if ! type "${golint}" >/dev/null 2>&1; then
- echo "Warning: go linting disabled. ${golint} isn't on your \$PATH. "\
- "Please either enter a chroot, or install go locally. Continuing." >&2
-elif [[ "${#go_files[@]}" -ne 0 ]]; then
- "${golint}" -set_exit_status "${go_files[@]}"
-fi
diff --git a/toolchain_utils_githooks/check-presubmit b/toolchain_utils_githooks/check-presubmit
index 0f770234..9b3db881 100755..120000
--- a/toolchain_utils_githooks/check-presubmit
+++ b/toolchain_utils_githooks/check-presubmit
@@ -1,64 +1 @@
-#!/bin/bash -eu
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Convenient wrapper to run presubmit checks in parallel without interleaving
-# output/etc.
-
-if [[ $# -eq 0 ]]; then
- echo "No files were given to check the style of. Exiting." >&2
- exit
-fi
-
-mydir="$(dirname "$(readlink -m "$0")")"
-pydir="${mydir}/.."
-
-if [[ -z "${PYTHONPATH:-}" ]]; then
- export PYTHONPATH="${pydir}"
-else
- export PYTHONPATH="${pydir}:${PYTHONPATH}"
-fi
-
-tempfiles=()
-rm_tempfiles() {
- rm -f "${tempfiles[@]}"
-}
-
-trap rm_tempfiles EXIT
-
-child_pids=()
-spawn_child() {
- local tempfile
- tempfile="$(mktemp)"
- tempfiles+=( "${tempfile}" )
- "$@" >"${tempfile}" 2>&1 &
- child_pids+=( "$!" )
-}
-
-
-# only lint existing files
-files_exist=false
-declare -a to_lint
-for file; do
- if [[ -f "${file}" ]]; then
- files_exist=true
- to_lint+=("${file}")
- fi
-done
-
-# We have a few things to do in parallel here. To avoid interleaving their
-# output, we pipe them all to tempfiles, then cat those tempfiles.
-if "${files_exist}"; then
- spawn_child "${mydir}/check-lint" "${to_lint[@]}"
- spawn_child "${mydir}/check-format" "${to_lint[@]}"
- spawn_child "${mydir}/../run_tests_for.py" "${to_lint[@]}"
-fi
-
-success=true
-for i in "${!child_pids[@]}"; do
- wait "${child_pids[$i]}" || success=false
- cat "${tempfiles[$i]}"
-done
-
-"${success}"
+check-presubmit.py \ No newline at end of file
diff --git a/toolchain_utils_githooks/check-presubmit.py b/toolchain_utils_githooks/check-presubmit.py
new file mode 100755
index 00000000..2fea102a
--- /dev/null
+++ b/toolchain_utils_githooks/check-presubmit.py
@@ -0,0 +1,528 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Runs presubmit checks against a bundle of files."""
+
+# To keep `cros lint` happy
+from __future__ import division, print_function
+
+import argparse
+import collections
+import datetime
+import multiprocessing
+import multiprocessing.pool
+import os
+import re
+import shlex
+import shutil
+import subprocess
+import sys
+import threading
+import traceback
+
+
+def run_command_unchecked(command, cwd, env=None):
+ """Runs a command in the given dir, returning its exit code and stdio."""
+ p = subprocess.Popen(
+ command,
+ cwd=cwd,
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ env=env,
+ )
+
+ stdout, _ = p.communicate()
+ exit_code = p.wait()
+ return exit_code, stdout.decode('utf-8', 'replace')
+
+
+def has_executable_on_path(exe):
+ """Returns whether we have `exe` somewhere on our $PATH"""
+ return shutil.which(exe) is not None
+
+
+def escape_command(command):
+ """Returns a human-readable and copy-pastable shell command.
+
+ Only intended for use in output to users. shell=True is strongly discouraged.
+ """
+ return ' '.join(shlex.quote(x) for x in command)
+
+
+def remove_deleted_files(files):
+ return [f for f in files if os.path.exists(f)]
+
+
+def is_file_executable(file_path):
+ return os.access(file_path, os.X_OK)
+
+
+# As noted in our docs, some of our Python code depends on modules that sit in
+# toolchain-utils/. Add that to PYTHONPATH to ensure that things like `cros
+# lint` are kept happy.
+def env_with_pythonpath(toolchain_utils_root):
+ env = dict(os.environ)
+ if 'PYTHONPATH' in env:
+ env['PYTHONPATH'] += ':' + toolchain_utils_root
+ else:
+ env['PYTHONPATH'] = toolchain_utils_root
+ return env
+
+
+# Each checker represents an independent check that's done on our sources.
+#
+# They should:
+# - never write to stdout/stderr or read from stdin directly
+# - return either a CheckResult, or a list of [(subcheck_name, CheckResult)]
+# - ideally use thread_pool to check things concurrently
+# - though it's important to note that these *also* live on the threadpool
+# we've provided. It's the caller's responsibility to guarantee that at
+# least ${number_of_concurrently_running_checkers}+1 threads are present
+# in the pool. In order words, blocking on results from the provided
+# threadpool is OK.
+CheckResult = collections.namedtuple('CheckResult',
+ ('ok', 'output', 'autofix_commands'))
+
+
+def get_check_result_or_catch(task):
+ """Returns the result of task(); if that raises, returns a CheckResult."""
+ try:
+ return task.get()
+ except Exception:
+ return CheckResult(
+ ok=False,
+ output='Check exited with an unexpected exception:\n%s' %
+ traceback.format_exc(),
+ autofix_commands=[],
+ )
+
+
+def check_yapf(toolchain_utils_root, python_files):
+ """Subchecker of check_py_format. Checks python file formats with yapf"""
+ command = ['yapf', '-d'] + python_files
+ exit_code, stdout_and_stderr = run_command_unchecked(
+ command, cwd=toolchain_utils_root)
+
+ # yapf fails when files are poorly formatted.
+ if exit_code == 0:
+ return CheckResult(
+ ok=True,
+ output='',
+ autofix_commands=[],
+ )
+
+ bad_files = []
+ bad_file_re = re.compile(r'^--- (.*)\s+\(original\)\s*$')
+ for line in stdout_and_stderr.splitlines():
+ m = bad_file_re.match(line)
+ if not m:
+ continue
+
+ file_name, = m.groups()
+ bad_files.append(file_name.strip())
+
+ # ... and doesn't really differentiate "your files have broken formatting"
+ # errors from general ones. So if we see nothing diffed, assume that a
+ # general error happened.
+ if not bad_files:
+ return CheckResult(
+ ok=False,
+ output='`%s` failed; stdout/stderr:\n%s' % (escape_command(command),
+ stdout_and_stderr),
+ autofix_commands=[],
+ )
+
+ autofix = ['yapf', '-i'] + bad_files
+ return CheckResult(
+ ok=False,
+ output='The following file(s) have formatting errors: %s' % bad_files,
+ autofix_commands=[autofix],
+ )
+
+
+def check_python_file_headers(python_files):
+ """Subchecker of check_py_format. Checks python #!s"""
+ add_hashbang = []
+ remove_hashbang = []
+
+ for python_file in python_files:
+ needs_hashbang = is_file_executable(python_file)
+ with open(python_file, encoding='utf-8') as f:
+ has_hashbang = f.read(2) == '#!'
+ if needs_hashbang == has_hashbang:
+ continue
+
+ if needs_hashbang:
+ add_hashbang.append(python_file)
+ else:
+ remove_hashbang.append(python_file)
+
+ autofix = []
+ output = []
+ if add_hashbang:
+ output.append(
+ 'The following files have no #!, but need one: %s' % add_hashbang)
+ autofix.append(['sed', '-i', '1i#!/usr/bin/env python3'] + add_hashbang)
+
+ if remove_hashbang:
+ output.append(
+ "The following files have a #!, but shouldn't: %s" % remove_hashbang)
+ autofix.append(['sed', '-i', '1d'] + remove_hashbang)
+
+ if not output:
+ return CheckResult(
+ ok=True,
+ output='',
+ autofix_commands=[],
+ )
+ return CheckResult(
+ ok=False,
+ output='\n'.join(output),
+ autofix_commands=autofix,
+ )
+
+
+def check_py_format(toolchain_utils_root, thread_pool, files):
+ """Runs yapf on files to check for style bugs. Also checks for #!s."""
+ yapf = 'yapf'
+ if not has_executable_on_path(yapf):
+ return CheckResult(
+ ok=False,
+ output="yapf isn't available on your $PATH. Please either "
+ 'enter a chroot, or place depot_tools on your $PATH.',
+ autofix_commands=[],
+ )
+
+ python_files = [f for f in remove_deleted_files(files) if f.endswith('.py')]
+ if not python_files:
+ return CheckResult(
+ ok=True,
+ output='no python files to check',
+ autofix_commands=[],
+ )
+
+ tasks = [
+ ('check_yapf',
+ thread_pool.apply_async(check_yapf,
+ (toolchain_utils_root, python_files))),
+ ('check_file_headers',
+ thread_pool.apply_async(check_python_file_headers, (python_files,))),
+ ]
+ return [(name, get_check_result_or_catch(task)) for name, task in tasks]
+
+
+def check_cros_lint(toolchain_utils_root, thread_pool, files):
+ """Runs `cros lint`"""
+
+ fixed_env = env_with_pythonpath(toolchain_utils_root)
+
+ # We have to support users who don't have a chroot. So we either run `cros
+ # lint` (if it's been made available to us), or we try a mix of
+ # pylint+golint.
+ def try_run_cros_lint(cros_binary):
+ exit_code, output = run_command_unchecked(
+ [cros_binary, 'lint', '--'] + files,
+ toolchain_utils_root,
+ env=fixed_env)
+
+ # This is returned specifically if cros couldn't find the Chrome OS tree
+ # root.
+ if exit_code == 127:
+ return None
+
+ return CheckResult(
+ ok=exit_code == 0,
+ output=output,
+ autofix_commands=[],
+ )
+
+ cros_lint = try_run_cros_lint('cros')
+ if cros_lint is not None:
+ return cros_lint
+
+ cros_root = os.getenv('CHROMEOS_ROOT_DIRECTORY')
+ if cros_root:
+ cros_lint = try_run_cros_lint(os.path.join(cros_root, 'chromite/bin/cros'))
+ if cros_lint is not None:
+ return cros_lint
+
+ tasks = []
+
+ def check_result_from_command(command):
+ exit_code, output = run_command_unchecked(
+ command, toolchain_utils_root, env=fixed_env)
+ return CheckResult(
+ ok=exit_code == 0,
+ output=output,
+ autofix_commands=[],
+ )
+
+ python_files = [f for f in remove_deleted_files(files) if f.endswith('.py')]
+ if python_files:
+
+ def run_pylint():
+ # pylint is required. Fail hard if it DNE.
+ return check_result_from_command(['pylint'] + python_files)
+
+ tasks.append(('pylint', thread_pool.apply_async(run_pylint)))
+
+ go_files = [f for f in remove_deleted_files(files) if f.endswith('.go')]
+ if go_files:
+
+ def run_golint():
+ if has_executable_on_path('golint'):
+ return check_result_from_command(['golint', '-set_exit_status'] +
+ go_files)
+
+ complaint = '\n'.join((
+ 'WARNING: go linting disabled. golint is not on your $PATH.',
+ 'Please either enter a chroot, or install go locally. Continuing.',
+ ))
+ return CheckResult(
+ ok=True,
+ output=complaint,
+ autofix_commands=[],
+ )
+
+ tasks.append(('golint', thread_pool.apply_async(run_golint)))
+
+ complaint = '\n'.join((
+ 'WARNING: No Chrome OS checkout detected, and no viable CrOS tree',
+ 'found; falling back to linting only python and go. If you have a',
+ 'Chrome OS checkout, please either develop from inside of the source',
+ 'tree, or set $CHROMEOS_ROOT_DIRECTORY to the root of it.',
+ ))
+
+ results = [(name, get_check_result_or_catch(task)) for name, task in tasks]
+ if not results:
+ return CheckResult(
+ ok=True,
+ output=complaint,
+ autofix_commands=[],
+ )
+
+ # We need to complain _somewhere_.
+ name, angry_result = results[0]
+ angry_complaint = (complaint + '\n\n' + angry_result.output).strip()
+ results[0] = (name, angry_result._replace(output=angry_complaint))
+ return results
+
+
+def check_go_format(toolchain_utils_root, _thread_pool, files):
+ """Runs gofmt on files to check for style bugs."""
+ gofmt = 'gofmt'
+ if not has_executable_on_path(gofmt):
+ return CheckResult(
+ ok=False,
+ output="gofmt isn't available on your $PATH. Please either "
+ 'enter a chroot, or place your go bin/ directory on your $PATH.',
+ autofix_commands=[],
+ )
+
+ go_files = [f for f in remove_deleted_files(files) if f.endswith('.go')]
+ if not go_files:
+ return CheckResult(
+ ok=True,
+ output='no go files to check',
+ autofix_commands=[],
+ )
+
+ command = [gofmt, '-l'] + go_files
+ exit_code, output = run_command_unchecked(command, cwd=toolchain_utils_root)
+
+ if exit_code:
+ return CheckResult(
+ ok=False,
+ output='%s failed; stdout/stderr:\n%s' % (escape_command(command),
+ output),
+ autofix_commands=[],
+ )
+
+ output = output.strip()
+ if not output:
+ return CheckResult(
+ ok=True,
+ output='',
+ autofix_commands=[],
+ )
+
+ broken_files = [x.strip() for x in output.splitlines()]
+ autofix = [gofmt, '-w'] + broken_files
+ return CheckResult(
+ ok=False,
+ output='The following Go files have incorrect '
+ 'formatting: %s' % broken_files,
+ autofix_commands=[autofix],
+ )
+
+
+def check_tests(toolchain_utils_root, _thread_pool, files):
+ """Runs tests."""
+ exit_code, stdout_and_stderr = run_command_unchecked(
+ [os.path.join(toolchain_utils_root, 'run_tests_for.py'), '--'] + files,
+ toolchain_utils_root)
+ return CheckResult(
+ ok=exit_code == 0,
+ output=stdout_and_stderr,
+ autofix_commands=[],
+ )
+
+
+def detect_toolchain_utils_root():
+ return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+
+def process_check_result(check_name, check_results, start_time):
+ """Prints human-readable output for the given check_results."""
+ indent = ' '
+
+ def indent_block(text):
+ return indent + text.replace('\n', '\n' + indent)
+
+ if isinstance(check_results, CheckResult):
+ ok, output, autofix_commands = check_results
+ if not ok and autofix_commands:
+ recommendation = ('Recommended command(s) to fix this: %s' %
+ [escape_command(x) for x in autofix_commands])
+ if output:
+ output += '\n' + recommendation
+ else:
+ output = recommendation
+ else:
+ output_pieces = []
+ autofix_commands = []
+ for subname, (ok, output, autofix) in check_results:
+ status = 'succeeded' if ok else 'failed'
+ message = ['*** %s.%s %s' % (check_name, subname, status)]
+ if output:
+ message.append(indent_block(output))
+ if not ok and autofix:
+ message.append(
+ indent_block('Recommended command(s) to fix this: %s' %
+ [escape_command(x) for x in autofix]))
+
+ output_pieces.append('\n'.join(message))
+ autofix_commands += autofix
+
+ ok = all(x.ok for _, x in check_results)
+ output = '\n\n'.join(output_pieces)
+
+ time_taken = datetime.datetime.now() - start_time
+ if ok:
+ print('*** %s succeeded after %s' % (check_name, time_taken))
+ else:
+ print('*** %s failed after %s' % (check_name, time_taken))
+
+ if output:
+ print(indent_block(output))
+
+ print()
+ return ok, autofix_commands
+
+
+def try_autofix(all_autofix_commands, toolchain_utils_root):
+ """Tries to run all given autofix commands, if appropriate."""
+ if not all_autofix_commands:
+ return
+
+ exit_code, output = run_command_unchecked(['git', 'status', '--porcelain'],
+ cwd=toolchain_utils_root)
+ if exit_code != 0:
+ print("Autofix aborted: couldn't get toolchain-utils git status.")
+ return
+
+ if output.strip():
+ # A clean repo makes checking/undoing autofix commands trivial. A dirty
+ # one... less so. :)
+ print('Git repo seems dirty; skipping autofix.')
+ return
+
+ anything_succeeded = False
+ for command in all_autofix_commands:
+ exit_code, output = run_command_unchecked(command, cwd=toolchain_utils_root)
+
+ if exit_code:
+ print('*** Autofix command `%s` exited with code %d; stdout/stderr:' %
+ (escape_command(command), exit_code))
+ print(output)
+ else:
+ print('*** Autofix `%s` succeeded' % escape_command(command))
+ anything_succeeded = True
+
+ if anything_succeeded:
+ print('NOTE: Autofixes have been applied. Please check your tree, since '
+ 'some lints may now be fixed')
+
+
+def main(argv):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ '--no_autofix',
+ dest='autofix',
+ action='store_false',
+ help="Don't run any autofix commands")
+ parser.add_argument('files', nargs='*')
+ opts = parser.parse_args(argv)
+
+ files = opts.files
+ if not files:
+ return 0
+
+ files = [os.path.abspath(f) for f in files]
+
+ # Note that we extract .__name__s from these, so please name them in a
+ # user-friendly way.
+ checks = [
+ check_cros_lint,
+ check_py_format,
+ check_go_format,
+ check_tests,
+ ]
+
+ toolchain_utils_root = detect_toolchain_utils_root()
+
+ # NOTE: As mentioned above, checks can block on threads they spawn in this
+ # pool, so we need at least len(checks)+1 threads to avoid deadlock. Use *2
+ # so all checks can make progress at a decent rate.
+ num_threads = max(multiprocessing.cpu_count(), len(checks) * 2)
+ start_time = datetime.datetime.now()
+
+ # For our single print statement...
+ spawn_print_lock = threading.RLock()
+
+ def run_check(check_fn):
+ name = check_fn.__name__
+ with spawn_print_lock:
+ print('*** Spawning %s' % name)
+ return name, check_fn(toolchain_utils_root, pool, files)
+
+ # ThreadPool is a ContextManager in py3.
+ # pylint: disable=not-context-manager
+ with multiprocessing.pool.ThreadPool(num_threads) as pool:
+ all_checks_ok = True
+ all_autofix_commands = []
+ for check_name, result in pool.imap_unordered(run_check, checks):
+ ok, autofix_commands = process_check_result(check_name, result,
+ start_time)
+ all_checks_ok = ok and all_checks_ok
+ all_autofix_commands += autofix_commands
+
+ # Run these after everything settles, so:
+ # - we don't collide with checkers that are running concurrently
+ # - we clearly print out everything that went wrong ahead of time, in case
+ # any of these fail
+ if opts.autofix:
+ try_autofix(all_autofix_commands, toolchain_utils_root)
+
+ if not all_checks_ok:
+ return 1
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))