Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(275)

Side by Side Diff: src/pkg/os/os_test.go

Issue 102320044: code review 102320044: syscall: implement syscall.Getppid() on Windows
Patch Set: diff -r d9c3411f6146 https://code.google.com/p/go Created 9 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/syscall/syscall_windows.go » ('j') | src/pkg/syscall/syscall_windows.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package os_test 5 package os_test
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "errors" 9 "errors"
10 "flag" 10 "flag"
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 1286
1287 func TestKillStartProcess(t *testing.T) { 1287 func TestKillStartProcess(t *testing.T) {
1288 testKillProcess(t, func(p *Process) { 1288 testKillProcess(t, func(p *Process) {
1289 err := p.Kill() 1289 err := p.Kill()
1290 if err != nil { 1290 if err != nil {
1291 t.Fatalf("Failed to kill test process: %v", err) 1291 t.Fatalf("Failed to kill test process: %v", err)
1292 } 1292 }
1293 }) 1293 })
1294 } 1294 }
1295 1295
1296 func TestGetppid(t *testing.T) {
1297 if Getenv("GO_WANT_HELPER_PROCESS") == "1" {
1298 defer Exit(0)
brainman 2014/06/13 00:43:49 Please, don't use defer here. It makes me suspicio
1299 fmt.Print(Getppid())
1300 return
1301 }
1302
1303 cmd := osexec.Command(Args[0], "-test.run=TestGetppid")
1304 cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
brainman 2014/06/13 00:43:49 You want to *add* new environment variable to the
shreveal 2014/06/13 06:32:13 This was essentially copied from helperCommand in
1305
1306 // verify that Getppid() from the forked process reports our process id
1307 output, err := cmd.Output()
brainman 2014/06/13 00:43:50 s/Output/CombinedOutput/ When things fail, the er
1308 if err != nil {
1309 t.Fatalf("Failed to spawn child process: %v", err)
brainman 2014/06/13 00:43:49 Please, display contents of "output" variable here
1310 }
1311
1312 childPpid := string(output)
1313 ourPid := fmt.Sprintf("%d", Getpid())
1314
1315 if childPpid != ourPid {
1316 t.Fatalf("Child process reports parent process id '%v', expected '%v'", childPpid, ourPid)
1317 }
1318 }
1319
1296 func TestKillFindProcess(t *testing.T) { 1320 func TestKillFindProcess(t *testing.T) {
1297 testKillProcess(t, func(p *Process) { 1321 testKillProcess(t, func(p *Process) {
1298 p2, err := FindProcess(p.Pid) 1322 p2, err := FindProcess(p.Pid)
1299 if err != nil { 1323 if err != nil {
1300 t.Fatalf("Failed to find test process: %v", err) 1324 t.Fatalf("Failed to find test process: %v", err)
1301 } 1325 }
1302 err = p2.Kill() 1326 err = p2.Kill()
1303 if err != nil { 1327 if err != nil {
1304 t.Fatalf("Failed to kill test process: %v", err) 1328 t.Fatalf("Failed to kill test process: %v", err)
1305 } 1329 }
(...skipping 24 matching lines...) Expand all
1330 // Test that all File methods give ErrInvalid if the receiver is nil. 1354 // Test that all File methods give ErrInvalid if the receiver is nil.
1331 func TestNilFileMethods(t *testing.T) { 1355 func TestNilFileMethods(t *testing.T) {
1332 for _, tt := range nilFileMethodTests { 1356 for _, tt := range nilFileMethodTests {
1333 var file *File 1357 var file *File
1334 got := tt.f(file) 1358 got := tt.f(file)
1335 if got != ErrInvalid { 1359 if got != ErrInvalid {
1336 t.Errorf("%v should fail when f is nil; got %v", tt.name , got) 1360 t.Errorf("%v should fail when f is nil; got %v", tt.name , got)
1337 } 1361 }
1338 } 1362 }
1339 } 1363 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/syscall/syscall_windows.go » ('j') | src/pkg/syscall/syscall_windows.go » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b