github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/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  	// Recent tag case.
    23  	tags["v5.9"] = true
    24  	actual = linuxClangPath(tags, binDir, defaultCompiler)
    25  	expected = defaultCompiler
    26  	assert.Equal(t, actual, expected, "unexpected clang path")
    27  }
    28  
    29  func TestGCCVersion(t *testing.T) {
    30  	defaultCompiler := "/some/default/compiler"
    31  	binDir := "/some/dir/"
    32  	tags := make(map[string]bool)
    33  
    34  	// No tags case.
    35  	actual := linuxGCCPath(tags, binDir, defaultCompiler)
    36  	expected := binDir + "gcc-5.5.0/bin/gcc"
    37  	assert.Equal(t, actual, expected, "unexpected gcc path")
    38  
    39  	// Somewhat old tag case.
    40  	tags["v4.12"] = true
    41  	actual = linuxGCCPath(tags, binDir, defaultCompiler)
    42  	expected = binDir + "gcc-8.1.0/bin/gcc"
    43  	assert.Equal(t, actual, expected, "unexpected gcc path")
    44  
    45  	// Recent tag case.
    46  	tags["v5.16"] = true
    47  	actual = linuxGCCPath(tags, binDir, defaultCompiler)
    48  	expected = defaultCompiler
    49  	assert.Equal(t, actual, expected, "unexpected gcc path")
    50  }