From 845969b9909389f2583a8e9a2bb21dfd9099a650 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:01:43 +0100 Subject: [PATCH] auditbeat - skip TestExeObjParser on CI (#38441) (#38461) TestExeObjParser fails on Windows because Defender is removing the testdata that is required by the test. This adds a conditional test skip for CI when those files are missing. Closes #38211 (cherry picked from commit 08e59363b6410f1701c9902858b3c0149556ff10) Co-authored-by: Andrew Kroh --- auditbeat/module/file_integrity/exeobjparser_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/auditbeat/module/file_integrity/exeobjparser_test.go b/auditbeat/module/file_integrity/exeobjparser_test.go index 0958305afb8..f8ca144e4ed 100644 --- a/auditbeat/module/file_integrity/exeobjparser_test.go +++ b/auditbeat/module/file_integrity/exeobjparser_test.go @@ -19,8 +19,11 @@ package file_integrity import ( + "errors" "fmt" + "io/fs" "math" + "os" "reflect" "strconv" "testing" @@ -44,6 +47,12 @@ func TestExeObjParser(t *testing.T) { t.Skip("skipping test on garbled PE file: see https://github.com/elastic/beats/issues/35705") } + if _, ci := os.LookupEnv("CI"); ci { + if _, err := os.Stat(target); err != nil && errors.Is(fs.ErrNotExist, err) { + t.Skip("skipping test because target binary was not found: see https://github.com/elastic/beats/issues/38211") + } + } + got := make(mapstr.M) err := exeObjParser(nil).Parse(got, target) if err != nil {