github.com/containers/podman/v4@v4.9.4/pkg/machine/e2e/config_windows_test.go (about) 1 package e2e_test 2 3 import ( 4 "fmt" 5 "os/exec" 6 "strings" 7 8 "github.com/containers/podman/v4/pkg/machine" 9 "github.com/containers/podman/v4/pkg/machine/wsl" 10 . "github.com/onsi/ginkgo/v2" 11 ) 12 13 const podmanBinary = "../../../bin/windows/podman.exe" 14 15 func getDownloadLocation(_ machine.VirtProvider) string { 16 fd, err := wsl.NewFedoraDownloader(machine.WSLVirt, "", defaultStream.String()) 17 if err != nil { 18 Fail("unable to get WSL virtual image") 19 } 20 return fd.Get().URL.String() 21 } 22 23 // pgrep emulates the pgrep linux command 24 func pgrep(n string) (string, error) { 25 // add filter to find the process and do no display a header 26 args := []string{"/fi", fmt.Sprintf("IMAGENAME eq %s", n), "/nh"} 27 out, err := exec.Command("tasklist.exe", args...).Output() 28 if err != nil { 29 return "", err 30 } 31 strOut := string(out) 32 // in pgrep, if no running process is found, it exits 1 and the output is zilch 33 if strings.Contains(strOut, "INFO: No tasks are running which match the specified search") { 34 return "", fmt.Errorf("no task found") 35 } 36 return strOut, nil 37 }