Files
podman/pkg/machine/e2e/config_windows_test.go
Brent Baude 9cbb64c525 Use fake images for machine tests
In tests that do not start a machine, we can use "fake" images to speed
up tests.  In the case of darwin and Linux, that can be /dev/null.  The
hypervisors don't care.

In the case of Windows, some research will need to be done to determine
the same approach but this is a start.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-11-10 10:51:23 -06:00

48 lines
1.3 KiB
Go

package e2e_test
import (
"fmt"
"os/exec"
"strings"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega/gexec"
)
const podmanBinary = "../../../bin/windows/podman.exe"
// pgrep emulates the pgrep linux command
func pgrep(n string) (string, error) {
// add filter to find the process and do no display a header
args := []string{"/fi", fmt.Sprintf("IMAGENAME eq %s", n), "/nh"}
out, err := exec.Command("tasklist.exe", args...).Output()
if err != nil {
return "", err
}
strOut := string(out)
// in pgrep, if no running process is found, it exits 1 and the output is zilch
if strings.Contains(strOut, "INFO: No tasks are running which match the specified search") {
return "", fmt.Errorf("no task found")
}
return strOut, nil
}
func runWslCommand(cmdArgs []string) (*machineSession, error) {
binary := "wsl"
GinkgoWriter.Println(binary + " " + strings.Join(cmdArgs, " "))
c := exec.Command(binary, cmdArgs...)
session, err := Start(c, GinkgoWriter, GinkgoWriter)
if err != nil {
Fail(fmt.Sprintf("Unable to start session: %q", err))
return nil, err
}
ms := machineSession{session}
ms.waitWithTimeout(defaultTimeout)
return &ms, nil
}
func (i *initMachine) withFakeImage(_ *machineTestBuilder) *initMachine {
i.image = mb.imagePath
return i
}