Home | History | Annotate | Download | only in build
      1 // Copyright 2017 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 build
      5 
      6 import (
      7 	"os/exec"
      8 	"strings"
      9 	"testing"
     10 )
     11 
     12 func TestCompilerIdentity(t *testing.T) {
     13 	t.Parallel()
     14 	for _, compiler := range []string{"gcc", "clang", "bazel"} {
     15 		compiler := compiler
     16 		t.Run(compiler, func(t *testing.T) {
     17 			t.Parallel()
     18 			if _, err := exec.LookPath(compiler); err != nil {
     19 				t.Skipf("compiler '%v' is not found: %v", compiler, err)
     20 			}
     21 			id, err := CompilerIdentity(compiler)
     22 			if err != nil {
     23 				t.Fatalf("failed: %v", err)
     24 			}
     25 			if len(id) == 0 {
     26 				t.Fatalf("identity is empty")
     27 			}
     28 			if strings.Contains(id, "\n") {
     29 				t.Fatalf("identity contains a new line")
     30 			}
     31 			// We don't know what's the right answer,
     32 			// so just print it for manual inspection.
     33 			t.Logf("id: '%v'", id)
     34 		})
     35 	}
     36 }
     37