...

Source file src/github.com/shirou/gopsutil/process/process_race_test.go

Documentation: github.com/shirou/gopsutil/process

     1  // +build race
     2  
     3  package process
     4  
     5  import (
     6  	"sync"
     7  	"testing"
     8  )
     9  
    10  func Test_Process_Ppid_Race(t *testing.T) {
    11  	wg := sync.WaitGroup{}
    12  	testCount := 10
    13  	p := testGetProcess()
    14  	wg.Add(testCount)
    15  	for i := 0; i < testCount; i++ {
    16  		go func(j int) {
    17  			ppid, err := p.Ppid()
    18  			wg.Done()
    19  			skipIfNotImplementedErr(t, err)
    20  			if err != nil {
    21  				t.Errorf("Ppid() failed, %v", err)
    22  			}
    23  
    24  			if j == 9 {
    25  				t.Logf("Ppid(): %d", ppid)
    26  			}
    27  		}(i)
    28  	}
    29  	wg.Wait()
    30  }
    31  

View as plain text