aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/vcs/linux_test.go
blob: 5e81760a2317704f1273bb5a07b8566cdb873a56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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.16"] = true
	actual = linuxGCCPath(tags, binDir, defaultCompiler)
	expected = defaultCompiler
	assert.Equal(t, actual, expected, "unexpected gcc path")
}