TBR: Move simulator to experimental, without preserving git history
MultiPart: 1/2

Change-Id: I9eb12cca43aa229039eb52d309f8d47d15159211
diff --git a/cmd/naming/simulator/commands.go b/cmd/naming/simulator/commands.go
deleted file mode 100644
index 0b25d5d..0000000
--- a/cmd/naming/simulator/commands.go
+++ /dev/null
@@ -1,260 +0,0 @@
-package main
-
-import (
-	"bytes"
-	"encoding/json"
-	"fmt"
-	"io"
-	"os"
-	"regexp"
-	"strings"
-
-	"v.io/x/ref/test/modules"
-)
-
-type builtinCmd func(sh *modules.Shell, state *cmdState, args ...string) (string, error)
-
-var varRE = regexp.MustCompile("(.*?)=(.*)")
-
-var builtins = map[string]*struct {
-	nargs       int // -1 means a variable # of args.
-	usage       string
-	needsHandle bool
-	fn          builtinCmd
-}{
-	"print":       {-1, "print <args>...", false, print},
-	"help":        {-1, "help", false, nil},
-	"set":         {-1, "set <var>=<val>...", false, set},
-	"json_set":    {-1, "<var>...", false, json_set},
-	"json_print":  {0, "", false, json_print},
-	"splitEP":     {-1, "splitEP", false, splitEP},
-	"assert":      {2, "val1 val2", false, assert},
-	"assertOneOf": {-1, "val1 val...", false, assertOneOf},
-	"read":        {-1, "read <handle> [var]", true, read},
-	"eval":        {1, "eval <handle>", true, eval},
-	"wait":        {1, "wait <handle>", true, wait},
-	"stop":        {1, "stop <handle>", true, stop},
-	"stderr":      {1, "stderr <handle>", true, stderr},
-	"list":        {0, "list", false, list},
-	"quit":        {0, "quit", false, quit},
-}
-
-func init() {
-	builtins["help"].fn = help
-}
-
-func print(_ *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	r := strings.Join(args, " ")
-	return r, nil
-}
-
-func splitEP(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	ep := strings.TrimLeft(args[0], "/")
-	ep = strings.TrimRight(ep, "/")
-	ep = strings.TrimLeft(ep, "@")
-	ep = strings.TrimRight(ep, "@")
-	parts := strings.Split(ep, "@")
-	sh.SetVar("PN", fmt.Sprintf("%d", len(parts)))
-	for i, p := range parts {
-		sh.SetVar(fmt.Sprintf("P%d", i), p)
-	}
-	return "", nil
-}
-
-func help(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	r := ""
-	if len(args) == 0 {
-		for k, _ := range builtins {
-			if k == "help" {
-				continue
-			}
-			r += k + ", "
-		}
-		r += sh.String()
-		return r, nil
-	} else {
-		for _, a := range args {
-			if v := builtins[a]; v != nil {
-				r += v.usage + "\n"
-				continue
-			}
-			h := sh.Help(a)
-			if len(h) == 0 {
-				return "", fmt.Errorf("unknown command: %q", a)
-			} else {
-				r += h
-			}
-		}
-	}
-	return r, nil
-}
-
-func parseVar(expr string) (string, string, error) {
-	m := varRE.FindAllStringSubmatch(expr, 1)
-	if len(m) != 1 || len(m[0]) != 3 {
-		return "", "", fmt.Errorf("%q is not an assignment statement", expr)
-	}
-	return m[0][1], m[0][2], nil
-}
-
-func set(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	r := ""
-	if len(args) == 0 {
-		for _, v := range sh.Env() {
-			r += v + "\n"
-		}
-		return r, nil
-	}
-	for _, a := range args {
-		k, v, err := parseVar(a)
-		if err != nil {
-			return "", err
-		}
-		sh.SetVar(k, v)
-	}
-	return "", nil
-}
-
-func assert(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	if args[0] != args[1] {
-		return "", fmt.Errorf("assertion failed: %q != %q", args[0], args[1])
-	}
-	return "", nil
-}
-
-func assertOneOf(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	if len(args) < 2 {
-		return "", fmt.Errorf("missing assertOneOf args")
-	}
-	expected := args[0]
-	for _, a := range args[1:] {
-		if a == expected {
-			return "", nil
-		}
-	}
-	return "", fmt.Errorf("assertion failed: %q not in %v", expected, args[1:])
-}
-
-func stderr(sh *modules.Shell, state *cmdState, args ...string) (string, error) {
-	state.Session.Finish(nil)
-	delete(handles, args[0])
-	return readStderr(state)
-}
-
-func readStderr(state *cmdState) (string, error) {
-	var b bytes.Buffer
-	if err := state.Handle.Shutdown(nil, &b); err != nil && err != io.EOF {
-		return b.String(), err
-	}
-	return b.String(), nil
-}
-
-func handleWrapper(sh *modules.Shell, fn builtinCmd, args ...string) (string, error) {
-	if len(args) < 1 {
-		return "", fmt.Errorf("missing handle argument")
-	}
-	state := handles[args[0]]
-	if state == nil {
-		return "", fmt.Errorf("invalid handle")
-	}
-	errstr := ""
-	r, err := fn(sh, state, args...)
-	if err != nil {
-		errstr, _ = readStderr(state)
-		errstr = strings.TrimSuffix(errstr, "\n")
-		if len(errstr) > 0 {
-			err = fmt.Errorf("%s: %v", errstr, err)
-		}
-	}
-	return r, err
-}
-
-func read(sh *modules.Shell, state *cmdState, args ...string) (string, error) {
-	l := state.Session.ReadLine()
-	for _, a := range args[1:] {
-		sh.SetVar(a, l)
-	}
-	return l, state.Session.OriginalError()
-}
-
-func eval(sh *modules.Shell, state *cmdState, args ...string) (string, error) {
-	l := state.Session.ReadLine()
-	if err := state.Session.OriginalError(); err != nil {
-		return l, err
-	}
-	k, v, err := parseVar(l)
-	if err != nil {
-		return "", err
-	}
-	sh.SetVar(k, v)
-	return l, nil
-}
-
-func stop(sh *modules.Shell, state *cmdState, args ...string) (string, error) {
-	state.Handle.CloseStdin()
-	return wait(sh, state, args...)
-}
-
-func wait(sh *modules.Shell, state *cmdState, args ...string) (string, error) {
-	// Read and return stdout
-	r, err := state.Session.Finish(nil)
-	delete(handles, args[0])
-	if err != nil {
-		return r, err
-	}
-	// Now read and return the contents of stderr as a string
-	if str, err := readStderr(state); err != nil && err != io.EOF {
-		return str, err
-	}
-	return r, nil
-}
-
-func list(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	r := ""
-	for h, v := range handles {
-		r += h + ": " + v.line + "\n"
-	}
-	return r, nil
-}
-
-func quit(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	r := ""
-	for k, h := range handles {
-		if err := h.Handle.Shutdown(os.Stdout, os.Stdout); err != nil {
-			r += fmt.Sprintf("%s: %v\n", k, err)
-		} else {
-			r += fmt.Sprintf("%s: ok\n", k)
-		}
-	}
-	fmt.Fprintf(os.Stdout, "%s\n", r)
-	os.Exit(0)
-	panic("unreachable")
-}
-
-func getLine(sh *modules.Shell, args ...string) (string, error) {
-	handle := handles[args[0]]
-	if handle == nil {
-		return "", fmt.Errorf("invalid handle")
-	}
-	l := handle.Session.ReadLine()
-	return l, handle.Session.Error()
-}
-
-func json_set(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	for _, k := range args {
-		if v, present := sh.GetVar(k); present {
-			jsonDict[k] = v
-		} else {
-			return "", fmt.Errorf("unrecognised variable: %q", k)
-		}
-	}
-	return "", nil
-}
-
-func json_print(sh *modules.Shell, _ *cmdState, args ...string) (string, error) {
-	bytes, err := json.Marshal(jsonDict)
-	if err != nil {
-		return "", err
-	}
-	return string(bytes), nil
-}
diff --git a/cmd/naming/simulator/driver.go b/cmd/naming/simulator/driver.go
deleted file mode 100644
index 0ba2f2a..0000000
--- a/cmd/naming/simulator/driver.go
+++ /dev/null
@@ -1,318 +0,0 @@
-// This app provides a simple scripted environment for running common veyron
-// services as subprocesses and testing interactions between them. It is
-// structured as an interpreter, with global variables and variable
-// expansion, but no control flow. The command set that it supports is
-// extendable by adding new 'commands' that implement the API defined
-// by veyron/test/modules.
-package main
-
-import (
-	"bufio"
-	"flag"
-	"fmt"
-	"os"
-	"strconv"
-	"strings"
-	"time"
-	"unicode"
-
-	"v.io/v23"
-	"v.io/v23/context"
-
-	_ "v.io/x/ref/profiles"
-	"v.io/x/ref/test/expect"
-	"v.io/x/ref/test/modules"
-	_ "v.io/x/ref/test/modules/core"
-)
-
-type cmdState struct {
-	modules.Handle
-	*expect.Session
-	line string
-}
-
-var (
-	interactive bool
-	filename    string
-	handles     map[string]*cmdState
-	jsonDict    map[string]string
-)
-
-func init() {
-	flag.BoolVar(&interactive, "interactive", true, "set interactive/batch mode")
-	flag.StringVar(&filename, "file", "", "command file")
-	handles = make(map[string]*cmdState)
-	jsonDict = make(map[string]string)
-	flag.Usage = usage
-}
-
-var usage = func() {
-	fmt.Println(
-		`Welcome to this simple shell that lets you run mount tables, a simple server
-and sundry other commands from an interactive command line or as scripts. Type
-'help' at the prompt to see a list of available commands, or 'help command' to
-get specific help about that command. The shell provides environment variables
-with expansion and intrinsic support for managing subprocess, but it does not
-provide any flow control commands.
-
-All commands, except builtin ones (such as help, set, eval etc) are run
-asynchronously in background. That is, the prompt returns as soon as they are
-started and no output is displayed from them unless an error is encountered
-when they are being started. Each input line is numbered and that number is
-used to refer to the standard output of previous started commands. The variable
-_ always contains the number of the immediately preceeding line. It is
-possible to read the output of a command (using the 'read' builtin) and assign
-it that output to an environment variable. The 'eval' builtin parses output of
-the form <var>=<val>. In this way subproccess may be started, their output
-read and used to configure subsequent subprocesses. For example:
-
-1> time
-2> read 1 t
-3> print $t
-
-will print the first line of output from the time command, as will the
-following:
-
-or:
-time
-read $_ t
-print $t
-
-The eval builtin is used to directly to assign to variables specified
-in the output of the command. For example, if the root command
-prints out MT_NAME=foo then eval will set MT_NAME to foo as follows:
-
-root
-eval $_
-print $MT_NAME
-
-will print the value of MT_NAME that is output by the root command.
-`)
-	flag.PrintDefaults()
-}
-
-func prompt(lineno int) {
-	if interactive {
-		fmt.Printf("%d> ", lineno)
-	}
-}
-
-var ctx *context.T
-
-func main() {
-	var shutdown v23.Shutdown
-	ctx, shutdown = v23.Init()
-
-	input := os.Stdin
-	if len(filename) > 0 {
-		f, err := os.Open(filename)
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "unexpected error: %s\n", err)
-			os.Exit(1)
-		}
-		input = f
-		interactive = false
-	}
-
-	// Subprocesses commands are run by fork/execing this binary
-	// so we must test to see if this instance is a subprocess or the
-	// the original command line instance.
-	if modules.IsModulesChildProcess() {
-		shutdown()
-		// Subprocess, run the requested command.
-		if err := modules.Dispatch(); err != nil {
-			fmt.Fprintf(os.Stderr, "failed: %v\n", err)
-			os.Exit(1)
-		}
-		return
-	}
-	defer shutdown()
-
-	shell, err := modules.NewShell(ctx, nil)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "unexpected error: %s\n", err)
-		os.Exit(1)
-	}
-	defer shell.Cleanup(os.Stderr, os.Stderr)
-
-	scanner := bufio.NewScanner(input)
-	lineno := 1
-	prompt(lineno)
-	for scanner.Scan() {
-		line := scanner.Text()
-		if !strings.HasPrefix(line, "#") && len(line) > 0 {
-			if line == "eof" {
-				break
-			}
-			if err := process(shell, line, lineno); err != nil {
-				fmt.Printf("ERROR: %d> %q: %v\n", lineno, line, err)
-				if !interactive {
-					os.Exit(1)
-				}
-			}
-		}
-		shell.SetVar("_", strconv.Itoa(lineno))
-		lineno++
-		prompt(lineno)
-	}
-	if err := scanner.Err(); err != nil {
-		fmt.Printf("error reading input: %v\n", err)
-	}
-
-}
-
-func output(lineno int, line string) {
-	if len(line) > 0 {
-		if !interactive {
-			fmt.Printf("%d> ", lineno)
-		}
-		line = strings.TrimSuffix(line, "\n")
-		fmt.Printf("%s\n", line)
-	}
-}
-
-func process(sh *modules.Shell, line string, lineno int) error {
-	fields, err := splitQuotedFields(line)
-	if err != nil {
-		return err
-	}
-	if len(fields) == 0 {
-		return fmt.Errorf("no input")
-	}
-	name := fields[0]
-
-	var args []string
-	if len(fields) > 1 {
-		args = fields[1:]
-	} else {
-		args = []string{}
-	}
-	sub, err := subVariables(sh, args)
-	if err != nil {
-		return err
-	}
-	if cmd := builtins[name]; cmd != nil {
-		if cmd.nargs >= 0 && len(sub) != cmd.nargs {
-			return fmt.Errorf("wrong (%d) # args for %q: usage %s", len(sub), name, cmd.usage)
-		}
-		l := ""
-		var err error
-		if cmd.needsHandle {
-			l, err = handleWrapper(sh, cmd.fn, sub...)
-		} else {
-			l, err = cmd.fn(sh, nil, sub...)
-		}
-		if err != nil {
-			return fmt.Errorf("%s : %s", err, l)
-		}
-		output(lineno, l)
-	} else {
-		handle, err := sh.Start(name, nil, sub...)
-		if err != nil {
-			return err
-		}
-		handles[strconv.Itoa(lineno)] = &cmdState{
-			handle,
-			expect.NewSession(nil, handle.Stdout(), 10*time.Minute),
-			line,
-		}
-		output(lineno, line)
-	}
-	return nil
-}
-
-// splitQuotedFields a line into fields, allowing for quoted strings.
-func splitQuotedFields(line string) ([]string, error) {
-	fields := []string{}
-	inquote := false
-	var field []rune
-	for _, c := range line {
-		switch {
-		case c == '"':
-			if inquote {
-				fields = append(fields, string(field))
-				field = nil
-				inquote = false
-			} else {
-				inquote = true
-			}
-		case unicode.IsSpace(c):
-			if inquote {
-				field = append(field, c)
-			} else {
-				if len(field) > 0 {
-					fields = append(fields, string(field))
-				}
-				field = nil
-			}
-		default:
-			field = append(field, c)
-		}
-	}
-	if inquote {
-		return nil, fmt.Errorf("unterminated quoted input")
-	}
-
-	if len(field) > 0 {
-		fields = append(fields, string(field))
-	}
-	return fields, nil
-}
-
-// subVariables substitutes variables that occur in the string slice
-// args with values from the Shell.
-func subVariables(sh *modules.Shell, args []string) ([]string, error) {
-	var results []string
-	for _, a := range args {
-		if r, err := subVariablesInArgument(sh, a); err != nil {
-			return results, err
-		} else {
-			results = append(results, r)
-		}
-	}
-	return results, nil
-}
-
-// subVariablesInArgument substitutes variables that occur in the string
-// parameter with values from vars.
-//
-// A variable, is introduced by $, terminated by \t, space, / , : or !.
-// Variables may also be enclosed by {} (as in ${VAR}) to allow for embedding
-// within strings.
-func subVariablesInArgument(sh *modules.Shell, a string) (string, error) {
-	first := strings.Index(a, "$")
-	if first < 0 {
-		return a, nil
-	}
-	parts := strings.Split(a, "$")
-	result := parts[0]
-	vn := ""
-	rem := 0
-	for _, p := range parts[1:] {
-		start := 0
-		end := -1
-		if strings.HasPrefix(p, "{") {
-			start = 1
-			end = strings.Index(p, "}")
-			if end < 0 {
-				return "", fmt.Errorf("unterminated variable: %q", p)
-			}
-			rem = end + 1
-		} else {
-			end = strings.IndexAny(p, "\t/,:!= ")
-			if end < 0 {
-				end = len(p)
-			}
-			rem = end
-		}
-		vn = p[start:end]
-		r := p[rem:]
-		v, present := sh.GetVar(vn)
-		if !present {
-			return a, fmt.Errorf("unknown variable: %q", vn)
-		}
-		result += v
-		result += r
-	}
-	return result, nil
-}
diff --git a/cmd/naming/simulator/driver_test.go b/cmd/naming/simulator/driver_test.go
deleted file mode 100644
index bb298ff..0000000
--- a/cmd/naming/simulator/driver_test.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"reflect"
-	"testing"
-
-	"v.io/x/ref/test/modules"
-)
-
-func TestFields(t *testing.T) {
-	cases := []struct {
-		input  string
-		output []string
-	}{
-		{"", []string{}},
-		{"a", []string{"a"}},
-		{"  z", []string{"z"}},
-		{"  zz  zz", []string{"zz", "zz"}},
-		{"ab", []string{"ab"}},
-		{"a b", []string{"a", "b"}},
-		{`a " b"`, []string{"a", " b"}},
-		{`a "  b  zz"`, []string{"a", "  b  zz"}},
-		{`a "  b		zz"`, []string{"a", "  b		zz"}},
-		{`a " b" cc`, []string{"a", " b", "cc"}},
-		{`a "z b" cc`, []string{"a", "z b", "cc"}},
-	}
-	for i, c := range cases {
-		got, err := splitQuotedFields(c.input)
-		if err != nil {
-			t.Errorf("%d: %q: unexpected error: %v", i, c.input, err)
-		}
-		if !reflect.DeepEqual(got, c.output) {
-			t.Errorf("%d: %q: got %#v, want %#v", i, c.input, got, c.output)
-		}
-	}
-	if _, err := splitQuotedFields(`a b "c`); err == nil {
-		t.Errorf("expected error for unterminated quote")
-	}
-}
-
-func TestVariables(t *testing.T) {
-	sh, err := modules.NewShell(nil, nil)
-	if err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-	defer sh.Cleanup(nil, nil)
-	sh.SetVar("foo", "bar")
-	cases := []struct {
-		input  string
-		output []string
-	}{
-		{"a b", []string{"a", "b"}},
-		{"a $foo", []string{"a", "bar"}},
-		{"$foo a", []string{"bar", "a"}},
-		{`a "$foo "`, []string{"a", "bar "}},
-		{"a xx$foo", []string{"a", "xxbar"}},
-		{"a xx${foo}yy", []string{"a", "xxbaryy"}},
-		{`a "foo"`, []string{"a", "foo"}},
-	}
-	for i, c := range cases {
-		fields, err := splitQuotedFields(c.input)
-		if err != nil {
-			t.Errorf("%d: %q: unexpected error: %v", i, c.input, err)
-		}
-		got, err := subVariables(sh, fields)
-		if err != nil {
-			t.Errorf("%d: %q: unexpected error: %v", i, c.input, err)
-		}
-		if !reflect.DeepEqual(got, c.output) {
-			t.Errorf("%d: %q: got %#v, want %#v", i, c.input, got, c.output)
-		}
-	}
-
-	errors := []struct {
-		input string
-		err   error
-	}{
-		{"$foox", fmt.Errorf("unknown variable: %q", "foox")},
-		{"${fo", fmt.Errorf("unterminated variable: %q", "{fo")},
-	}
-	for i, c := range errors {
-		vars, got := subVariables(sh, []string{c.input})
-		if (got == nil && c.err != nil) || got.Error() != c.err.Error() {
-			t.Errorf("%d: %q: expected error: got %v (with results %#v) want %v", i, c.input, got, vars, c.err)
-		}
-	}
-}
diff --git a/cmd/naming/simulator/shell_functions.go b/cmd/naming/simulator/shell_functions.go
deleted file mode 100644
index 1c2fc57..0000000
--- a/cmd/naming/simulator/shell_functions.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"io"
-	"time"
-
-	"v.io/v23"
-	"v.io/v23/context"
-	"v.io/v23/naming"
-
-	"v.io/x/ref/test/modules"
-)
-
-func init() {
-	modules.RegisterFunction("cache", `on|off
-turns the namespace cache on or off`, namespaceCache)
-	modules.RegisterFunction("mount", `<mountpoint> <server> <ttl> [M][R]
-invokes namespace.Mount(<mountpoint>, <server>, <ttl>)`, mountServer)
-	modules.RegisterFunction("resolve", `<name>
-resolves name to obtain an object server address`, resolveObject)
-	modules.RegisterFunction("resolveMT", `<name>
-resolves name to obtain a mount table address`, resolveMT)
-	modules.RegisterFunction("setRoots", `<name>...
-set the in-process namespace roots to <name>...`, setNamespaceRoots)
-}
-
-// checkArgs checks for the expected number of args in args. A negative
-// value means at least that number of args are expected.
-func checkArgs(args []string, expected int, usage string) error {
-	got := len(args)
-	if expected < 0 {
-		expected = -expected
-		if got < expected {
-			return fmt.Errorf("wrong # args (got %d, expected >=%d) expected: %q got: %v", got, expected, usage, args)
-		}
-	} else {
-		if got != expected {
-			return fmt.Errorf("wrong # args (got %d, expected %d) expected: %q got: %v", got, expected, usage, args)
-		}
-	}
-	return nil
-}
-
-func mountServer(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
-	if err := checkArgs(args, -3, "<mount point> <server> <ttl> [M][R]"); err != nil {
-		return err
-	}
-	var opts []naming.MountOpt
-	for _, arg := range args[3:] {
-		for _, c := range arg {
-			switch c {
-			case 'R':
-				opts = append(opts, naming.ReplaceMountOpt(true))
-			case 'M':
-				opts = append(opts, naming.ServesMountTableOpt(true))
-			}
-		}
-	}
-	mp, server, ttlstr := args[0], args[1], args[2]
-	ttl, err := time.ParseDuration(ttlstr)
-	if err != nil {
-		return fmt.Errorf("failed to parse time from %q", ttlstr)
-	}
-	ns := v23.GetNamespace(ctx)
-	if err := ns.Mount(ctx, mp, server, ttl, opts...); err != nil {
-		return err
-	}
-	fmt.Fprintf(stdout, "Mount(%s, %s, %s, %v)\n", mp, server, ttl, opts)
-	return nil
-}
-
-func namespaceCache(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
-	if err := checkArgs(args, 1, "on|off"); err != nil {
-		return err
-	}
-	disable := true
-	switch args[0] {
-	case "on":
-		disable = false
-	case "off":
-		disable = true
-	default:
-		return fmt.Errorf("arg must be 'on' or 'off'")
-	}
-	v23.GetNamespace(ctx).CacheCtl(naming.DisableCache(disable))
-	return nil
-}
-
-type resolver func(ctx *context.T, name string, opts ...naming.ResolveOpt) (me *naming.MountEntry, err error)
-
-func resolve(fn resolver, stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
-	if err := checkArgs(args, 1, "<name>"); err != nil {
-		return err
-	}
-	name := args[0]
-	me, err := fn(ctx, name)
-	if err != nil {
-		fmt.Fprintf(stdout, "RN=0\n")
-		return err
-	}
-	servers := me.Names()
-	fmt.Fprintf(stdout, "RN=%d\n", len(servers))
-	for i, s := range servers {
-		fmt.Fprintf(stdout, "R%d=%s\n", i, s)
-	}
-	return nil
-}
-
-func resolveObject(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
-	return resolve(v23.GetNamespace(ctx).Resolve, stdin, stdout, stderr, env, args...)
-}
-
-func resolveMT(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
-	return resolve(v23.GetNamespace(ctx).ResolveToMountTable, stdin, stdout, stderr, env, args...)
-}
-
-func setNamespaceRoots(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
-	return v23.GetNamespace(ctx).SetRoots(args...)
-}
diff --git a/cmd/naming/simulator/simulator_v23_test.go b/cmd/naming/simulator/simulator_v23_test.go
deleted file mode 100644
index e1ac8ef..0000000
--- a/cmd/naming/simulator/simulator_v23_test.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package main_test
-
-//go:generate v23 test generate .
-
-import (
-	"bytes"
-	"fmt"
-	"io/ioutil"
-	"os"
-	"regexp"
-	"testing"
-
-	"v.io/x/ref/test/v23tests"
-)
-
-func V23TestSimulator(t *v23tests.T) {
-	binary := t.BuildGoPkg("v.io/x/ref/cmd/naming/simulator")
-	files, err := ioutil.ReadDir("./testdata")
-	if err != nil {
-		t.Fatal(err)
-	}
-	scripts := []string{}
-	re := regexp.MustCompile(`.*\.scr`)
-	for _, f := range files {
-		if !f.IsDir() && re.MatchString(f.Name()) {
-			scripts = append(scripts, "./testdata/"+f.Name())
-		}
-	}
-	for _, script := range scripts {
-		if testing.Verbose() {
-			fmt.Fprintf(os.Stderr, "Script %v\n", script)
-		}
-		scriptFile, err := os.Open(script)
-		if err != nil {
-			t.Fatalf("Open(%q) failed: %v", script, err)
-		}
-		invocation := binary.WithStdin(scriptFile).Start()
-		var stdout, stderr bytes.Buffer
-		if err := invocation.Wait(&stdout, &stderr); err != nil {
-			fmt.Fprintf(os.Stderr, "Script %v failed\n", script)
-			fmt.Fprintln(os.Stderr, stdout.String())
-			fmt.Fprintln(os.Stderr, stderr.String())
-			t.Error(err)
-		}
-	}
-}
diff --git a/cmd/naming/simulator/testdata/ambiguity.scr b/cmd/naming/simulator/testdata/ambiguity.scr
deleted file mode 100644
index 844323d..0000000
--- a/cmd/naming/simulator/testdata/ambiguity.scr
+++ /dev/null
@@ -1,67 +0,0 @@
-# This is p's 'ambiguity' example
-#
-# mountMT("/s1/a", "/s2/b")
-# mountMT("/s2/b", "/s3/c")
-# mount("/s3/c", "/s4")
-#
-# Bogdan points out that: 'we will actually have d == "" in the echo example
-# below (since Serve only mounts endpoints without suffixes)'
-#
-# I'm not using any local names because its easier to not get confused
-# this way.
-#
-# resolve("/s1/a") can now have 4 possible objects, the mount point in server1,
-# the mount point in server2, the mount point in server3, and the object d in
-# server4.  When we make a call, like SetPermissions, how do we tell which one to
-# modify?   If we glob("/s1/a") we get:
-#
-# "s1/a", ["/s2/b"(mountpoint)]
-# "s1/a", ["/s3/c"(mountpoint)]
-# "s1/a", ["/s4"(mountpoint)]
-
-set localaddr="--veyron.tcp.address=127.0.0.1:0"
-
-root $localaddr
-set r=$_
-read $r
-eval $r
-set s1=$MT_NAME
-
-root $localaddr
-set r=$_
-read $r
-eval $r
-set s2=$MT_NAME
-
-root $localaddr
-set r=$_
-read $r
-eval $r
-set s3=$MT_NAME
-
-mount $s1/a $s2/b 1h
-wait $_
-
-mount $s2/b $s3/c 1h
-wait $_
-
-echoServer $localaddr "Echo" $s3/c
-set es_h=$_
-
-# Returns the root and three mounts at s1/a.
-ls $s1/...
-set l=$_
-eval $l
-assert $RN 5
-wait $l
-
-# Returns the mount at s1/a.
-ls $s1/a
-set l=$_
-eval $l
-assert $RN 1
-eval $l
-assert $R0 $s1/a
-wait $l
-
-stop $es_h
diff --git a/cmd/naming/simulator/testdata/echo.scr b/cmd/naming/simulator/testdata/echo.scr
deleted file mode 100644
index 4ca7435..0000000
--- a/cmd/naming/simulator/testdata/echo.scr
+++ /dev/null
@@ -1,63 +0,0 @@
-# Simple example to show how names work both without and with a mount table
-# and the difference between resolve and resolveMT.
-
-set localaddr=--veyron.tcp.address=127.0.0.1:0
-set ws=--veyron.tcp.protocol=ws
-
-setRoots
-
-# A 'stand-alone' server
-echoServer $localaddr $ws $localaddr "text" ""
-set es=$_
-read $es
-eval $es
-set esName=$NAME
-
-echoClient $esName "test"
-set ec=$_
-read $ec line
-assert $line "text: test"
-
-stop $es
-wait $ec
-
-# now use a nameserver.
-root $localaddr
-set r=$_
-read $r
-eval $r
-set root=$MT_NAME
-
-set NAMESPACE_ROOT=$root
-echoServer $localaddr $ws $localaddr "text2" "a/b"
-set es=$_
-read $es
-eval $es
-set es_name=$NAME
-
-echoClient "a/b" "test 2"
-set ec=$_
-read $ec line
-assert $line "text2: test 2"
-
-# resolve will return the server's address
-setRoots $root
-resolve a/b
-set r=$_
-eval $r
-assert $RN 2
-eval $r
-set ep1=$R0
-eval $r
-set ep2=$R1
-assertOneOf $es_name $ep1 $ep2
-
-# resolveMT will return the mount table's address (the part before the //)
-resolveMT a/b
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-assert $R0 $root/a/b
-
-stop $es
diff --git a/cmd/naming/simulator/testdata/json_example.scr b/cmd/naming/simulator/testdata/json_example.scr
deleted file mode 100644
index d399a30..0000000
--- a/cmd/naming/simulator/testdata/json_example.scr
+++ /dev/null
@@ -1,29 +0,0 @@
-
-cache off
-
-set localaddr=--veyron.tcp.address=127.0.0.1:0
-
-root $localaddr
-set root=$_
-eval $root
-set ROOT_PID=$PID
-eval $root
-set ROOT_NAME=$MT_NAME
-json_set ROOT_NAME ROOT_PID
-
-set PROXY_MOUNTPOINT=$ROOT_NAME/proxy/mp
-proxyd $localaddr $PROXY_MOUNTPOINT
-set proxyd=$_
-read $proxyd
-eval $proxyd
-set PROXYD_NAME=$PROXY_NAME
-splitEP $PROXY_NAME
-set PROXY_HOST_ADDR=$P2
-json_set PROXY_MOUNTPOINT PROXY_NAME PROXY_HOST_ADDR
-
-
-json_print
-
-# uncomment wait $root to have the script leave all of the processes running
-#wait $root
-stop $proxyd
diff --git a/cmd/naming/simulator/testdata/mt_complex.scr b/cmd/naming/simulator/testdata/mt_complex.scr
deleted file mode 100644
index e2546eb..0000000
--- a/cmd/naming/simulator/testdata/mt_complex.scr
+++ /dev/null
@@ -1,278 +0,0 @@
-# Some more complex uses of mount tables and mounts
-#
-# TODO - list the examples and any issues.
-
-set localaddr="--veyron.tcp.address=127.0.0.1:0"
-set ws=--veyron.tcp.protocol=ws
-
-cache off
-
-root $localaddr
-set root_h=$_
-read $root_h
-eval $root_h
-set root=$MT_NAME
-
-set NAMESPACE_ROOT=$root
-mt $localaddr tl/a
-set m=$_
-set mt_a_h=$m
-read $m
-eval $m
-set mt_a_name=$MT_NAME
-
-mt $localaddr tl/b
-set m=$_
-set mt_b_h=$m
-eval $m
-eval $m
-set mt_b_name=$MT_NAME
-
-setRoots $root
-
-#
-# Using glob 'correctly' takes some care. There are (at least?) three
-# forms that you need to consider...
-#
-
-# ls ... finds all of the mount points, as relative names
-ls ...
-set l=$_
-eval $l
-assert $RN 3
-wait $l
-
-# ls /... is meaningless, finds nothing.
-ls /...
-set l=$_
-eval $l
-assert $RN 0
-wait $l
-
-# a rooted glob finds all of the mount points, include an entry for the root
-# itself. It returns rooted names.
-ls $root/...
-set l=$_
-eval $l
-assert $RN 4
-wait $l
-
-resolve tl/a
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-set ep1=$R0
-assert $mt_a_name $ep1
-wait $r
-
-#
-# Now, let's run some echo servers, invoke rpc's on them, see what
-# glob and resolve do.
-#
-
-# run an echo server on tl.
-echoServer  $localaddr "E1" tl
-set es_E1=$_
-read $es_E1
-eval $es_E1
-set es_E1_name=$NAME
-
-# the echo server above, obscures the mount tables below it.
-# each of the ls (i.e. glob) calls below will lead to 'ipc:unknown method'
-# errors generated by the echo server.
-ls ...
-set l=$_
-eval $l
-assert $RN 2
-
-ls $root/...
-set l=$_
-eval $l
-assert $RN 3
-
-echoClient tl test
-read $_ o
-assert $o "E1: test"
-
-# resolve will find the address of the echo server.
-resolve tl
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-set ep1=$R0
-assert $es_E1_name $ep1
-
-# let's have the echo server shut down
-stop $es_E1
-
-# and now, we can see the mount tables again.
-ls ...
-set l=$_
-eval $l
-assert $RN 3
-wait $l
-
-resolve tl/a
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-set ep1=$R0
-assert $mt_a_name $ep1
-
-# run an echo server on tl/a - note that this currently doesn't seem to
-# have any effect on the mount table - that is, I suspect the mount table
-# refuses the mount.
-echoServer  $localaddr "E2" tl/a
-set es_E2=$_
-read $es_E2
-eval $es_E2
-set es_E2_name=$NAME
-
-# we can invoke the echo server 'E2' just fine, probably because
-# we just get lucky and get the most recently mounted address back first.
-#echoClient "tl/b" bar
-#read $_ o
-#assert $o "E2: bar"
-
-# but, when we resolve it's name, we get back two servers, one for the
-# mount table and another for the server!
-#resolve tl/a
-#set r=$_
-#eval $r
-#assert $RN 2
-#eval $r
-#set ep1=$R0
-#eval $r
-#set ep2=$R1
-#assertOneOf $mt_a_name $ep1 $ep2
-
-# resolveMT correctly returns the root's address.
-resolveMT tl/a
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-assert $R0 $root/tl/a
-
-#
-# NOTE: I propose to fix the above ambiguity by having resolve only
-# ever return non-mountpoint servers. To do so, requires that the mount table
-# can tell them apart, which requires the separate Mount and MountMT calls.
-#
-
-# Mount the same server somewhere else
-# TODO(cnicolaou): $es_E2_name needs to be made into an endpoint.
-mount tl/a/c $es_E2_name 1h
-wait $_
-
-ls ...
-wait $_
-
-# this leads to 1 call of ResolveStep for //c on the echo server.
-resolve tl/a/c
-wait $_
-
-# this leads to 2 calls of ResolveStep for //c on the echo server.
-echoClient tl/a/c baz
-read $_ o
-assert $o "E2: baz"
-
-#
-# Can the spurious calls to ResolveStep above be avoided??
-#
-
-# Mount the same server with a really long name.
-set long_name=tl/b/x/y/z/really/long
-mount $long_name $es_E2_name 1h
-wait $_
-
-echoClient $long_name "long baz"
-read $_ o
-assert $o "E2: long baz"
-
-# This example just creates a 'pointer' into the Echo servers name space.
-# NOTE: do we really need this functionality?
-#
-# ResolveStep is again called on the server for //tl/b/x/y/z/really/long
-mount tl/b/short1 $es_E2_name/$long_name 1h
-wait $_
-
-echoClient tl/b/short1 "short baz"
-read $_ o
-assert $o E2.${long_name}": short baz"
-
-# Create a mount table with a 'long' name
-set long_name=tl/b/some/deep/name/that/is/a/mount/table
-mt $localaddr $long_name
-set m=$_
-read $m
-eval $m
-set mt_l_name=$MT_NAME
-
-
-# Create a second mount table with a 'long' name
-set second_long_name=tl/a/some/deep/name/that/is/a/mount/table
-mt $localaddr $second_long_name
-set m=$_
-read $m
-eval $m
-set mt_l2_name=$MT_NAME
-
-# Run an echo server that uses that mount table
-echoServer $localaddr "E3" $long_name/echo
-set es_E3=$_
-eval $es_E3
-set es_E3_name=$NAME
-
-echoClient $long_name/echo "long E3"
-read $_ o
-assert $o "E3: long E3"
-
-# make sure that the mount table is the one we expect.
-resolveMT $long_name/echo
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-set ep1=$R0
-assert $mt_l_name/echo $ep1
-
-# Now, use mount directly to create a 'symlink'
-set symlink_target=some/deep/name/that/is/a/mount
-mount tl/b/symlink $mt_b_name/$symlink_target 1h M
-wait $_
-
-ls -l tl/b/symlink
-wait $_
-
-resolve tl/b/symlink
-set r=$_
-eval $r
-# used to return nothing since symlink is an 'interior' node.
-#assert $RN 0
-#
-# now we get the 'interior' returned.
-assert $RN 1
-eval $r
-assert $R0 $mt_b_name/$symlink_target
-# don't close or wait for this command since it'll error out.
-
-
-# resolveMT will return the original mount point
-resolveMT tl/b/symlink
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-set ep1=$R0
-assert $mt_b_name/symlink $ep1
-
-stop $es_E3
-stop $es_E2
-
-quit
-
-
diff --git a/cmd/naming/simulator/testdata/mt_simple.scr b/cmd/naming/simulator/testdata/mt_simple.scr
deleted file mode 100644
index 9c5b5f2..0000000
--- a/cmd/naming/simulator/testdata/mt_simple.scr
+++ /dev/null
@@ -1,101 +0,0 @@
-# Simple example showing multiple mount tables, servers and globing
-
-set localaddr="--veyron.tcp.address=127.0.0.1:0"
-set ws=--veyron.tcp.protocol=ws
-
-root $localaddr
-set m=$_
-read $m
-eval $m
-set root=$MT_NAME
-
-set NAMESPACE_ROOT=$root
-mt $localaddr $ws $localaddr usa
-set m=$_
-read $m
-eval $m
-set usa_mt=$MT_NAME
-mt $localaddr $ws $localaddr uk
-set m=$_
-read $m
-eval $m
-set uk_mt=$MT_NAME
-
-ls $root/...
-set l=$_
-eval $l
-assert $RN 3
-wait $l
-
-set NAMESPACE_ROOT=$usa_mt
-mt $localaddr $ws $localaddr "palo alto"
-set m=$_
-read $m
-eval $m
-set pa_mt=$MT_NAME
-
-set NAMESPACE_ROOT=$uk_mt
-mt $localaddr $ws $localaddr "cambridge"
-set m=$_
-read $m
-eval $m
-set cam_mt=$MT_NAME
-
-ls $root/...
-set l=$_
-eval $l
-assert $RN 7
-wait $l
-
-ls -l $root/...
-wait $_
-
-resolve $root/usa
-set r=$_
-eval $r
-# We get two endpoints back, in arbitrary order
-# one of which is 'ws', the other 'tcp'
-assert $RN 2
-eval $r
-set ep1=$R0
-eval $r
-set ep2=$R1
-assertOneOf $usa_mt $ep1 $ep2
-wait $r
-
-resolve  "$root/usa/palo alto"
-set r=$_
-assert $RN 2
-eval $r
-# this resolves to the mount table hosting palo alto, not the mount table
-# that would host any objects mounted on .../palo alto/...
-# but the uk/cambridge example below seems to behave the opposite way?
-eval $r
-set ep1=$R0
-eval $r
-set ep2=$R1
-assertOneOf $pa_mt $ep1 $ep2
-wait $r
-
-resolve $root/uk
-set r=$_
-eval $r
-assert $RN 2
-eval $r
-set ep1=$R0
-eval $r
-set ep2=$R1
-assertOneOf $uk_mt $ep1 $ep2
-wait $r
-
-resolve "$root/uk/cambridge"
-set r=$_
-eval $r
-assert $RN 2
-eval $r
-set ep1=$R0
-eval $r
-set ep2=$R1
-# this behaves differently to the usa/palo alto case?
-assertOneOf $cam_mt $ep1 $ep2
-wait $r
diff --git a/cmd/naming/simulator/testdata/proxy.scr b/cmd/naming/simulator/testdata/proxy.scr
deleted file mode 100644
index 855879e..0000000
--- a/cmd/naming/simulator/testdata/proxy.scr
+++ /dev/null
@@ -1,120 +0,0 @@
-cache off
-
-set localaddr=--veyron.tcp.address=127.0.0.1:0
-set ws=--veyron.tcp.protocol=ws
-
-root $localaddr
-set m=$_
-read $m
-eval $m
-set root=$MT_NAME
-set NAMESPACE_ROOT=$root
-setRoots $NAMESPACE_ROOT
-print $NAMESPACE_ROOT
-
-# run a non-proxied echo server
-echoServer $localaddr $ws $localaddr noproxy echo/noproxy
-set esnp=$_
-read $esnp
-eval $esnp
-set NP_ECHOS_NAME=$NAME
-
-echoClient echo/noproxy "ohh"
-set ec=$_
-read $ec l
-assert $l "noproxy: ohh"
-
-# run a proxy server
-proxyd $localaddr $ws $localaddr p1
-set proxy=$_
-read $proxy
-# PROXY_NAME=<name of proxy>
-eval $proxy
-splitEP $PROXY_NAME
-assert $PN 7
-set PROXY_ADDR=$P2
-set PROXY_RID=$P3
-
-
-# TODO(cnicolaou): figure out why ls appears to run slowly when a proxy is
-# running, maybe a problem with the mount table.
-#ls ...
-#set l=$_
-#eval $l
-#assert $RN 3
-#wait $l
-
-echoServer $localaddr $ws $localaddr --veyron.proxy=p1 withproxy echo/withproxy
-set eswp=$_
-read $eswp
-eval $eswp
-set ECHOS_NAME=$NAME
-splitEP $NAME
-set ECHOS_RID=$P3
-
-echoClient echo/withproxy "ahh"
-set ec=$_
-read $ec l
-assert $l "withproxy: ahh"
-
-#ls ...
-#set l=$_
-#eval $l
-#assert $RN 4
-#wait $l
-
-print "root mt:" $NAMESPACE_ROOT
-print "proxy:" $PROXY_ADDR
-print "no proxy: " $NP_ECHOS_NAME
-print "with proxy: " $ECHOS_NAME
-# The ipc.Server implementation publishes the proxy supplied address and
-# the local address in the mount table
-
-resolve echo/withproxy
-set rs=$_
-stop $rs
-quit
-eval $rs
-# This will be 4 when ipc.Listen can return all of the endpoints in use,
-# then the proxy can return more than one address. We only see 3 endpoints
-# because the proxy server only returns one to the echo server.
-assert $RN 3
-
-eval $rs
-set ep1=$R0
-eval $rs
-set ep2=$R1
-eval $rs
-set ep3=$R2
-#eval $rs
-#set ep4=$R3
-
-splitEP $ep1
-assert $PN 7
-set ep1_addr=$P2
-set rid=$P3
-splitEP $ep2
-set ep2_addr=$P2
-splitEP $ep3
-set ep3_addr=$P2
-#splitEP $ep4
-#set ep4_addr=$P2
-
-assertOneOf $PROXY_ADDR $ep1_addr $ep2_addr $ep3_addr
-# $ep4_addr
-assert $rid $ECHOS_RID
-
-ls -l echo/withproxy
-wait $_
-ls -l echo/noproxy
-wait $_
-
-echoClient echo/withproxy "ohh"
-set ec=$_
-read $ec l
-assert $l "withproxy: ohh"
-
-stop $eswp
-stop $esnp
-stop $proxy
-
diff --git a/cmd/naming/simulator/testdata/public_echo.scr b/cmd/naming/simulator/testdata/public_echo.scr
deleted file mode 100644
index 5447fad..0000000
--- a/cmd/naming/simulator/testdata/public_echo.scr
+++ /dev/null
@@ -1,32 +0,0 @@
-# Simple script to test for interop between the current checked in
-# code here and the running public mount table.
-
-# TODO(cnicolaou): reenable this when our prod services are more reliable.
-quit
-
-set localaddr=--veyron.tcp.address=127.0.0.1:0
-
-# now use the global nameserver.
-
-set global_name=global/echo
-echoServer $localaddr "text2" $global_name
-set es=$_
-read $es
-eval $es
-set es_name=$NAME
-
-echoClient "$global_name" "test 2"
-set ec=$_
-read $ec line
-assert $line "text2: test 2"
-
-# resolve will return the server's address
-resolve $global_name
-set r=$_
-eval $r
-assert $RN 1
-eval $r
-set ep1=$R0
-assert $es_name $ep1
-
-stop $es
diff --git a/cmd/naming/simulator/v23_test.go b/cmd/naming/simulator/v23_test.go
deleted file mode 100644
index 1453ba5..0000000
--- a/cmd/naming/simulator/v23_test.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file was auto-generated via go generate.
-// DO NOT UPDATE MANUALLY
-package main_test
-
-import "fmt"
-import "testing"
-import "os"
-
-import "v.io/x/ref/test"
-import "v.io/x/ref/test/modules"
-import "v.io/x/ref/test/v23tests"
-
-func TestMain(m *testing.M) {
-	test.Init()
-	if modules.IsModulesChildProcess() {
-		if err := modules.Dispatch(); err != nil {
-			fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
-			os.Exit(1)
-		}
-		return
-	}
-	cleanup := v23tests.UseSharedBinDir()
-	r := m.Run()
-	cleanup()
-	os.Exit(r)
-}
-
-func TestV23Simulator(t *testing.T) {
-	v23tests.RunTest(t, V23TestSimulator)
-}