Merge ""veyron/tools/principal": RecvBlessings flags"
diff --git a/lib/modules/core/wspr.go b/lib/modules/core/wspr.go
index 18bdf7c..0451e1e 100644
--- a/lib/modules/core/wspr.go
+++ b/lib/modules/core/wspr.go
@@ -9,6 +9,8 @@
"veyron.io/veyron/veyron/lib/flags"
"veyron.io/veyron/veyron/lib/modules"
"veyron.io/wspr/veyron/services/wsprd/wspr"
+
+ "veyron.io/veyron/veyron2/rt"
)
var (
@@ -47,8 +49,13 @@
}
args = fl.Args()
+ r, err := rt.New()
+ if err != nil {
+ return fmt.Errorf("rt.New failed: %s", err)
+ }
+ defer r.Cleanup()
l := initListenSpec(fl)
- proxy := wspr.NewWSPR(*port, nil, &l, *identd, nil)
+ proxy := wspr.NewWSPR(r, *port, nil, &l, *identd, nil)
defer proxy.Shutdown()
addr := proxy.Listen()
diff --git a/lib/modules/exec.go b/lib/modules/exec.go
index 74acf2f..2d517d7 100644
--- a/lib/modules/exec.go
+++ b/lib/modules/exec.go
@@ -196,6 +196,7 @@
// Transcribe stderr.
outputFromFile(eh.stderr, stderr)
+ os.Remove(eh.stderr.Name())
return procErr
}
diff --git a/lib/modules/func.go b/lib/modules/func.go
index 8fd0523..381c9de 100644
--- a/lib/modules/func.go
+++ b/lib/modules/func.go
@@ -121,13 +121,15 @@
fh.mu.Unlock()
// Safe to close stderr now.
+ stderrName := stderr.Name()
stderr.Close()
+ defer os.Remove(stderrName)
if stderr_w != nil {
- if stderr, err := os.Open(stderr.Name()); err == nil {
+ if stderr, err := os.Open(stderrName); err == nil {
io.Copy(stderr_w, stderr)
stderr.Close()
} else {
- fmt.Fprintf(os.Stderr, "failed to open %q: %s\n", stderr.Name(), err)
+ fmt.Fprintf(os.Stderr, "failed to open %q: %s\n", stderrName, err)
}
}
diff --git a/lib/modules/modules_test.go b/lib/modules/modules_test.go
index cee9708..074d39a 100644
--- a/lib/modules/modules_test.go
+++ b/lib/modules/modules_test.go
@@ -214,6 +214,7 @@
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
+ defer sh.Cleanup(nil, nil)
testShutdown(t, sh, "echos", false)
}
@@ -282,6 +283,7 @@
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
+ defer sh.Cleanup(nil, nil)
testShutdown(t, sh, "echof", true)
}
@@ -417,7 +419,6 @@
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
- defer sh.Cleanup(nil, nil)
if err := validateCredentials(startChildAndGetCredentials(sh, nil), "test-shell/child"); err != nil {
t.Fatal(err)
}
@@ -426,6 +427,7 @@
if cred1, cred2 := startChildAndGetCredentials(sh, nil), startChildAndGetCredentials(sh, nil); cred1 == cred2 {
t.Fatalf("The same credentials directory %v was set for two children", cred1)
}
+ sh.Cleanup(nil, nil)
// Test child credentials when VeyronCredentials are set.
root := tsecurity.NewPrincipal("root")
@@ -471,6 +473,7 @@
if err := validateCredentials(startChildAndGetCredentials(sh, nil), "root/anotherShell/child"); err != nil {
t.Fatal(err)
}
+ sh.Cleanup(nil, nil)
// Test that VeyronCredentials specified as a parameter overrides the OS and
// shell ones.
diff --git a/lib/modules/shell.go b/lib/modules/shell.go
index f4dcb7f..d9839c0 100644
--- a/lib/modules/shell.go
+++ b/lib/modules/shell.go
@@ -157,6 +157,7 @@
if err != nil {
return "", err
}
+ sh.tempCredDirs = append(sh.tempCredDirs, dir)
// Create a principal and default blessing for the child that is
// derived from the blessing created for this shell. This can
// be used by the parent to invoke RPCs on any children and for the
@@ -200,7 +201,6 @@
return "", err
}
}
- sh.tempCredDirs = append(sh.tempCredDirs, dir)
return dir, nil
}
diff --git a/lib/modules/util.go b/lib/modules/util.go
index b38e767..b2a62fa 100644
--- a/lib/modules/util.go
+++ b/lib/modules/util.go
@@ -16,7 +16,7 @@
func newLogfile(prefix, name string) (*os.File, error) {
nameHash := adler32.Checksum([]byte(name))
- f, err := ioutil.TempFile("", fmt.Sprintf("__modules__%s-%x", prefix, nameHash))
+ f, err := ioutil.TempFile("", fmt.Sprintf("__modules__%s-%x-", prefix, nameHash))
if err != nil {
return nil, err
}
diff --git a/lib/testutil/security/util_test.go b/lib/testutil/security/util_test.go
index 36718c3..8b3070a 100644
--- a/lib/testutil/security/util_test.go
+++ b/lib/testutil/security/util_test.go
@@ -22,6 +22,7 @@
parent := r.Principal()
childdir := NewVeyronCredentials(parent, "child")
+ defer os.RemoveAll(childdir)
if _, err = vsecurity.LoadPersistentPrincipal(childdir, nil); err != nil {
t.Fatalf("Expected NewVeyronCredentials to have populated the directory %q: %v", childdir, err)
}
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 1516527..af3a370 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -429,7 +429,7 @@
for {
flow, err := ln.Accept()
if err != nil {
- vlog.VI(10).Infof("ipc: Accept on %v failed: %v", ln, err)
+ vlog.VI(10).Infof("ipc: Accept on %v failed: %v", ep, err)
return
}
calls.Add(1)
@@ -437,13 +437,13 @@
defer calls.Done()
fs, err := newFlowServer(flow, s)
if err != nil {
- vlog.Errorf("newFlowServer on %v failed: %v", ln, err)
+ vlog.Errorf("newFlowServer on %v failed: %v", ep, err)
return
}
if err := fs.serve(); err != nil {
// TODO(caprita): Logging errors here is too spammy. For example, "not
// authorized" errors shouldn't be logged as server errors.
- vlog.Errorf("Flow serve on %v failed: %v", ln, err)
+ vlog.Errorf("Flow serve on %v failed: %v", ep, err)
}
}(flow)
}
diff --git a/runtimes/google/ipc/server_test.go b/runtimes/google/ipc/server_test.go
index 8e43cca..bc91133 100644
--- a/runtimes/google/ipc/server_test.go
+++ b/runtimes/google/ipc/server_test.go
@@ -86,6 +86,7 @@
process modules.Handle
session *expect.Session
mount string
+ sh *modules.Shell
}
func (h *proxyHandle) Start(t *testing.T) error {
@@ -100,6 +101,7 @@
h.process = server
h.session = expect.NewSession(t, server.Stdout(), time.Minute)
h.mount = h.session.ReadLine()
+ h.sh = sh
if err := h.session.Error(); err != nil {
return err
}
@@ -118,6 +120,7 @@
if len(h.mount) == 0 {
return nil
}
+ h.sh.Cleanup(nil, nil)
return h.ns.Unmount(testContext(), "proxy", h.mount)
}
diff --git a/runtimes/google/ipc/signature_test.go b/runtimes/google/ipc/signature_test.go
index 83d9c78..0f5c5ac 100644
--- a/runtimes/google/ipc/signature_test.go
+++ b/runtimes/google/ipc/signature_test.go
@@ -100,7 +100,7 @@
}},
}
for _, test := range tests {
- sig, err := reserved.MethodSignature(runtime.NewContext(), name, test.Method)
+ sig, err := reserved.MethodSignature(runtime.NewContext(), nil, name, test.Method)
if err != nil {
t.Errorf("call failed: %v", err)
}
@@ -155,7 +155,7 @@
},
}
- sig, err := reserved.Signature(runtime.NewContext(), name)
+ sig, err := reserved.Signature(runtime.NewContext(), nil, name)
if err != nil {
t.Errorf("call failed: %v", err)
}
diff --git a/runtimes/google/ipc/stream/vif/set_test.go b/runtimes/google/ipc/stream/vif/set_test.go
index 09b11e5..e7a7aa2 100644
--- a/runtimes/google/ipc/stream/vif/set_test.go
+++ b/runtimes/google/ipc/stream/vif/set_test.go
@@ -4,6 +4,7 @@
"fmt"
"io/ioutil"
"net"
+ "os"
"path"
"testing"
@@ -48,6 +49,7 @@
if err != nil {
t.Fatal(err)
}
+ defer os.RemoveAll(dir)
sockname := path.Join(dir, "socket")
ln, err := net.Listen("unix", sockname)
if err != nil {
diff --git a/services/identity/googleoauth/handler.go b/services/identity/googleoauth/handler.go
index fb93bc1..9f40f0e 100644
--- a/services/identity/googleoauth/handler.go
+++ b/services/identity/googleoauth/handler.go
@@ -472,7 +472,7 @@
if err != nil {
return empty, fmt.Errorf("failed to parse duration: %v", err)
}
- return security.ExpiryCaveat(t.Add(time.Minute * offset))
+ return security.ExpiryCaveat(t.Add(offset))
}
func newMethodCaveat(methods []string) (security.Caveat, error) {
diff --git a/services/mgmt/application/impl/impl_test.go b/services/mgmt/application/impl/impl_test.go
index 62c4e24..af03a77 100644
--- a/services/mgmt/application/impl/impl_test.go
+++ b/services/mgmt/application/impl/impl_test.go
@@ -34,6 +34,7 @@
if err != nil {
t.Fatalf("TempDir(%q, %q) failed: %v", dir, prefix, err)
}
+ defer os.RemoveAll(store)
dispatcher, err := NewDispatcher(store, nil)
if err != nil {
t.Fatalf("NewDispatcher() failed: %v", err)
diff --git a/services/mgmt/lib/fs/simplestore_test.go b/services/mgmt/lib/fs/simplestore_test.go
index 0a453d0..9957121 100644
--- a/services/mgmt/lib/fs/simplestore_test.go
+++ b/services/mgmt/lib/fs/simplestore_test.go
@@ -2,8 +2,8 @@
import (
"fmt"
+ "io/ioutil"
"os"
- "path/filepath"
"reflect"
"testing"
@@ -14,6 +14,15 @@
"veyron.io/veyron/veyron2/verror"
)
+func tempFile(t *testing.T) string {
+ tmpfile, err := ioutil.TempFile("", "simplestore-test-")
+ if err != nil {
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
+ }
+ defer tmpfile.Close()
+ return tmpfile.Name()
+}
+
func TestNewMemstore(t *testing.T) {
memstore, err := fs.NewMemstore("")
@@ -21,22 +30,21 @@
t.Fatalf("fs.NewMemstore() failed: %v", err)
}
- _, err = os.Stat(memstore.PersistedFile())
- if err != nil {
+ if _, err = os.Stat(memstore.PersistedFile()); err != nil {
t.Fatalf("Stat(%v) failed: %v", memstore.PersistedFile(), err)
}
+ os.Remove(memstore.PersistedFile())
}
func TestNewNamedMemstore(t *testing.T) {
- path := filepath.Join(os.TempDir(), "namedms")
+ path := tempFile(t)
+ defer os.Remove(path)
memstore, err := fs.NewMemstore(path)
if err != nil {
t.Fatalf("fs.NewMemstore() failed: %v", err)
}
- defer os.Remove(path)
- _, err = os.Stat(memstore.PersistedFile())
- if err != nil {
+ if _, err = os.Stat(memstore.PersistedFile()); err != nil {
t.Fatalf("Stat(%v) failed: %v", path, err)
}
}
@@ -91,12 +99,12 @@
}
func TestSerializeDeserialize(t *testing.T) {
- path := filepath.Join(os.TempDir(), "namedms")
+ path := tempFile(t)
+ defer os.Remove(path)
memstoreOriginal, err := fs.NewMemstore(path)
if err != nil {
t.Fatalf("fs.NewMemstore() failed: %v", err)
}
- defer os.Remove(path)
// Create example data.
envelope := application.Envelope{
@@ -367,12 +375,12 @@
}
func TestOperationsNeedValidBinding(t *testing.T) {
- path := filepath.Join(os.TempDir(), "namedms")
+ path := tempFile(t)
+ defer os.Remove(path)
memstoreOriginal, err := fs.NewMemstore(path)
if err != nil {
t.Fatalf("fs.NewMemstore() failed: %v", err)
}
- defer os.Remove(path)
// Create example data.
envelope := application.Envelope{
@@ -432,20 +440,18 @@
}
func TestOpenEmptyMemstore(t *testing.T) {
- path := filepath.Join(os.TempDir(), "namedms")
+ path := tempFile(t)
defer os.Remove(path)
// Create a brand new memstore persisted to namedms. This will
// have the side-effect of creating an empty backing file.
- _, err := fs.NewMemstore(path)
- if err != nil {
+ if _, err := fs.NewMemstore(path); err != nil {
t.Fatalf("fs.NewMemstore() failed: %v", err)
}
// Create another memstore that will attempt to deserialize the empty
// backing file.
- _, err = fs.NewMemstore(path)
- if err != nil {
+ if _, err := fs.NewMemstore(path); err != nil {
t.Fatalf("fs.NewMemstore() failed: %v", err)
}
}
diff --git a/services/mgmt/root/impl/dispatcher.go b/services/mgmt/root/impl/dispatcher.go
deleted file mode 100644
index 7d34f29..0000000
--- a/services/mgmt/root/impl/dispatcher.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package impl
-
-import (
- "veyron.io/veyron/veyron/services/mgmt/root"
- "veyron.io/veyron/veyron2/ipc"
- "veyron.io/veyron/veyron2/security"
-)
-
-// dispatcher holds the state of the root process.
-type dispatcher struct {
- state *invoker
-}
-
-var _ ipc.Dispatcher = (*dispatcher)(nil)
-
-// NewDispatcher is the dispatcher factory.
-func NewDispatcher() *dispatcher {
- return &dispatcher{NewInvoker()}
-}
-
-// DISPATCHER INTERFACE IMPLEMENTATION
-
-func (d *dispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
- return root.RootServer(d.state), nil, nil
-}
diff --git a/services/mgmt/root/impl/root.go b/services/mgmt/root/impl/root.go
deleted file mode 100644
index 4905a2a..0000000
--- a/services/mgmt/root/impl/root.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package impl
-
-import (
- "errors"
- "os/exec"
- "runtime"
- "time"
-
- "veyron.io/veyron/veyron2/ipc"
- "veyron.io/veyron/veyron2/vlog"
-)
-
-// invoker is the object that implements the Root interface
-type invoker struct{}
-
-// NewInvoker is the invoker factory.
-func NewInvoker() *invoker {
- return &invoker{}
-}
-
-// ROOT INTERFACE IMPLEMENTATION
-
-// resetLinux implements the Reset method for Linux.
-func (i *invoker) resetLinux(deadline uint64) {
- time.Sleep(time.Duration(deadline) * time.Millisecond)
- cmd := exec.Command("shutdown", "-r", "now")
- vlog.VI(0).Infof("Shutting down.")
- cmd.Run()
-}
-
-func (i *invoker) Reset(call ipc.ServerContext, deadline uint64) error {
- vlog.VI(0).Infof("Reset(%v).", deadline)
- switch runtime.GOOS {
- case "linux":
- go i.resetLinux(deadline)
- default:
- // TODO(jsimsa): Implement Reset method for additional operating
- // systems.
- return errors.New("Unsupported operating system: " + runtime.GOOS)
- }
- return nil
-}
diff --git a/services/mgmt/root/root.vdl b/services/mgmt/root/root.vdl
deleted file mode 100644
index b8e635b..0000000
--- a/services/mgmt/root/root.vdl
+++ /dev/null
@@ -1,11 +0,0 @@
-// Package root contains root process implementation and internal
-// interfaces and types used by the implementation.
-package root
-
-// Root is an interface to be implemented by a process with root level
-// privileges.
-type Root interface {
- // Reset waits for the given deadline (in milliseconds) and then
- // restars the host node machine.
- Reset(Deadline uint64) (error)
-}
diff --git a/services/mgmt/root/root.vdl.go b/services/mgmt/root/root.vdl.go
deleted file mode 100644
index 5fdd66c..0000000
--- a/services/mgmt/root/root.vdl.go
+++ /dev/null
@@ -1,182 +0,0 @@
-// This file was auto-generated by the veyron vdl tool.
-// Source: root.vdl
-
-// Package root contains root process implementation and internal
-// interfaces and types used by the implementation.
-package root
-
-import (
- // The non-user imports are prefixed with "__" to prevent collisions.
- __veyron2 "veyron.io/veyron/veyron2"
- __context "veyron.io/veyron/veyron2/context"
- __ipc "veyron.io/veyron/veyron2/ipc"
- __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- __wiretype "veyron.io/veyron/veyron2/wiretype"
-)
-
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
-// RootClientMethods is the client interface
-// containing Root methods.
-//
-// Root is an interface to be implemented by a process with root level
-// privileges.
-type RootClientMethods interface {
- // Reset waits for the given deadline (in milliseconds) and then
- // restars the host node machine.
- Reset(ctx __context.T, Deadline uint64, opts ...__ipc.CallOpt) error
-}
-
-// RootClientStub adds universal methods to RootClientMethods.
-type RootClientStub interface {
- RootClientMethods
- __ipc.UniversalServiceMethods
-}
-
-// RootClient returns a client stub for Root.
-func RootClient(name string, opts ...__ipc.BindOpt) RootClientStub {
- var client __ipc.Client
- for _, opt := range opts {
- if clientOpt, ok := opt.(__ipc.Client); ok {
- client = clientOpt
- }
- }
- return implRootClientStub{name, client}
-}
-
-type implRootClientStub struct {
- name string
- client __ipc.Client
-}
-
-func (c implRootClientStub) c(ctx __context.T) __ipc.Client {
- if c.client != nil {
- return c.client
- }
- return __veyron2.RuntimeFromContext(ctx).Client()
-}
-
-func (c implRootClientStub) Reset(ctx __context.T, i0 uint64, opts ...__ipc.CallOpt) (err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Reset", []interface{}{i0}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (c implRootClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// RootServerMethods is the interface a server writer
-// implements for Root.
-//
-// Root is an interface to be implemented by a process with root level
-// privileges.
-type RootServerMethods interface {
- // Reset waits for the given deadline (in milliseconds) and then
- // restars the host node machine.
- Reset(ctx __ipc.ServerContext, Deadline uint64) error
-}
-
-// RootServerStubMethods is the server interface containing
-// Root methods, as expected by ipc.Server.
-// There is no difference between this interface and RootServerMethods
-// since there are no streaming methods.
-type RootServerStubMethods RootServerMethods
-
-// RootServerStub adds universal methods to RootServerStubMethods.
-type RootServerStub interface {
- RootServerStubMethods
- // Describe the Root interfaces.
- Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
-}
-
-// RootServer returns a server stub for Root.
-// It converts an implementation of RootServerMethods into
-// an object that may be used by ipc.Server.
-func RootServer(impl RootServerMethods) RootServerStub {
- stub := implRootServerStub{
- impl: impl,
- }
- // Initialize GlobState; always check the stub itself first, to handle the
- // case where the user has the Glob method defined in their VDL source.
- if gs := __ipc.NewGlobState(stub); gs != nil {
- stub.gs = gs
- } else if gs := __ipc.NewGlobState(impl); gs != nil {
- stub.gs = gs
- }
- return stub
-}
-
-type implRootServerStub struct {
- impl RootServerMethods
- gs *__ipc.GlobState
-}
-
-func (s implRootServerStub) Reset(ctx __ipc.ServerContext, i0 uint64) error {
- return s.impl.Reset(ctx, i0)
-}
-
-func (s implRootServerStub) Globber() *__ipc.GlobState {
- return s.gs
-}
-
-func (s implRootServerStub) Describe__() []__ipc.InterfaceDesc {
- return []__ipc.InterfaceDesc{RootDesc}
-}
-
-// RootDesc describes the Root interface.
-var RootDesc __ipc.InterfaceDesc = descRoot
-
-// descRoot hides the desc to keep godoc clean.
-var descRoot = __ipc.InterfaceDesc{
- Name: "Root",
- PkgPath: "veyron.io/veyron/veyron/services/mgmt/root",
- Doc: "// Root is an interface to be implemented by a process with root level\n// privileges.",
- Methods: []__ipc.MethodDesc{
- {
- Name: "Reset",
- Doc: "// Reset waits for the given deadline (in milliseconds) and then\n// restars the host node machine.",
- InArgs: []__ipc.ArgDesc{
- {"Deadline", ``}, // uint64
- },
- OutArgs: []__ipc.ArgDesc{
- {"", ``}, // error
- },
- },
- },
-}
-
-func (s implRootServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Reset"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Deadline", Type: 53},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 65},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/services/mgmt/root/rootd/main.go b/services/mgmt/root/rootd/main.go
deleted file mode 100644
index 4688bdc..0000000
--- a/services/mgmt/root/rootd/main.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package main
-
-import (
- "veyron.io/veyron/veyron2/rt"
- "veyron.io/veyron/veyron2/vlog"
-
- "veyron.io/veyron/veyron/lib/signals"
- "veyron.io/veyron/veyron/profiles/roaming"
- "veyron.io/veyron/veyron/services/mgmt/root/impl"
-)
-
-func main() {
- r, err := rt.New()
- if err != nil {
- vlog.Fatalf("Could not initialize runtime: %v", err)
- }
- defer r.Cleanup()
- server, err := r.NewServer()
- if err != nil {
- vlog.Errorf("NewServer() failed: %v", err)
- return
- }
- defer server.Stop()
- dispatcher := impl.NewDispatcher()
- ep, err := server.Listen(roaming.ListenSpec)
- if err != nil {
- vlog.Errorf("Listen(%s) failed: %v", roaming.ListenSpec, err)
- return
- }
- vlog.VI(0).Infof("Listening on %v", ep)
- name := ""
- if err := server.ServeDispatcher(name, dispatcher); err != nil {
- vlog.Errorf("ServeDispatcher(%v) failed: %v", name, err)
- return
- }
-
- // Wait until shutdown.
- <-signals.ShutdownOnSignals(r)
-}
diff --git a/tools/binary/impl_test.go b/tools/binary/impl_test.go
index ba314cc..004a235 100644
--- a/tools/binary/impl_test.go
+++ b/tools/binary/impl_test.go
@@ -142,7 +142,7 @@
if err != nil {
t.Fatalf("%v", err)
}
- defer os.Remove(dir)
+ defer os.RemoveAll(dir)
file := path.Join(dir, "testfile")
defer os.Remove(file)
if err := cmd.Execute([]string{"download", naming.JoinAddressName(endpoint.String(), "exists"), file}); err != nil {
diff --git a/tools/build/impl_test.go b/tools/build/impl_test.go
index 4f4d3f7..59f832d 100644
--- a/tools/build/impl_test.go
+++ b/tools/build/impl_test.go
@@ -11,14 +11,12 @@
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/services/mgmt/binary"
"veyron.io/veyron/veyron2/services/mgmt/build"
- "veyron.io/veyron/veyron2/verror"
+ verror "veyron.io/veyron/veyron2/verror2"
"veyron.io/veyron/veyron2/vlog"
"veyron.io/veyron/veyron/profiles"
)
-var errInternalError = verror.Internalf("internal error")
-
type mock struct{}
func (mock) Build(ctx build.BuilderBuildContext, arch build.Architecture, opsys build.OperatingSystem) ([]byte, error) {
@@ -28,7 +26,7 @@
}
if err := iterator.Err(); err != nil {
vlog.Errorf("Advance() failed: %v", err)
- return nil, errInternalError
+ return nil, verror.Make(verror.Internal, ctx)
}
return nil, nil
}
diff --git a/tools/gclogs/gclogs_test.go b/tools/gclogs/gclogs_test.go
index f9168fe..0454df5 100644
--- a/tools/gclogs/gclogs_test.go
+++ b/tools/gclogs/gclogs_test.go
@@ -1,5 +1,9 @@
+// +build -darwin
+
package main
+// These tests need go 1.4 to run successfully on a mac.
+
import (
"bytes"
"fmt"
@@ -15,7 +19,7 @@
func setup(t *testing.T, workdir, username string) (tmpdir string) {
var err error
- tmpdir, err = ioutil.TempDir(workdir, "parse-file-info-")
+ tmpdir, err = ioutil.TempDir(workdir, "gclogs-test-setup-")
if err != nil {
t.Fatalf("ioutil.TempDir failed: %v", err)
}
diff --git a/tools/mgmt/nodex/acl_impl.go b/tools/mgmt/nodex/acl_impl.go
index 7296702..f54c2ee 100644
--- a/tools/mgmt/nodex/acl_impl.go
+++ b/tools/mgmt/nodex/acl_impl.go
@@ -9,7 +9,7 @@
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/services/mgmt/node"
"veyron.io/veyron/veyron2/services/security/access"
- "veyron.io/veyron/veyron2/verror"
+ verror "veyron.io/veyron/veyron2/verror2"
)
var cmdGet = &cmdline.Command{
diff --git a/tools/mgmt/nodex/acl_test.go b/tools/mgmt/nodex/acl_test.go
index 2cb3b96..57922f8 100644
--- a/tools/mgmt/nodex/acl_test.go
+++ b/tools/mgmt/nodex/acl_test.go
@@ -2,7 +2,6 @@
import (
"bytes"
- "fmt"
"reflect"
"regexp"
"strings"
@@ -11,7 +10,14 @@
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/services/security/access"
- "veyron.io/veyron/veyron2/verror"
+ verror "veyron.io/veyron/veyron2/verror2"
+)
+
+const pkgPath = "veyron.io/veyron/veyron/tools/mgmt/nodex/main"
+
+var (
+ errOops = verror.Register(pkgPath+".errOops", verror.NoRetry, "oops!")
+ errBadETag = verror.Register(access.ErrBadEtag, verror.NoRetry, "{1:}{2:} etag is out of date{:_}")
)
func TestACLGetCommand(t *testing.T) {
@@ -125,7 +131,7 @@
etag: "anEtagForToday",
err: nil,
},
- verror.Make(access.ErrBadEtag, fmt.Sprintf("etag mismatch in:%s vers:%s", "anEtagForToday", "anEtagForTomorrow")),
+ verror.Make(errBadETag, nil, "anEtagForToday", "anEtagForTomorrow"),
GetACLResponse{
acl: access.TaggedACLMap{
"Admin": access.ACL{
@@ -217,7 +223,7 @@
tape.SetResponses([]interface{}{GetACLResponse{
acl: access.TaggedACLMap{},
etag: "anEtagForToday",
- err: verror.BadArgf("oops!"),
+ err: verror.Make(errOops, nil),
},
})
@@ -251,7 +257,7 @@
etag: "anEtagForToday",
err: nil,
},
- verror.BadArgf("oops!"),
+ verror.Make(errOops, nil),
})
if err := cmd.Execute([]string{"acl", "set", nodeName, "friend", "Read"}); err == nil {
diff --git a/tools/mgmt/nodex/impl_test.go b/tools/mgmt/nodex/impl_test.go
index 75107a3..535fbdb 100644
--- a/tools/mgmt/nodex/impl_test.go
+++ b/tools/mgmt/nodex/impl_test.go
@@ -10,7 +10,7 @@
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/services/mgmt/node"
- "veyron.io/veyron/veyron2/verror"
+ verror "veyron.io/veyron/veyron2/verror2"
)
func init() {
@@ -275,7 +275,7 @@
// Error operation.
tape.SetResponses([]interface{}{
- verror.BadArgf("oops!"),
+ verror.Make(errOops, nil),
})
if err := cmd.Execute([]string{"claim", nodeName, "grant"}); err == nil {
t.Fatalf("claim() failed to detect error", err)
@@ -355,7 +355,7 @@
// Error operation.
tape.SetResponses([]interface{}{StartResponse{
[]string{},
- verror.BadArgf("oops!"),
+ verror.Make(errOops, nil),
},
})
if err := cmd.Execute([]string{"start", appName, "grant"}); err == nil {
diff --git a/tools/mgmt/nodex/instance_impl_test.go b/tools/mgmt/nodex/instance_impl_test.go
index 493ffe5..36d909d 100644
--- a/tools/mgmt/nodex/instance_impl_test.go
+++ b/tools/mgmt/nodex/instance_impl_test.go
@@ -7,7 +7,7 @@
"testing"
"veyron.io/veyron/veyron2/naming"
- "veyron.io/veyron/veyron2/verror"
+ verror "veyron.io/veyron/veyron2/verror2"
)
func TestStopCommand(t *testing.T) {
@@ -68,7 +68,7 @@
// Test stop with bad parameters.
tape.SetResponses([]interface{}{
- verror.BadArgf("oops!"),
+ verror.Make(errOops, nil),
})
if err := cmd.Execute([]string{"stop", appName + "/appname"}); err == nil {
t.Fatalf("wrongly didn't receive a non-nil error.")
@@ -136,7 +136,7 @@
// Test list with bad parameters.
tape.SetResponses([]interface{}{
- verror.BadArgf("oops!"),
+ verror.Make(errOops, nil),
})
if err := cmd.Execute([]string{lower, appName + "/appname"}); err == nil {
t.Fatalf("wrongly didn't receive a non-nil error.")
diff --git a/tools/mgmt/test.sh b/tools/mgmt/test.sh
index bd4c59a..f253152 100755
--- a/tools/mgmt/test.sh
+++ b/tools/mgmt/test.sh
@@ -89,7 +89,7 @@
# Start a binary server.
local -r BINARYD_NAME="binaryd"
shell_test::start_server "${BINARYD_BIN}" --name="${BINARYD_NAME}" \
- --root="$(shell::tmp_dir)/binstore" --veyron.tcp.address=127.0.0.1:0 --http=127.0.0.1:0 \
+ --root_dir="$(shell::tmp_dir)/binstore" --veyron.tcp.address=127.0.0.1:0 --http=127.0.0.1:0 \
|| shell_test::fail "line ${LINENO} failed to start binaryd"
# Upload a binary to the binary server. The binary we upload is binaryd
@@ -110,7 +110,7 @@
# Upload an envelope for our test app.
local -r SAMPLE_APP_NAME="${APPLICATIOND_NAME}/testapp/v0"
local -r APP_PUBLISH_NAME="testbinaryd"
- echo "{\"Title\":\"BINARYD\", \"Args\":[\"--name=${APP_PUBLISH_NAME}\", \"--root=./binstore\", \"--veyron.tcp.address=127.0.0.1:0\"], \"Binary\":\"${SAMPLE_APP_BIN_NAME}\", \"Env\":[]}" > ./app.envelope && \
+ echo "{\"Title\":\"BINARYD\", \"Args\":[\"--name=${APP_PUBLISH_NAME}\", \"--root_dir=./binstore\", \"--veyron.tcp.address=127.0.0.1:0\"], \"Binary\":\"${SAMPLE_APP_BIN_NAME}\", \"Env\":[]}" > ./app.envelope && \
"${APPLICATION_BIN}" put "${SAMPLE_APP_NAME}" test ./app.envelope && rm ./app.envelope
# Verify that the envelope we uploaded shows up with glob.
diff --git a/tools/naming/simulator/driver_test.go b/tools/naming/simulator/driver_test.go
index 5ccb5cb..303874a 100644
--- a/tools/naming/simulator/driver_test.go
+++ b/tools/naming/simulator/driver_test.go
@@ -44,6 +44,7 @@
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
+ defer sh.Cleanup(nil, nil)
sh.SetVar("foo", "bar")
cases := []struct {
input string
diff --git a/tools/servicerunner/servicerunner_test.go b/tools/servicerunner/servicerunner_test.go
index fb72ff6..c2a4085 100644
--- a/tools/servicerunner/servicerunner_test.go
+++ b/tools/servicerunner/servicerunner_test.go
@@ -7,6 +7,7 @@
"encoding/json"
"fmt"
"io/ioutil"
+ "os"
"os/exec"
"path"
"testing"
@@ -21,6 +22,8 @@
func TestMain(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "servicerunner_test")
check(t, err)
+ defer os.RemoveAll(tmpdir)
+ os.Setenv("TMPDIR", tmpdir)
bin := path.Join(tmpdir, "servicerunner")
fmt.Println("Building", bin)