mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Track paths and provide a rename hook.
This change also adds extensive testing to the p9 package via mocks. The sanity checks and type checks are moved from the gofer into the core package, where they can be more easily validated. PiperOrigin-RevId: 218296768 Change-Id: I4fc3c326e7bf1e0e140a454cbacbcc6fd617ab55
This commit is contained in:
@@ -15,7 +15,7 @@ go_register_toolchains(go_version="1.11.1")
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
|
||||
gazelle_dependencies()
|
||||
|
||||
# Add dependencies on external repositories.
|
||||
# External repositories, in sorted order.
|
||||
go_repository(
|
||||
name = "com_github_cenkalti_backoff",
|
||||
importpath = "github.com/cenkalti/backoff",
|
||||
@@ -28,6 +28,12 @@ go_repository(
|
||||
commit = "886344bea0798d02ff3fae16a922be5f6b26cee0"
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_golang_mock",
|
||||
importpath = "github.com/golang/mock",
|
||||
commit = "600781dde9cca80734169b9e969d9054ccc57937",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_google_go-cmp",
|
||||
importpath = "github.com/google/go-cmp",
|
||||
@@ -58,6 +64,12 @@ go_repository(
|
||||
commit = "b2d941ef6a780da2d9982c1fb28d77ad97f54fc7",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_syndtr_gocapability",
|
||||
importpath = "github.com/syndtr/gocapability",
|
||||
commit = "d98352740cb2c55f81556b63d4a1ec64c5a319c2",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_vishvananda_netlink",
|
||||
importpath = "github.com/vishvananda/netlink",
|
||||
@@ -81,9 +93,3 @@ go_repository(
|
||||
importpath = "golang.org/x/sys",
|
||||
commit = "0dd5e194bbf5eb84a39666eb4c98a4d007e4203a",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_syndtr_gocapability",
|
||||
importpath = "github.com/syndtr/gocapability",
|
||||
commit = "d98352740cb2c55f81556b63d4a1ec64c5a319c2",
|
||||
)
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "amutex",
|
||||
srcs = ["amutex.go"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "atomicbitops",
|
||||
srcs = [
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "binary",
|
||||
srcs = ["binary.go"],
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
|
||||
|
||||
go_library(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "compressio",
|
||||
srcs = ["compressio.go"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "client",
|
||||
srcs = [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "server",
|
||||
srcs = ["server.go"],
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "dhcp",
|
||||
srcs = [
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "eventchannel",
|
||||
srcs = [
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "fd",
|
||||
srcs = ["fd.go"],
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "gate",
|
||||
srcs = [
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "ilist",
|
||||
srcs = [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "linewriter",
|
||||
srcs = ["linewriter.go"],
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "log",
|
||||
srcs = [
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "metric",
|
||||
srcs = ["metric.go"],
|
||||
|
||||
@@ -15,6 +15,7 @@ go_library(
|
||||
"handlers.go",
|
||||
"messages.go",
|
||||
"p9.go",
|
||||
"path_tree.go",
|
||||
"pool.go",
|
||||
"server.go",
|
||||
"transport.go",
|
||||
@@ -32,6 +33,7 @@ go_test(
|
||||
name = "p9_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"buffer_test.go",
|
||||
"client_test.go",
|
||||
"messages_test.go",
|
||||
"p9_test.go",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2018 Google Inc.
|
||||
//
|
||||
// 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 p9
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBufferOverrun(t *testing.T) {
|
||||
buf := &buffer{
|
||||
// This header indicates that a large string should follow, but
|
||||
// it is only two bytes. Reading a string should cause an
|
||||
// overrun.
|
||||
data: []byte{0x0, 0x16},
|
||||
}
|
||||
if s := buf.ReadString(); s != "" {
|
||||
t.Errorf("overrun read got %s, want empty", s)
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,7 @@ func NewClient(socket *unet.Socket, messageSize uint32, version string) (*Client
|
||||
msize: largestFixedSize,
|
||||
}
|
||||
}
|
||||
|
||||
// Compute a payload size and round to 512 (normal block size)
|
||||
// if it's larger than a single block.
|
||||
payloadSize := messageSize - largestFixedSize
|
||||
@@ -299,3 +300,8 @@ func (c *Client) sendRecv(t message, r message) error {
|
||||
func (c *Client) Version() uint32 {
|
||||
return c.version
|
||||
}
|
||||
|
||||
// Close closes the underlying socket.
|
||||
func (c *Client) Close() error {
|
||||
return c.socket.Close()
|
||||
}
|
||||
|
||||
@@ -172,6 +172,9 @@ func (c *clientFile) SetAttr(valid SetAttrMask, attr SetAttr) error {
|
||||
}
|
||||
|
||||
// Remove implements File.Remove.
|
||||
//
|
||||
// N.B. This method is no longer part of the file interface and should be
|
||||
// considered deprecated.
|
||||
func (c *clientFile) Remove() error {
|
||||
// Avoid double close.
|
||||
if !atomic.CompareAndSwapUint32(&c.closed, 0, 1) {
|
||||
@@ -181,7 +184,6 @@ func (c *clientFile) Remove() error {
|
||||
|
||||
// Send the remove message.
|
||||
if err := c.client.sendRecv(&Tremove{FID: c.fid}, &Rremove{}); err != nil {
|
||||
log.Warningf("Tremove failed, losing FID %v: %v", c.fid, err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user