github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/pkg/vcs/linux_test.go (about)

     1  // Copyright 2022 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package vcs
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestClangVersion(t *testing.T) {
    13  	defaultCompiler := "/some/default/compiler"
    14  	binDir := "/some/dir/"
    15  	tags := make(map[string]bool)
    16  
    17  	// No tags case.
    18  	actual := linuxClangPath(tags, binDir, defaultCompiler)
    19  	expected := binDir + "llvm-9.0.1/bin/clang"
    20  	assert.Equal(t, actual, expected, "unexpected clang path")
    21  
    22  	// Older tag case.
    23  	tags["v5.9"] = true
    24  	actual = linuxClangPath(tags, binDir, defaultCompiler)
    25  	expected = "clang-15"
    26  	assert.Equal(t, actual, expected, "unexpected clang path")
    27  
    28  	// Recent tag case.
    29  	tags["v6.15"] = true
    30  	actual = linuxClangPath(tags, binDir, defaultCompiler)
    31  	expected = defaultCompiler
    32  	assert.Equal(t, actual, expected, "unexpected clang path")
    33  }
    34  
    35  func TestGCCVersion(t *testing.T) {
    36  	defaultCompiler := "/some/default/compiler"
    37  	binDir := "/some/dir/"
    38  	tags := make(map[string]bool)
    39  
    40  	// No tags case.
    41  	actual := linuxGCCPath(tags, binDir, defaultCompiler)
    42  	expected := binDir + "gcc-5.5.0/bin/gcc"
    43  	assert.Equal(t, actual, expected, "unexpected gcc path")
    44  
    45  	// Somewhat old tag case.
    46  	tags["v4.12"] = true
    47  	actual = linuxGCCPath(tags, binDir, defaultCompiler)
    48  	expected = binDir + "gcc-8.1.0/bin/gcc"
    49  	assert.Equal(t, actual, expected, "unexpected gcc path")
    50  
    51  	// Recent tag case.
    52  	tags["v5.16"] = true
    53  	actual = linuxGCCPath(tags, binDir, defaultCompiler)
    54  	expected = defaultCompiler
    55  	assert.Equal(t, actual, expected, "unexpected gcc path")
    56  }