diff options
Diffstat (limited to 'tests/e2e/lifecycle_test.go')
| -rw-r--r-- | tests/e2e/lifecycle_test.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/e2e/lifecycle_test.go b/tests/e2e/lifecycle_test.go index 6cff0c8..ffd731f 100644 --- a/tests/e2e/lifecycle_test.go +++ b/tests/e2e/lifecycle_test.go @@ -1,7 +1,6 @@ package e2e import ( - "fmt" "os" "os/exec" "path/filepath" @@ -48,7 +47,9 @@ func waitForLifecycle(t *testing.T, binaryPath, runtimeDir, profile string, expe t.Fatalf("Timed out waiting for lifecycle state: expected active=%v", expectedActive) case <-tick.C: cmd := exec.Command(binaryPath, "test-lifecycle", "--profile", profile) - cmd.Env = append(os.Environ(), fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir)) + cmd.Env = SetEnvOverrides(map[string]string{"XDG_RUNTIME_DIR": runtimeDir}) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr err := cmd.Run() isActive := err == nil @@ -79,7 +80,9 @@ func TestNamespaceLifecycleAutomation(t *testing.T) { t.Run("ReferenceCounting", func(t *testing.T) { // Start a process that exits quickly cmd1 := exec.Command(binaryPath, "--profile", "default", "--", "sleep", "1.0") - cmd1.Env = append(os.Environ(), fmt.Sprintf("XDG_RUNTIME_DIR=%s", tmpRuntimeDir)) + cmd1.Env = SetEnvOverrides(map[string]string{"XDG_RUNTIME_DIR": tmpRuntimeDir}) + cmd1.Stdout = os.Stdout + cmd1.Stderr = os.Stderr if err := cmd1.Start(); err != nil { t.Fatalf("Failed to start cmd1: %v", err) } @@ -87,9 +90,11 @@ func TestNamespaceLifecycleAutomation(t *testing.T) { // Verify PID file exists using polling waitForLifecycle(t, binaryPath, tmpRuntimeDir, "default", true) - // Start a second process using the same profile - cmd2 := exec.Command(binaryPath, "--profile", "default", "--", "sleep", "1.0") - cmd2.Env = append(os.Environ(), fmt.Sprintf("XDG_RUNTIME_DIR=%s", tmpRuntimeDir)) + // Start a second process using the same profile with a longer sleep + cmd2 := exec.Command(binaryPath, "--profile", "default", "--", "sleep", "5.0") + cmd2.Env = SetEnvOverrides(map[string]string{"XDG_RUNTIME_DIR": tmpRuntimeDir}) + cmd2.Stdout = os.Stdout + cmd2.Stderr = os.Stderr if err := cmd2.Start(); err != nil { t.Fatalf("Failed to start cmd2: %v", err) } @@ -100,7 +105,7 @@ func TestNamespaceLifecycleAutomation(t *testing.T) { t.Fatalf("cmd1 failed: %v", err) } - // Poll for the count to drop back to 1 + // Poll for the count to drop back to 1 (cmd2 should still be running) waitForLifecycle(t, binaryPath, tmpRuntimeDir, "default", true) // Wait for second process to exit naturally |
