proc: main's two reds, the TUI's serve start through proc.Command (#3567) and an RSS read before the loader ran
Test (ubuntu, macos) on main has been red since 75e78a5a0 on two tests.
TestNoCommandBypassesProc: internal/tui/keep.go's serveInBackground
started `magpie serve` with os/exec. It is proc.Command now, the fix
skygunner gave on #3567 (64bd29fa on their fork). Off Windows
proc.Command is exec.Command, and this path runs on Linux only, so
nothing else changes.
TestTreeRSS (ubuntu only): the test read sleep's VmRSS right after
StartTree and wanted at least 64 KiB. Just after its exec a command
holds a few pages until its loader maps libc: CI read 16384 bytes. The
test now reads again until it holds 64 KiB, for up to 10s. Tree.RSS
itself is unchanged.
Run at this head:
- golang:1.26 docker (Linux, CI's Go): TestTreeRSS -count=50,
old test red 13 of 50 ("a running sleep holds ..."), new 50 of 50 ok.
- macOS: go test -count=3 ./internal/proc ./internal/tui ok (the old
keep.go is the guard's red on CI's runs 40199986992 and earlier).
- GOOS=linux and GOOS=windows go vet -tags nogui on both packages,
gofmt clean.
Not run: the full suite.
Co-authored-by: skygunner <skygunner@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A running tree's resident memory is read, and none once it was waited
|
||||
@@ -20,7 +21,13 @@ func TestTreeRSS(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// just after its exec a command holds a few pages, until its loader
|
||||
// maps what it runs on (16KiB on ubuntu CI), so it is read until it does
|
||||
rss, ok := tree.RSS()
|
||||
for end := time.Now().Add(10 * time.Second); ok && rss < 64<<10 && time.Now().Before(end); {
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
rss, ok = tree.RSS()
|
||||
}
|
||||
if !ok || rss < 64<<10 || rss > 1<<30 {
|
||||
t.Fatalf("a running %s holds %d bytes (%v)", name, rss, ok)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package tui
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
@@ -12,6 +11,7 @@ import (
|
||||
"github.com/yetone/magpie/internal/appdir"
|
||||
"github.com/yetone/magpie/internal/autostart"
|
||||
"github.com/yetone/magpie/internal/daemon"
|
||||
"github.com/yetone/magpie/internal/proc"
|
||||
)
|
||||
|
||||
// On Linux with no desktop session (a WSL distro, a server over SSH)
|
||||
@@ -99,7 +99,7 @@ func serveInBackground() (int, string, error) {
|
||||
return 0, "", err
|
||||
}
|
||||
defer f.Close()
|
||||
cmd := exec.Command(exe, "serve")
|
||||
cmd := proc.Command(exe, "serve")
|
||||
cmd.Stdout, cmd.Stderr = f, f
|
||||
detach(cmd)
|
||||
if err := cmd.Start(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user