diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2021-07-16 15:32:28 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2021-07-20 13:39:45 +0200 |
| commit | 1b201b48c59d619af21de7fcc5face22824c0285 (patch) | |
| tree | e0e7dec8e2b626a61ce6ef0a9aebf47dad108190 /pkg/build/linux_test.go | |
| parent | 5a171d724fb4a90890e868348e85c03646cdedab (diff) | |
pkg/build/linux: add compiler detection
Detect compiler that was used to build the Linux kernel from
auto-generated header files. This would be the most precise information.
Diffstat (limited to 'pkg/build/linux_test.go')
| -rw-r--r-- | pkg/build/linux_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/build/linux_test.go b/pkg/build/linux_test.go index 0babee967..63614e023 100644 --- a/pkg/build/linux_test.go +++ b/pkg/build/linux_test.go @@ -22,6 +22,23 @@ func TestElfBinarySignature(t *testing.T) { enumerateFlags(t, nil, []string{"-g", "-O1", "-O2", "-no-pie", "-static"}) } +func TestQueryLinuxCompiler(t *testing.T) { + const goodDir = "./testdata/linux_compiler_ok" + const expectedCompiler = "gcc (Debian 10.2.1-6+build2) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2" + ret, err := queryLinuxCompiler(goodDir) + if err != nil { + t.Fatalf("error: %v", err) + } + if ret != expectedCompiler { + t.Fatalf("got: %T, expected: %T", ret, expectedCompiler) + } + const badDir = "./testingData/non_existing_folder" + _, err = queryLinuxCompiler(badDir) + if err == nil { + t.Fatalf("Expected an error, got none") + } +} + func enumerateFlags(t *testing.T, flags, allFlags []string) { if len(allFlags) != 0 { enumerateFlags(t, flags, allFlags[1:]) |
