Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

test(cursor): skip background ownership tests on Linux kernels before 6.9 (#11262)

pseudoyuf9d5bfcf7ad2
diff --git a/server/pkg/agent/cursor_background_late_child_test.go b/server/pkg/agent/cursor_background_late_child_test.go
index 586eaff266..9b9f99b2ae 100644
--- a/server/pkg/agent/cursor_background_late_child_test.go
+++ b/server/pkg/agent/cursor_background_late_child_test.go
@@ -24,6 +24,7 @@ import (
)
func TestCaptureCursorBackgroundLateDescendant(t *testing.T) {
+ requireCursorBackgroundOwnership(t)
dir := t.TempDir()
gate := filepath.Join(dir, "fork")
root := exec.Command(os.Args[0])
diff --git a/server/pkg/agent/cursor_background_process_unix_test.go b/server/pkg/agent/cursor_background_process_unix_test.go
index 226ee7bd98..a58063fd22 100644
--- a/server/pkg/agent/cursor_background_process_unix_test.go
+++ b/server/pkg/agent/cursor_background_process_unix_test.go
@@ -15,6 +15,7 @@ import (
)
func TestCaptureCursorBackgroundProcessReapsLeaderExitedGroup(t *testing.T) {
+ requireCursorBackgroundOwnership(t)
dir := t.TempDir()
root := exec.Command(os.Args[0])
root.Env = append(os.Environ(), cursorFakeModeEnv+"=budget", "CURSOR_FAKE_DIR="+dir, "CURSOR_FAKE_DURATION=30s")
@@ -78,6 +79,7 @@ func TestCaptureCursorBackgroundProcessRejectsUnrelatedPID(t *testing.T) {
}
func TestCaptureCursorBackgroundSurvivesRootExitDuringCapture(t *testing.T) {
+ requireCursorBackgroundOwnership(t)
dir := t.TempDir()
root := exec.Command(os.Args[0])
root.Env = append(os.Environ(), cursorFakeModeEnv+"=budget", "CURSOR_FAKE_DIR="+dir, "CURSOR_FAKE_DURATION=30s")
diff --git a/server/pkg/agent/cursor_background_support_linux_test.go b/server/pkg/agent/cursor_background_support_linux_test.go
new file mode 100644
index 0000000000..46e9fe2450
--- /dev/null
+++ b/server/pkg/agent/cursor_background_support_linux_test.go
@@ -0,0 +1,33 @@
+//go:build linux
+
+package agent
+
+import (
+ "errors"
+ "os"
+ "testing"
+
+ "golang.org/x/sys/unix"
+)
+
+// requireCursorBackgroundOwnership skips a test that needs the daemon to own a
+// Cursor background shell. Ownership signals the shell's process group through
+// a pidfd (PIDFD_SIGNAL_PROCESS_GROUP, Linux 6.9+). Older kernels reject the
+// flag with EINVAL, and production then logs that it cannot own the shell and
+// keeps the idle watchdog instead.
+func requireCursorBackgroundOwnership(t *testing.T) {
+ t.Helper()
+ group, err := captureCursorUnixGroup(os.Getpid())
+ switch {
+ case err == nil:
+ group.close()
+ case errors.Is(err, unix.ESRCH):
+ // The test binary need not lead a process group. A kernel that knows
+ // the flag looks for the group and finds none; an older one rejects the
+ // flag before looking.
+ case errors.Is(err, unix.EINVAL):
+ t.Skip("pidfd process-group signalling needs Linux 6.9 or newer")
+ default:
+ t.Fatalf("probe pidfd process-group signalling: %v", err)
+ }
+}
diff --git a/server/pkg/agent/cursor_background_support_other_test.go b/server/pkg/agent/cursor_background_support_other_test.go
new file mode 100644
index 0000000000..31faf42ce8
--- /dev/null
+++ b/server/pkg/agent/cursor_background_support_other_test.go
@@ -0,0 +1,10 @@
+//go:build !linux
+
+package agent
+
+import "testing"
+
+// requireCursorBackgroundOwnership only probes Linux, whose kernel decides
+// whether pidfd process-group signalling exists. Other platforms keep their own
+// skips.
+func requireCursorBackgroundOwnership(t *testing.T) { t.Helper() }
diff --git a/server/pkg/agent/cursor_liveness_test.go b/server/pkg/agent/cursor_liveness_test.go
index 1ebc0e6690..6eb4954085 100644
--- a/server/pkg/agent/cursor_liveness_test.go
+++ b/server/pkg/agent/cursor_liveness_test.go
@@ -115,6 +115,11 @@ func runFakeCursorStream(mode string) {
if _, err := os.Stat(gate); err == nil {
break
}
+ // A test that failed before opening the gate has removed its
+ // temp dir; exit instead of waiting forever outside its cleanup.
+ if _, err := os.Stat(filepath.Dir(gate)); err != nil {
+ return
+ }
time.Sleep(5 * time.Millisecond)
}
}
@@ -230,6 +235,9 @@ func TestCursorBackgroundLifecycle(t *testing.T) {
}
for _, mode := range []string{"natural", "budget", "multiple", "finish", "cancel"} {
t.Run(mode, func(t *testing.T) {
+ if mode != "natural" {
+ requireCursorBackgroundOwnership(t)
+ }
self, err := os.Executable()
if err != nil {
t.Fatal(err)