Skip to content

Commit 0ef1c70

Browse files
committed
fix: toolbox: add freebsd stub for fileExtendedInfoFormat
Fixes #3620 Signed-off-by: Doug MacEachern <[email protected]>
1 parent 7bde166 commit 0ef1c70

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

simulator/guest_operations_manager_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@ package simulator
1919
import (
2020
"os"
2121
"os/exec"
22+
"runtime"
2223
"strings"
2324
"testing"
2425

2526
"github.com/vmware/govmomi/vim25/types"
2627
)
2728

2829
func TestFileInfo(t *testing.T) {
30+
switch runtime.GOOS {
31+
case "linux", "darwin":
32+
default:
33+
// listFiles() returns a `find` command to run inside a linux docker container.
34+
// The `find` command also works on darwin, skip otherwise.
35+
t.Skipf("GOOS=%s", runtime.GOOS)
36+
}
37+
2938
pwd, err := os.Getwd()
3039
if err != nil {
3140
t.Fatal(err)

toolbox/process/process_test.go

+29-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2017-2021 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,14 +26,25 @@ import (
2626
"net/http"
2727
"net/http/httptest"
2828
"net/url"
29+
"runtime"
2930
"strconv"
3031
"testing"
3132
"time"
3233

3334
"github.com/vmware/govmomi/toolbox/vix"
3435
)
3536

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+
3645
func TestProcessFunction(t *testing.T) {
46+
checkGOOS(t)
47+
3748
m := NewManager()
3849
var pids []int64
3950

@@ -72,16 +83,21 @@ func TestProcessFunction(t *testing.T) {
7283
}
7384

7485
func TestProcessCommand(t *testing.T) {
86+
checkGOOS(t)
87+
7588
m := NewManager()
7689
var pids []int64
7790

7891
for i := 0; i <= 2; i++ {
7992
r := &vix.StartProgramRequest{
80-
ProgramPath: "/bin/bash",
93+
ProgramPath: shell,
8194
Arguments: fmt.Sprintf(`-c "exit %d"`, i),
8295
}
8396

84-
pid, _ := m.Start(r, New())
97+
pid, err := m.Start(r, New())
98+
if err != nil {
99+
t.Fatal(err)
100+
}
85101
pids = append(pids, pid)
86102
}
87103

@@ -115,6 +131,8 @@ func TestProcessCommand(t *testing.T) {
115131
}
116132

117133
func TestProcessKill(t *testing.T) {
134+
checkGOOS(t)
135+
118136
m := NewManager()
119137
var pids []int64
120138

@@ -139,7 +157,7 @@ func TestProcessKill(t *testing.T) {
139157
},
140158
{
141159
&vix.StartProgramRequest{
142-
ProgramPath: "/bin/bash",
160+
ProgramPath: shell,
143161
Arguments: fmt.Sprintf(`-c "while true; do sleep 1; done"`),
144162
},
145163
New(),
@@ -186,6 +204,8 @@ func TestProcessKill(t *testing.T) {
186204
}
187205

188206
func TestProcessRemove(t *testing.T) {
207+
checkGOOS(t)
208+
189209
m := NewManager()
190210

191211
m.expire = time.Millisecond
@@ -234,6 +254,8 @@ func TestProcessError(t *testing.T) {
234254
}
235255

236256
func TestProcessIO(t *testing.T) {
257+
checkGOOS(t)
258+
237259
m := NewManager()
238260

239261
r := &vix.StartProgramRequest{
@@ -278,6 +300,8 @@ func (c *testRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
278300
}
279301

280302
func TestProcessRoundTripper(t *testing.T) {
303+
checkGOOS(t)
304+
281305
echo := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
282306
_ = r.Write(w)
283307
}))

toolbox/toolbox_freebsd.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package toolbox
18+
19+
import (
20+
"os"
21+
)
22+
23+
func fileExtendedInfoFormat(dir string, info os.FileInfo) string {
24+
return ""
25+
}

0 commit comments

Comments
 (0)