forked from 0xPolygon/polygon-edge
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TestServer: kill process group * fix lint * Makefile test add '-count=1' ignore cache * Makefile test command add build dependency * Ctrl-C kill process group * fix mockStore.GetReceiptsByHash concurrent error * never release reserved port * never use the same port * fix lint * build tag support unix environment
- Loading branch information
Showing
8 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos | ||
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos | ||
|
||
package framework | ||
|
||
import ( | ||
"os/exec" | ||
) | ||
|
||
func registerPID(cmd *exec.Cmd) { | ||
// ignore | ||
} | ||
|
||
func execCommand(workdir, name string, args ...string) *exec.Cmd { | ||
cmd := exec.Command(binaryName, args...) | ||
cmd.Dir = workdir | ||
|
||
return cmd | ||
} | ||
|
||
func processKill(cmd *exec.Cmd) error { | ||
return cmd.Process.Kill() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos | ||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos | ||
|
||
package framework | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"os/exec" | ||
"os/signal" | ||
"syscall" | ||
) | ||
|
||
var pids = []int{} | ||
|
||
func init() { | ||
go func() { | ||
// wait os.Interrupt signal | ||
c := make(chan os.Signal, 1) | ||
signal.Notify(c, os.Interrupt) | ||
|
||
for sig := range c { | ||
if sig == os.Interrupt { | ||
// kill the whole process group | ||
for _, pid := range pids { | ||
_ = syscall.Kill(-pid, syscall.SIGKILL) | ||
} | ||
} | ||
|
||
os.Exit(1) | ||
} | ||
}() | ||
} | ||
|
||
func registerPID(cmd *exec.Cmd) { | ||
pids = append(pids, cmd.Process.Pid) | ||
} | ||
|
||
func execCommand(workdir, name string, args ...string) *exec.Cmd { | ||
cmd := exec.Command(binaryName, args...) | ||
cmd.SysProcAttr = &syscall.SysProcAttr{ | ||
Setpgid: true, | ||
Pgid: 0, | ||
} | ||
cmd.Dir = workdir | ||
|
||
return cmd | ||
} | ||
|
||
func processKill(cmd *exec.Cmd) error { | ||
// kill the whole process group | ||
err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL) | ||
if errors.Is(syscall.ESRCH, err) { | ||
return nil | ||
} | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package framework | ||
|
||
import ( | ||
"os/exec" | ||
) | ||
|
||
func registerPID(cmd *exec.Cmd) { | ||
// ignore | ||
} | ||
|
||
func execCommand(workdir, name string, args ...string) *exec.Cmd { | ||
cmd := exec.Command(binaryName, args...) | ||
cmd.Dir = workdir | ||
|
||
return cmd | ||
} | ||
|
||
func processKill(cmd *exec.Cmd) error { | ||
return cmd.Process.Kill() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters