@@ -11,7 +11,6 @@ import (
11
11
"strings"
12
12
"testing"
13
13
14
- "github.com/shirou/gopsutil/v3/internal/common"
15
14
"github.com/stretchr/testify/assert"
16
15
)
17
16
@@ -62,8 +61,7 @@ func Test_Process_splitProcStat_fromFile(t *testing.T) {
62
61
if err != nil {
63
62
t .Error (err )
64
63
}
65
- f := common .MockEnv ("HOST_PROC" , "testdata/linux" )
66
- defer f ()
64
+ t .Setenv ("HOST_PROC" , "testdata/linux" )
67
65
for _ , pid := range pids {
68
66
pid , err := strconv .ParseInt (pid .Name (), 0 , 32 )
69
67
if err != nil {
@@ -99,8 +97,7 @@ func Test_fillFromCommWithContext(t *testing.T) {
99
97
if err != nil {
100
98
t .Error (err )
101
99
}
102
- f := common .MockEnv ("HOST_PROC" , "testdata/linux" )
103
- defer f ()
100
+ t .Setenv ("HOST_PROC" , "testdata/linux" )
104
101
for _ , pid := range pids {
105
102
pid , err := strconv .ParseInt (pid .Name (), 0 , 32 )
106
103
if err != nil {
@@ -121,8 +118,7 @@ func Test_fillFromStatusWithContext(t *testing.T) {
121
118
if err != nil {
122
119
t .Error (err )
123
120
}
124
- f := common .MockEnv ("HOST_PROC" , "testdata/linux" )
125
- defer f ()
121
+ t .Setenv ("HOST_PROC" , "testdata/linux" )
126
122
for _ , pid := range pids {
127
123
pid , err := strconv .ParseInt (pid .Name (), 0 , 32 )
128
124
if err != nil {
@@ -139,8 +135,7 @@ func Test_fillFromStatusWithContext(t *testing.T) {
139
135
}
140
136
141
137
func Benchmark_fillFromCommWithContext (b * testing.B ) {
142
- f := common .MockEnv ("HOST_PROC" , "testdata/linux" )
143
- defer f ()
138
+ b .Setenv ("HOST_PROC" , "testdata/linux" )
144
139
pid := 1060
145
140
p , _ := NewProcess (int32 (pid ))
146
141
for i := 0 ; i < b .N ; i ++ {
@@ -149,8 +144,7 @@ func Benchmark_fillFromCommWithContext(b *testing.B) {
149
144
}
150
145
151
146
func Benchmark_fillFromStatusWithContext (b * testing.B ) {
152
- f := common .MockEnv ("HOST_PROC" , "testdata/linux" )
153
- defer f ()
147
+ b .Setenv ("HOST_PROC" , "testdata/linux" )
154
148
pid := 1060
155
149
p , _ := NewProcess (int32 (pid ))
156
150
for i := 0 ; i < b .N ; i ++ {
@@ -163,8 +157,7 @@ func Test_fillFromTIDStatWithContext_lx_brandz(t *testing.T) {
163
157
if err != nil {
164
158
t .Error (err )
165
159
}
166
- f := common .MockEnv ("HOST_PROC" , "testdata/lx_brandz" )
167
- defer f ()
160
+ t .Setenv ("HOST_PROC" , "testdata/lx_brandz" )
168
161
for _ , pid := range pids {
169
162
pid , err := strconv .ParseInt (pid .Name (), 0 , 32 )
170
163
if err != nil {
0 commit comments