From 953fda060f317c2389ef6fd1cac8806a2bfe92ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paolo=20Chil=C3=A0?= Date: Mon, 29 May 2023 16:01:04 +0200 Subject: [PATCH] Avoid SEGFAULT when cleaning up installation in integration tests fixture (#2741) --- pkg/testing/fixture_install.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/testing/fixture_install.go b/pkg/testing/fixture_install.go index 88b138735d2..692cb3c7819 100644 --- a/pkg/testing/fixture_install.go +++ b/pkg/testing/fixture_install.go @@ -68,7 +68,9 @@ func (i InstallOpts) toCmdArgs() []string { // Install installs the prepared Elastic Agent binary func (f *Fixture) Install(ctx context.Context, installOpts *InstallOpts, opts ...process.CmdOption) ([]byte, error) { installArgs := []string{"install"} - installArgs = append(installArgs, installOpts.toCmdArgs()...) + if installOpts != nil { + installArgs = append(installArgs, installOpts.toCmdArgs()...) + } out, err := f.Exec(ctx, installArgs, opts...) if err != nil { return nil, err @@ -111,7 +113,9 @@ func (f *Fixture) Uninstall(ctx context.Context, uninstallOpts *UninstallOpts, o } uninstallArgs := []string{"uninstall"} - uninstallArgs = append(uninstallArgs, uninstallOpts.toCmdArgs()...) + if uninstallOpts != nil { + uninstallArgs = append(uninstallArgs, uninstallOpts.toCmdArgs()...) + } out, err := f.Exec(ctx, uninstallArgs, opts...) if err != nil { return nil, err