diff options
author | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-02-28 21:09:49 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-02-28 21:09:49 +0000 |
commit | ed2c53c997b7b57f970e5aa351ac330355dcca18 (patch) | |
tree | d310a6a84483842248a4a3f210a15324d7e450cc | |
parent | e617e3393dd24003aa976ece5050bb291070041c (diff) | |
parent | 73b35a288582305e45a656e35fd2e8b47933fd90 (diff) | |
download | toolchain-utils-ed2c53c997b7b57f970e5aa351ac330355dcca18.tar.gz |
Merging 13 commit(s) from Chromium's toolchain-utils am: 1c417d433e am: 73b35a2885
Change-Id: I2546fc1ef608b262f5c9d8485156379ad78ee05d
36 files changed, 239 insertions, 133 deletions
diff --git a/afdo_metadata/kernel_afdo.json b/afdo_metadata/kernel_afdo.json index 751af04c..24f40fe6 100644 --- a/afdo_metadata/kernel_afdo.json +++ b/afdo_metadata/kernel_afdo.json @@ -1,11 +1,17 @@ { "chromeos-kernel-3_14": { "name": "R81-12607.58-1578524353" - }, + }, "chromeos-kernel-4_4": { - "name": "R82-12874.0-1581330812" - }, + "name": "R82-12901.0-1582540582" + }, "chromeos-kernel-3_18": { - "name": "R82-12861.0-1580725956" + "name": "R82-12901.0-1582540470" + }, + "chromeos-kernel-4_14": { + "name": "R82-12896.0-1582540320" + }, + "chromeos-kernel-4_19": { + "name": "R82-12898.0-1582540816" } }
\ No newline at end of file diff --git a/binary_search_tool/binary_search_perforce.py b/binary_search_tool/binary_search_perforce.py index 5065f709..f2a3c8d5 100755 --- a/binary_search_tool/binary_search_perforce.py +++ b/binary_search_tool/binary_search_perforce.py @@ -369,7 +369,7 @@ class P4BinarySearcher(VCSBinarySearcher): self.ce.RunCommand(command) command = 'cd %s' % self.checkout_dir command += '; g4 changes -c %s' % self.client_name - _, out, _ = self.ce.RunCommandWOUTPUOT(command) + _, out, _ = self.ce.RunCommandWOutput(command) changes = re.findall(r'Change (\d+)', out) if changes: command = 'cd %s' % self.checkout_dir diff --git a/binary_search_tool/compiler_wrapper.py b/binary_search_tool/compiler_wrapper.py index 8755ed42..0fd92c67 100755 --- a/binary_search_tool/compiler_wrapper.py +++ b/binary_search_tool/compiler_wrapper.py @@ -37,7 +37,7 @@ BISECT_DIR = os.environ.get('BISECT_DIR') or DEFAULT_BISECT_DIR def ProcessArgFile(arg_file): args = [] # Read in entire file at once and parse as if in shell - with open(arg_file, 'rb') as f: + with open(arg_file, 'r', encoding='utf-8') as f: args.extend(shlex.split(f.read())) return args diff --git a/binary_search_tool/test/binary_search_tool_test.py b/binary_search_tool/test/binary_search_tool_test.py index ca9313b5..6f5b514e 100755 --- a/binary_search_tool/test/binary_search_tool_test.py +++ b/binary_search_tool/test/binary_search_tool_test.py @@ -202,7 +202,7 @@ class BisectingUtilsTest(unittest.TestCase): f.write('test123') bss = binary_search_state.MockBinarySearchState() - with self.assertRaises(binary_search_state.Error): + with self.assertRaises(OSError): bss.SaveState() with open(state_file, 'r', encoding='utf-8') as f: diff --git a/buildbot_test_toolchains.py b/buildbot_test_toolchains.py index 5f7c21d3..1609da49 100755 --- a/buildbot_test_toolchains.py +++ b/buildbot_test_toolchains.py @@ -204,23 +204,23 @@ class ToolchainComparator(object): # Now add vanilla to test file. official_image = """ - vanilla_image { - chromeos_root: %s - build: %s - compiler: llvm - } - """ % (self._chromeos_root, vanilla_image) + vanilla_image { + chromeos_root: %s + build: %s + compiler: llvm + } + """ % (self._chromeos_root, vanilla_image) f.write(official_image) # Now add non-AFDO image to test file. if nonafdo_image: official_nonafdo_image = """ - nonafdo_image { - chromeos_root: %s - build: %s - compiler: llvm - } - """ % (self._chromeos_root, nonafdo_image) + nonafdo_image { + chromeos_root: %s + build: %s + compiler: llvm + } + """ % (self._chromeos_root, nonafdo_image) f.write(official_nonafdo_image) label_string = '%s_trybot_image' % compiler_string @@ -228,14 +228,14 @@ class ToolchainComparator(object): # Reuse autotest files from vanilla image for trybot images autotest_files = os.path.join('/tmp', vanilla_image, 'autotest_files') experiment_image = """ - %s { - chromeos_root: %s - build: %s - autotest_path: %s - compiler: %s - } - """ % (label_string, self._chromeos_root, trybot_image, - autotest_files, compiler_string) + %s { + chromeos_root: %s + build: %s + autotest_path: %s + compiler: %s + } + """ % (label_string, self._chromeos_root, trybot_image, autotest_files, + compiler_string) f.write(experiment_image) crosperf = os.path.join(TOOLCHAIN_DIR, 'crosperf', 'crosperf') diff --git a/chromiumos_image_diff.py b/chromiumos_image_diff.py index 66a54ccc..3d54100d 100755 --- a/chromiumos_image_diff.py +++ b/chromiumos_image_diff.py @@ -318,7 +318,7 @@ def Main(argv): for i, image_path in enumerate([options.image1, options.image2], start=1): image_path = os.path.realpath(image_path) if not os.path.isfile(image_path): - logger.getLogger().LogError('"{0}" is not a file.'.format(image_path)) + logger.GetLogger().LogError('"{0}" is not a file.'.format(image_path)) return 1 chromeos_root = None diff --git a/compiler_wrapper/bisect_flag.go b/compiler_wrapper/bisect_flag.go index 8aec3e7e..f07d9a63 100644 --- a/compiler_wrapper/bisect_flag.go +++ b/compiler_wrapper/bisect_flag.go @@ -20,7 +20,7 @@ import sys def ExpandArgs(args, target): for arg in args: if arg[0] == '@': - with open(arg[1:], 'rb') as f: + with open(arg[1:], 'r', encoding='utf-8') as f: ExpandArgs(shlex.split(f.read()), target) else: target.append(arg) @@ -64,7 +64,7 @@ func calcBisectCommand(env env, cfg *config, bisectStage string, compilerCmd *co return &command{ Path: "/usr/bin/env", Args: append([]string{ - "python", + "python3", "-c", bisectPythonCommand, bisectStage, diff --git a/compiler_wrapper/bisect_flag_test.go b/compiler_wrapper/bisect_flag_test.go index 5c4c82d6..cc203a0f 100644 --- a/compiler_wrapper/bisect_flag_test.go +++ b/compiler_wrapper/bisect_flag_test.go @@ -56,7 +56,7 @@ func TestCallBisectDriverWithCCache(t *testing.T) { if err := verifyPath(cmd, "/usr/bin/env"); err != nil { t.Error(err) } - if err := verifyArgOrder(cmd, "python", "/usr/bin/ccache"); err != nil { + if err := verifyArgOrder(cmd, "python3", "/usr/bin/ccache"); err != nil { t.Error(err) } if err := verifyEnvUpdate(cmd, "CCACHE_DIR=.*"); err != nil { @@ -138,7 +138,7 @@ func withBisectTestContext(t *testing.T, work func(ctx *testContext)) { if err := verifyPath(cmd, "/usr/bin/env"); err != nil { return err } - if cmd.Args[0] != "python" { + if cmd.Args[0] != "python3" { return fmt.Errorf("expected a call to python. Got: %s", cmd.Args[0]) } if cmd.Args[1] != "-c" { diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go index c614b99f..11fd8199 100644 --- a/compiler_wrapper/compiler_wrapper.go +++ b/compiler_wrapper/compiler_wrapper.go @@ -108,14 +108,14 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int } rusageLogfileName := getRusageLogFilename(env) bisectStage := getBisectStage(env) - if shouldForceDisableWError(env) { + if newWarningsDir, ok := getNewWarningsDir(env, cfg); ok { if rusageLogfileName != "" { return 0, newUserErrorf("GETRUSAGE is meaningless with FORCE_DISABLE_WERROR") } if bisectStage != "" { return 0, newUserErrorf("BISECT_STAGE is meaningless with FORCE_DISABLE_WERROR") } - return doubleBuildWithWNoError(env, cfg, compilerCmd) + return doubleBuildWithWNoError(env, cfg, newWarningsDir, compilerCmd) } if shouldCompileWithFallback(env) { if rusageLogfileName != "" { diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go index 5f389684..70c27f06 100644 --- a/compiler_wrapper/config.go +++ b/compiler_wrapper/config.go @@ -14,6 +14,8 @@ type config struct { isAndroidWrapper bool // Whether to use ccache. useCCache bool + // Whether llvmNext wrapper. + useLlvmNext bool // Flags to add to gcc and clang. commonFlags []string // Flags to add to gcc only. @@ -83,6 +85,7 @@ func getConfig(configName string, useCCache bool, useLlvmNext bool, version stri return nil, newErrorwithSourceLocf("unknown config name: %s", configName) } cfg.useCCache = useCCache + cfg.useLlvmNext = useLlvmNext if useLlvmNext { cfg.clangFlags = append(cfg.clangFlags, llvmNextFlags...) } @@ -208,5 +211,5 @@ var androidConfig = &config{ gccFlags: []string{}, clangFlags: []string{}, clangPostFlags: []string{}, - newWarningsDir: "/tmp/fatal_clang_warnings", + newWarningsDir: "", } diff --git a/compiler_wrapper/disable_werror_flag.go b/compiler_wrapper/disable_werror_flag.go index 864397dd..0d68d560 100644 --- a/compiler_wrapper/disable_werror_flag.go +++ b/compiler_wrapper/disable_werror_flag.go @@ -9,16 +9,39 @@ import ( "encoding/json" "io/ioutil" "os" + "path" "strings" "syscall" ) -func shouldForceDisableWError(env env) bool { - value, _ := env.getenv("FORCE_DISABLE_WERROR") - return value != "" +func getNewWarningsDir(env env, cfg *config) (dirName string, ok bool) { + if cfg.isAndroidWrapper { + if cfg.useLlvmNext { + value, _ := env.getenv("OUT_DIR") + if value != "" { + return path.Join(value, "warnings_reports"), true + } + } + } else { + value, _ := env.getenv("FORCE_DISABLE_WERROR") + if value != "" { + return cfg.newWarningsDir, true + } + } + return "", false +} + +func disableWerrorFlags(originalArgs []string) []string { + noErrors := []string{"-Wno-error"} + for _, flag := range originalArgs { + if strings.HasPrefix(flag, "-Werror=") { + noErrors = append(noErrors, strings.Replace(flag, "-Werror", "-Wno-error", 1)) + } + } + return noErrors } -func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCode int, err error) { +func doubleBuildWithWNoError(env env, cfg *config, newWarningsDir string, originalCmd *command) (exitCode int, err error) { originalStdoutBuffer := &bytes.Buffer{} originalStderrBuffer := &bytes.Buffer{} // TODO: This is a bug in the old wrapper that it drops the ccache path @@ -44,7 +67,7 @@ func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCo retryStderrBuffer := &bytes.Buffer{} retryCommand := &command{ Path: originalCmd.Path, - Args: append(originalCmd.Args, "-Wno-error"), + Args: append(originalCmd.Args, disableWerrorFlags(originalCmd.Args)...), EnvUpdates: originalCmd.EnvUpdates, } retryExitCode, err := wrapSubprocessErrorWithSourceLoc(retryCommand, @@ -73,8 +96,8 @@ func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCo defer syscall.Umask(oldMask) // Allow root and regular users to write to this without issue. - if err := os.MkdirAll(cfg.newWarningsDir, 0777); err != nil { - return 0, wrapErrorwithSourceLocf(err, "error creating warnings directory %s", cfg.newWarningsDir) + if err := os.MkdirAll(newWarningsDir, 0777); err != nil { + return 0, wrapErrorwithSourceLocf(err, "error creating warnings directory %s", newWarningsDir) } // Have some tag to show that files aren't fully written. It would be sad if @@ -85,7 +108,7 @@ func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCo // Coming up with a consistent name for this is difficult (compiler command's // SHA can clash in the case of identically named files in different // directories, or similar); let's use a random one. - tmpFile, err := ioutil.TempFile(cfg.newWarningsDir, "warnings_report*.json"+incompleteSuffix) + tmpFile, err := ioutil.TempFile(newWarningsDir, "warnings_report*.json"+incompleteSuffix) if err != nil { return 0, wrapErrorwithSourceLocf(err, "error creating warnings file") } diff --git a/compiler_wrapper/disable_werror_flag_test.go b/compiler_wrapper/disable_werror_flag_test.go index fb25d193..eb907e6b 100644 --- a/compiler_wrapper/disable_werror_flag_test.go +++ b/compiler_wrapper/disable_werror_flag_test.go @@ -11,6 +11,7 @@ import ( "io" "io/ioutil" "os" + "path" "path/filepath" "strings" "testing" @@ -372,3 +373,46 @@ func TestDoubleBuildWerrorChmodsThingsAppropriately(t *testing.T) { } }) } + +func TestAndroidGetNewWarningsDir(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + outDir := "/foo/bar" + expectedDir := path.Join(outDir, "warnings_reports") + + ctx.env = []string{"OUT_DIR=" + outDir} + ctx.cfg.isAndroidWrapper = true + + // Disable werror ON + ctx.cfg.useLlvmNext = true + dir, ok := getNewWarningsDir(ctx, ctx.cfg) + if !ok || dir != expectedDir { + t.Errorf("disable Werror not enabled for Android with useLlvmNext (dirName=%q ok=%t), expectedDir=%q", dir, ok, expectedDir) + } + + // Disable werror OFF + ctx.cfg.useLlvmNext = false + dir, ok = getNewWarningsDir(ctx, ctx.cfg) + if ok || dir != "" { + t.Errorf("disable Werror incorrectly enabled for Android without useLlvmNext (dirName=%q ok=%t)", dir, ok) + } + }) +} + +func TestChromeOSGetNewWarningsDirOn(t *testing.T) { + withForceDisableWErrorTestContext(t, func(ctx *testContext) { + dir, ok := getNewWarningsDir(ctx, ctx.cfg) + if !ok || dir != ctx.cfg.newWarningsDir { + t.Errorf("disable Werror not enabled for ChromeOS with FORCE_DISABLE_WERROR set (dirName=%q ok=%t) expectedDir=%q", dir, ok, ctx.cfg.newWarningsDir) + } + + }) +} + +func TestChromeOSGetNewWarningsDirOff(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + dir, ok := getNewWarningsDir(ctx, ctx.cfg) + if ok || dir != "" { + t.Errorf("disable Werror incorrectly enabled for ChromeOS without FORCE_DISABLE_WERROR set (dirName=%q ok=%t)", dir, ok) + } + }) +} diff --git a/compiler_wrapper/rusage_flag.go b/compiler_wrapper/rusage_flag.go index 2a3768c1..690308b2 100644 --- a/compiler_wrapper/rusage_flag.go +++ b/compiler_wrapper/rusage_flag.go @@ -18,6 +18,26 @@ func getRusageLogFilename(env env) string { return value } +func lockFileExclusive(fd uintptr) error { + maxTries := 100 + for i := 0; i < maxTries; i++ { + const seekSet = 0 + err := syscall.FcntlFlock(fd, syscall.F_SETLKW, &syscall.Flock_t{ + Type: syscall.F_WRLCK, + Whence: seekSet, + Start: 0, + Len: 0, + }) + if err == nil { + return nil + } + if err != syscall.EINTR { + return fmt.Errorf("locking file: %v", err) + } + } + return fmt.Errorf("locking file failed after %d tries", maxTries) +} + func logRusage(env env, logFileName string, compilerCmd *command) (exitCode int, err error) { rusageBefore := syscall.Rusage{} if err := syscall.Getrusage(syscall.RUSAGE_CHILDREN, &rusageBefore); err != nil { @@ -49,21 +69,35 @@ func logRusage(env env, logFileName string, compilerCmd *command) (exitCode int, if err := os.MkdirAll(filepath.Dir(logFileName), 0777); err != nil { return 0, wrapErrorwithSourceLocf(err, "error creating rusage log directory %s", logFileName) } + + timeUnit := float64(time.Second) + data := fmt.Sprintf("%.5f : %.5f : %.5f : %d : %s : %s\n", + float64(elapsedRealTime)/timeUnit, float64(elapsedUserTime)/timeUnit, float64(elapsedSysTime)/timeUnit, + maxMemUsed, absCompilerPath, + strings.Join(append([]string{filepath.Base(absCompilerPath)}, compilerCmd.Args...), " ")) + // Note: using file mode 0666 so that a root-created log is writable by others. logFile, err := os.OpenFile(logFileName, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666) if err != nil { - return 0, wrapErrorwithSourceLocf(err, "error creating rusage logfile %s", logFileName) + return 0, wrapErrorwithSourceLocf(err, "creating rusage logfile %s", logFileName) } - timeUnit := float64(time.Second) - if _, err := fmt.Fprintf(logFile, "%.5f : %.5f : %.5f : %d : %s : %s\n", - float64(elapsedRealTime)/timeUnit, float64(elapsedUserTime)/timeUnit, float64(elapsedSysTime)/timeUnit, - maxMemUsed, absCompilerPath, - strings.Join(append([]string{filepath.Base(absCompilerPath)}, compilerCmd.Args...), " ")); err != nil { + + // O_APPEND's atomicity guarantees are only for writes up to a certain size. If we don't + // lock the file, we might end up with corrupted records. + // + // Note that Close()'ing the file releases all associated locks. + if err := lockFileExclusive(logFile.Fd()); err != nil { _ = logFile.Close() - return 0, wrapErrorwithSourceLocf(err, "error writing rusage logfile %s", logFileName) + return 0, wrapErrorwithSourceLocf(err, "locking rusage logfile %s: %v", logFileName, err) + } + + _, err = logFile.WriteString(data) + closeErr := logFile.Close() + if err != nil { + return 0, wrapErrorwithSourceLocf(err, "writing to rusage logfile %s: %v", logFileName, err) } - if err := logFile.Close(); err != nil { - return 0, wrapErrorwithSourceLocf(err, "error closing rusage logfile %s", logFileName) + if closeErr != nil { + return 0, wrapErrorwithSourceLocf(err, "closing rusage logfile %s: %v", logFileName, closeErr) } return exitCode, nil diff --git a/compiler_wrapper/testdata/android_golden/bisect.json b/compiler_wrapper/testdata/android_golden/bisect.json index 25df7f17..a1ffc50b 100644 --- a/compiler_wrapper/testdata/android_golden/bisect.json +++ b/compiler_wrapper/testdata/android_golden/bisect.json @@ -18,9 +18,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "/user/home/ANDROID_BISECT", "/tmp/stable/clang.real", @@ -53,9 +53,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/tmp/stable/clang.real", @@ -91,9 +91,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/tmp/stable/clang.real", diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json b/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json index 28adfee2..437cae52 100644 --- a/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json +++ b/compiler_wrapper/testdata/cros_clang_host_golden/bisect.json @@ -18,9 +18,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "/tmp/sysroot_bisect", "/tmp/stable/clang", @@ -67,9 +67,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/tmp/stable/clang", @@ -119,9 +119,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/tmp/stable/clang", 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 248fcb4b..2393e71a 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 @@ -94,7 +94,8 @@ "-Wno-unknown-warning-option", "main.cc", "-Wno-implicit-int-float-conversion", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ] } } @@ -159,7 +160,8 @@ "-Wno-unknown-warning-option", "main.cc", "-Wno-implicit-int-float-conversion", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ] }, "stdout": "somemessage", diff --git a/compiler_wrapper/testdata/cros_hardened_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_golden/bisect.json index b00f9740..a6ac7a19 100644 --- a/compiler_wrapper/testdata/cros_hardened_golden/bisect.json +++ b/compiler_wrapper/testdata/cros_hardened_golden/bisect.json @@ -18,9 +18,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "/tmp/sysroot_bisect", "/usr/bin/ccache", @@ -81,9 +81,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/ccache", @@ -147,9 +147,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/ccache", 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 f975f452..f796764a 100644 --- a/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json +++ b/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json @@ -136,7 +136,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ], "env_updates": [ "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", @@ -233,7 +234,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ], "env_updates": [ "CCACHE_BASEDIR=/usr/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 b00f9740..a6ac7a19 100644 --- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json @@ -18,9 +18,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "/tmp/sysroot_bisect", "/usr/bin/ccache", @@ -81,9 +81,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/ccache", @@ -147,9 +147,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/ccache", 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 f975f452..f796764a 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 @@ -136,7 +136,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ], "env_updates": [ "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", @@ -233,7 +234,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ], "env_updates": [ "CCACHE_BASEDIR=/usr/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 5075f843..ac9beb55 100644 --- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json +++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/bisect.json @@ -18,9 +18,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "/tmp/sysroot_bisect", "/usr/bin/clang", @@ -76,9 +76,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/clang", @@ -137,9 +137,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/clang", 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 59dfb93e..078c05da 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 @@ -121,7 +121,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ] } } @@ -204,7 +205,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ] }, "stdout": "somemessage", diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json b/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json index cb5dea01..22ba14c0 100644 --- a/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json +++ b/compiler_wrapper/testdata/cros_nonhardened_golden/bisect.json @@ -18,9 +18,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "/tmp/sysroot_bisect", "/usr/bin/ccache", @@ -73,9 +73,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/ccache", @@ -131,9 +131,9 @@ "cmd": { "path": "/usr/bin/env", "args": [ - "python", + "python3", "-c", - "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'rb') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", + "\nimport bisect_driver\nimport shlex\nimport sys\n\ndef ExpandArgs(args, target):\n\tfor arg in args:\n\t\tif arg[0] == '@':\n\t\t\twith open(arg[1:], 'r', encoding='utf-8') as f:\n\t\t\t\tExpandArgs(shlex.split(f.read()), target)\n\t\telse:\n\t\t\ttarget.append(arg)\n\treturn target\n\nstage = sys.argv[1]\ndir = sys.argv[2]\nexecargs = ExpandArgs(sys.argv[3:], [])\n\nsys.exit(bisect_driver.bisect_driver(stage, dir, execargs))\n", "someBisectStage", "someBisectDir", "/usr/bin/ccache", 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 787ce95d..9787e8a6 100644 --- a/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json +++ b/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json @@ -112,7 +112,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ], "env_updates": [ "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", @@ -193,7 +194,8 @@ "-B../../bin", "-target", "x86_64-cros-linux-gnu", - "-Wno-error" + "-Wno-error", + "-Wno-error=poison-system-directories" ], "env_updates": [ "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", diff --git a/cros_utils/buildbot_utils.py b/cros_utils/buildbot_utils.py index a06abd26..428433db 100644 --- a/cros_utils/buildbot_utils.py +++ b/cros_utils/buildbot_utils.py @@ -27,7 +27,6 @@ TIME_OUT = 43200 # Decide the build is dead or will never finish class BuildbotTimeout(Exception): """Exception to throw when a buildbot operation timesout.""" - pass def RunCommandInPath(path, cmd): diff --git a/cros_utils/command_executer.py b/cros_utils/command_executer.py index 39bff5ed..002aa754 100755 --- a/cros_utils/command_executer.py +++ b/cros_utils/command_executer.py @@ -240,10 +240,9 @@ class CommandExecuter(object): return command def WriteToTempShFile(self, contents): - # TODO(crbug.com/1048938): use encoding='utf-8' when all dependencies have - # migrated to python 3. with tempfile.NamedTemporaryFile( - 'w', delete=False, prefix=os.uname()[1], suffix='.sh') as f: + 'w', encoding='utf-8', delete=False, prefix=os.uname()[1], + suffix='.sh') as f: f.write('#!/bin/bash\n') f.write(contents) f.flush() @@ -367,10 +366,9 @@ class CommandExecuter(object): if self.logger: self.logger.LogCmd(command, print_to_console=print_to_console) - # TODO(crbug.com/1048938): use encoding='utf-8' when all dependencies have - # migrated to python 3. with tempfile.NamedTemporaryFile( 'w', + encoding='utf-8', delete=False, dir=os.path.join(chromeos_root, 'src/scripts'), suffix='.sh', diff --git a/cros_utils/device_setup_utils_unittest.py b/cros_utils/device_setup_utils_unittest.py index 63f9bf66..12a70811 100755 --- a/cros_utils/device_setup_utils_unittest.py +++ b/cros_utils/device_setup_utils_unittest.py @@ -14,10 +14,9 @@ import time import unittest from unittest import mock -from device_setup_utils import DutWrapper - from cros_utils import command_executer from cros_utils import logger +from cros_utils.device_setup_utils import DutWrapper BIG_LITTLE_CPUINFO = """processor : 0 model name : ARMv8 Processor rev 4 (v8l) diff --git a/cros_utils/logger.py b/cros_utils/logger.py index 4cc4618e..e304fe12 100644 --- a/cros_utils/logger.py +++ b/cros_utils/logger.py @@ -207,7 +207,6 @@ class MockLogger(object): def __init__(self, *_args, **_kwargs): self.stdout = sys.stdout self.stderr = sys.stderr - return None def _AddSuffix(self, basename, suffix): return '%s%s' % (basename, suffix) diff --git a/cros_utils/misc.py b/cros_utils/misc.py index 246767f0..b4beb60c 100644 --- a/cros_utils/misc.py +++ b/cros_utils/misc.py @@ -462,7 +462,7 @@ def ApplyGerritPatches(chromeos_root, gerrit_patch_string, sys.path.append(os.path.join(chromeos_root, 'chromite')) # Imports below are ok after modifying path to add chromite. # Pylint cannot detect that and complains. - # pylint: disable=import-error + # pylint: disable=import-error, import-outside-toplevel from lib import git from lib import gerrit manifest = git.ManifestCheckout(chromeos_root) diff --git a/cros_utils/tabulator.py b/cros_utils/tabulator.py index 300c2d79..5029ceee 100644 --- a/cros_utils/tabulator.py +++ b/cros_utils/tabulator.py @@ -318,7 +318,7 @@ class SamplesTableGenerator(TableGenerator): v.append(None) run_fail += 1 one_tuple = ((run_pass, run_fail), v) - if iterations != 0 and iterations != run_pass + run_fail: + if iterations not in (0, run_pass + run_fail): raise ValueError('Iterations of each benchmark run ' \ 'are not the same') iterations = run_pass + run_fail @@ -358,7 +358,7 @@ class SamplesTableGenerator(TableGenerator): # Accumulate each run result to composite benchmark run # If any run fails, then we set this run for composite benchmark # to None so that we know it fails. - if bench_runs[index] and row[label_index][index] != None: + if bench_runs[index] and row[label_index][index] is not None: row[label_index][index] += bench_runs[index] else: row[label_index][index] = None @@ -557,12 +557,10 @@ class AmeanResult(StringMeanResult): class RawResult(Result): """Raw result.""" - pass class IterationResult(Result): """Iteration result.""" - pass class MinResult(Result): diff --git a/crosperf/experiment_factory.py b/crosperf/experiment_factory.py index 4527db5f..3b1ed614 100644 --- a/crosperf/experiment_factory.py +++ b/crosperf/experiment_factory.py @@ -229,8 +229,8 @@ class ExperimentFactory(object): iterations = benchmark_settings.GetField('iterations') if cwp_dso: - if cwp_dso_iterations != 0 and iterations != cwp_dso_iterations: - raise RuntimeError('Iterations of each benchmark run are not the ' \ + if cwp_dso_iterations not in (0, iterations): + raise RuntimeError('Iterations of each benchmark run are not the ' 'same') cwp_dso_iterations = iterations diff --git a/crosperf/experiment_file.py b/crosperf/experiment_file.py index 1d89edad..d2831bda 100644 --- a/crosperf/experiment_file.py +++ b/crosperf/experiment_file.py @@ -95,7 +95,8 @@ class ExperimentFile(object): if not line: continue - elif ExperimentFile._FIELD_VALUE_RE.match(line): + + if ExperimentFile._FIELD_VALUE_RE.match(line): field = self._ParseField(reader) settings.SetField(field[0], field[1], field[2]) elif ExperimentFile._CLOSE_SETTINGS_RE.match(line): @@ -113,7 +114,8 @@ class ExperimentFile(object): if not line: continue - elif ExperimentFile._OPEN_SETTINGS_RE.match(line): + + if ExperimentFile._OPEN_SETTINGS_RE.match(line): new_settings, settings_type = self._ParseSettings(reader) # We will allow benchmarks with duplicated settings name for now. # Further decision will be made when parsing benchmark details in diff --git a/crosperf/machine_manager.py b/crosperf/machine_manager.py index 7211662c..0b38eef2 100644 --- a/crosperf/machine_manager.py +++ b/crosperf/machine_manager.py @@ -28,12 +28,10 @@ CHECKSUM_FILE = '/usr/local/osimage_checksum_file' class BadChecksum(Exception): """Raised if all machines for a label don't have the same checksum.""" - pass class BadChecksumString(Exception): """Raised if all machines for a label don't have the same checksum string.""" - pass class MissingLocksDirectory(Exception): @@ -298,8 +296,8 @@ class MachineManager(object): retval = image_chromeos.DoImage(image_chromeos_args) if retval: raise RuntimeError("Could not image machine: '%s'." % machine.name) - else: - self.num_reimages += 1 + + self.num_reimages += 1 machine.checksum = checksum machine.image = label.chromeos_image machine.label = label diff --git a/crosperf/results_report_templates.py b/crosperf/results_report_templates.py index 3c5258c9..ea411e21 100644 --- a/crosperf/results_report_templates.py +++ b/crosperf/results_report_templates.py @@ -6,7 +6,7 @@ """Text templates used by various parts of results_report.""" from __future__ import print_function -import cgi +import html from string import Template _TabMenuTemplate = Template(""" @@ -19,7 +19,7 @@ _TabMenuTemplate = Template(""" def _GetTabMenuHTML(table_name): # N.B. cgi.escape does some very basic HTML escaping. Nothing more. - escaped = cgi.escape(table_name, quote=True) + escaped = html.escape(table_name) return _TabMenuTemplate.substitute(table_name=escaped) @@ -35,7 +35,7 @@ _ExperimentFileHTML = """ def _GetExperimentFileHTML(experiment_file_text): if not experiment_file_text: return '' - return _ExperimentFileHTML % (cgi.escape(experiment_file_text),) + return _ExperimentFileHTML % (html.escape(experiment_file_text, quote=False),) _ResultsSectionHTML = Template(""" diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py index 79ace20d..62a85cc6 100644 --- a/crosperf/suite_runner.py +++ b/crosperf/suite_runner.py @@ -166,11 +166,10 @@ class SuiteRunner(object): # process namespace and we can kill process created easily by their # process group. chrome_root_options = ('--no-ns-pid ' - '--chrome_root={} --chrome_root_mount={} ' + '--chrome_root={0} --chrome_root_mount={1} ' 'FEATURES="-usersandbox" ' - 'CHROME_ROOT={}'.format(label.chrome_src, - CHROME_MOUNT_DIR, - CHROME_MOUNT_DIR)) + 'CHROME_ROOT={1}'.format(label.chrome_src, + CHROME_MOUNT_DIR)) if self.log_level != 'verbose': self.logger.LogOutput('Running test.') diff --git a/lock_machine.py b/lock_machine.py index 06c0e80c..2948381d 100755 --- a/lock_machine.py +++ b/lock_machine.py @@ -518,12 +518,6 @@ def Main(argv): lock_manager.CheckMachineLocks(machine_states, cmd) lock_manager.UpdateMachines(False) - elif cmd == 'add': - lock_manager.AddMachinesToLocalServer() - - elif cmd == 'remove': - lock_manager.RemoveMachinesFromLocalServer() - return 0 |