From 79a5963585ac032cd3f390a37b5d276f7f9d0b5c Mon Sep 17 00:00:00 2001 From: Space Meyer Date: Tue, 13 Sep 2022 15:24:23 +0000 Subject: pkg/bisect: use default compiler during bisection where possible This allows us to bisect at least recently introduced bugs, where the manager that found the bug uses a non standard compiler. This is usefull during development of a new sanitizer for which a compiler with non-upstreamed patches is required. --- pkg/vcs/linux_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkg/vcs/linux_test.go (limited to 'pkg/vcs/linux_test.go') diff --git a/pkg/vcs/linux_test.go b/pkg/vcs/linux_test.go new file mode 100644 index 000000000..1865aa2d6 --- /dev/null +++ b/pkg/vcs/linux_test.go @@ -0,0 +1,50 @@ +// Copyright 2022 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package vcs + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestClangVersion(t *testing.T) { + defaultCompiler := "/some/default/compiler" + binDir := "/some/dir/" + tags := make(map[string]bool) + + // No tags case. + actual := linuxClangPath(tags, binDir, defaultCompiler) + expected := binDir + "llvm-9.0.1/bin/clang" + assert.Equal(t, actual, expected, "unexpected clang path") + + // Recent tag case. + tags["v5.9"] = true + actual = linuxClangPath(tags, binDir, defaultCompiler) + expected = defaultCompiler + assert.Equal(t, actual, expected, "unexpected clang path") +} + +func TestGCCVersion(t *testing.T) { + defaultCompiler := "/some/default/compiler" + binDir := "/some/dir/" + tags := make(map[string]bool) + + // No tags case. + actual := linuxGCCPath(tags, binDir, defaultCompiler) + expected := binDir + "gcc-5.5.0/bin/gcc" + assert.Equal(t, actual, expected, "unexpected gcc path") + + // Somewhat old tag case. + tags["v4.12"] = true + actual = linuxGCCPath(tags, binDir, defaultCompiler) + expected = binDir + "gcc-8.1.0/bin/gcc" + assert.Equal(t, actual, expected, "unexpected gcc path") + + // Recent tag case. + tags["v5.9"] = true + actual = linuxGCCPath(tags, binDir, defaultCompiler) + expected = defaultCompiler + assert.Equal(t, actual, expected, "unexpected gcc path") +} -- cgit mrf-deployment