From 1b201b48c59d619af21de7fcc5face22824c0285 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 16 Jul 2021 15:32:28 +0000 Subject: 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. --- pkg/build/linux_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'pkg/build/linux_test.go') 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:]) -- cgit mrf-deployment