Skip to content

Commit

Permalink
fix: toolbox: add freebsd stub for fileExtendedInfoFormat
Browse files Browse the repository at this point in the history
Fixes #3620

Signed-off-by: Doug MacEachern <[email protected]>
  • Loading branch information
dougm committed Dec 12, 2024
1 parent 7bde166 commit 0ef1c70
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
9 changes: 9 additions & 0 deletions simulator/guest_operations_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@ package simulator
import (
"os"
"os/exec"
"runtime"
"strings"
"testing"

"github.com/vmware/govmomi/vim25/types"
)

func TestFileInfo(t *testing.T) {
switch runtime.GOOS {
case "linux", "darwin":
default:
// listFiles() returns a `find` command to run inside a linux docker container.
// The `find` command also works on darwin, skip otherwise.
t.Skipf("GOOS=%s", runtime.GOOS)
}

pwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
Expand Down
34 changes: 29 additions & 5 deletions toolbox/process/process_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2017-2021 VMware, Inc. All Rights Reserved.
Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -26,14 +26,25 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"runtime"
"strconv"
"testing"
"time"

"github.com/vmware/govmomi/toolbox/vix"
)

func checkGOOS(t *testing.T) {
switch runtime.GOOS {
case "linux", "darwin":
default:
t.Skipf("GOOS=%s", runtime.GOOS)
}
}

func TestProcessFunction(t *testing.T) {
checkGOOS(t)

m := NewManager()
var pids []int64

Expand Down Expand Up @@ -72,16 +83,21 @@ func TestProcessFunction(t *testing.T) {
}

func TestProcessCommand(t *testing.T) {
checkGOOS(t)

m := NewManager()
var pids []int64

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

pid, _ := m.Start(r, New())
pid, err := m.Start(r, New())
if err != nil {
t.Fatal(err)
}
pids = append(pids, pid)
}

Expand Down Expand Up @@ -115,6 +131,8 @@ func TestProcessCommand(t *testing.T) {
}

func TestProcessKill(t *testing.T) {
checkGOOS(t)

m := NewManager()
var pids []int64

Expand All @@ -139,7 +157,7 @@ func TestProcessKill(t *testing.T) {
},
{
&vix.StartProgramRequest{
ProgramPath: "/bin/bash",
ProgramPath: shell,
Arguments: fmt.Sprintf(`-c "while true; do sleep 1; done"`),
},
New(),
Expand Down Expand Up @@ -186,6 +204,8 @@ func TestProcessKill(t *testing.T) {
}

func TestProcessRemove(t *testing.T) {
checkGOOS(t)

m := NewManager()

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

func TestProcessIO(t *testing.T) {
checkGOOS(t)

m := NewManager()

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

func TestProcessRoundTripper(t *testing.T) {
checkGOOS(t)

echo := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Write(w)
}))
Expand Down
25 changes: 25 additions & 0 deletions toolbox/toolbox_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package toolbox

import (
"os"
)

func fileExtendedInfoFormat(dir string, info os.FileInfo) string {
return ""
}

0 comments on commit 0ef1c70

Please sign in to comment.