aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/os/exec_test.go
blob: 032763abfed9c7da5ef34fe0f700bf96d433d541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package os_test

import (
	. "os"
	"runtime"
	"testing"
)

func TestFindProcess(t *testing.T) {
	// NOTE: For now, we only test the Linux case since only exec_posix.go is currently the only implementation.
	if runtime.GOOS == "linux" {
		// Linux guarantees that there is pid 0
		proc, err := FindProcess(0)
		if err != nil {
			t.Error("FindProcess(0): wanted err == nil, got %v:", err)
		}

		if proc.Pid != 0 {
			t.Error("Expected pid 0, got: ", proc.Pid)
		}

		pid0 := Process{Pid: 0}
		if *proc != pid0 {
			t.Error("Expected &Process{Pid: 0}, got", *proc)
		}
	}

}