1
1
/*
2
- Copyright (c) 2017- 2021 VMware, Inc. All Rights Reserved.
2
+ Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
6
6
You may obtain a copy of the License at
7
7
8
- http://www.apache.org/licenses/LICENSE-2.0
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
9
10
10
Unless required by applicable law or agreed to in writing, software
11
11
distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,14 +26,25 @@ import (
26
26
"net/http"
27
27
"net/http/httptest"
28
28
"net/url"
29
+ "runtime"
29
30
"strconv"
30
31
"testing"
31
32
"time"
32
33
33
34
"github.com/vmware/govmomi/toolbox/vix"
34
35
)
35
36
37
+ func checkGOOS (t * testing.T ) {
38
+ switch runtime .GOOS {
39
+ case "linux" , "darwin" :
40
+ default :
41
+ t .Skipf ("GOOS=%s" , runtime .GOOS )
42
+ }
43
+ }
44
+
36
45
func TestProcessFunction (t * testing.T ) {
46
+ checkGOOS (t )
47
+
37
48
m := NewManager ()
38
49
var pids []int64
39
50
@@ -72,16 +83,21 @@ func TestProcessFunction(t *testing.T) {
72
83
}
73
84
74
85
func TestProcessCommand (t * testing.T ) {
86
+ checkGOOS (t )
87
+
75
88
m := NewManager ()
76
89
var pids []int64
77
90
78
91
for i := 0 ; i <= 2 ; i ++ {
79
92
r := & vix.StartProgramRequest {
80
- ProgramPath : "/bin/bash" ,
93
+ ProgramPath : shell ,
81
94
Arguments : fmt .Sprintf (`-c "exit %d"` , i ),
82
95
}
83
96
84
- pid , _ := m .Start (r , New ())
97
+ pid , err := m .Start (r , New ())
98
+ if err != nil {
99
+ t .Fatal (err )
100
+ }
85
101
pids = append (pids , pid )
86
102
}
87
103
@@ -115,6 +131,8 @@ func TestProcessCommand(t *testing.T) {
115
131
}
116
132
117
133
func TestProcessKill (t * testing.T ) {
134
+ checkGOOS (t )
135
+
118
136
m := NewManager ()
119
137
var pids []int64
120
138
@@ -139,7 +157,7 @@ func TestProcessKill(t *testing.T) {
139
157
},
140
158
{
141
159
& vix.StartProgramRequest {
142
- ProgramPath : "/bin/bash" ,
160
+ ProgramPath : shell ,
143
161
Arguments : fmt .Sprintf (`-c "while true; do sleep 1; done"` ),
144
162
},
145
163
New (),
@@ -186,6 +204,8 @@ func TestProcessKill(t *testing.T) {
186
204
}
187
205
188
206
func TestProcessRemove (t * testing.T ) {
207
+ checkGOOS (t )
208
+
189
209
m := NewManager ()
190
210
191
211
m .expire = time .Millisecond
@@ -234,6 +254,8 @@ func TestProcessError(t *testing.T) {
234
254
}
235
255
236
256
func TestProcessIO (t * testing.T ) {
257
+ checkGOOS (t )
258
+
237
259
m := NewManager ()
238
260
239
261
r := & vix.StartProgramRequest {
@@ -278,6 +300,8 @@ func (c *testRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
278
300
}
279
301
280
302
func TestProcessRoundTripper (t * testing.T ) {
303
+ checkGOOS (t )
304
+
281
305
echo := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
282
306
_ = r .Write (w )
283
307
}))
0 commit comments