func TestDirJoin(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("skipping test on windows") } wfi, err := os.Stat("/etc/hosts") if err != nil { t.Skip("skipping test; no /etc/hosts file") } test := func(d http.Dir, name string) { f, err := d.Open(name) if err != nil { t.Fatalf("open of %s: %v", name, err) } defer f.Close() gfi, err := f.Stat() if err != nil { t.Fatalf("stat of %s: %v", name, err) } if !os.SameFile(gfi, wfi) { t.Errorf("%s got different file", name) } } test(http.Dir("/etc/"), "/hosts") test(http.Dir("/etc/"), "hosts") test(http.Dir("/etc/"), "../../../../hosts") test(http.Dir("/etc"), "/hosts") test(http.Dir("/etc"), "hosts") test(http.Dir("/etc"), "../../../../hosts") // Not really directories, but since we use this trick in // ServeFile, test it: test(http.Dir("/etc/hosts"), "") test(http.Dir("/etc/hosts"), "/") test(http.Dir("/etc/hosts"), "../") }
func TestLatencyEWMAFun(t *testing.T) { t.Skip("run it for fun") m := peer.NewMetrics() id, err := testutil.RandPeerID() if err != nil { t.Fatal(err) } mu := 100.0 sig := 10.0 next := func() time.Duration { mu = (rand.NormFloat64() * sig) + mu return time.Duration(mu) } print := func() { fmt.Printf("%3.f %3.f --> %d\n", sig, mu, m.LatencyEWMA(id)) } for { select { case <-time.After(200 * time.Millisecond): m.RecordLatency(id, next()) print() } } }
func numOpenFDS(t *testing.T) (n int, lsof []byte) { lsof, err := exec.Command("lsof", "-b", "-n", "-p", strconv.Itoa(os.Getpid())).Output() if err != nil { t.Skip("skipping test; error finding or running lsof") } return bytes.Count(lsof, []byte("\n")), lsof }
// Test that simultaneous RemoveAll do not report an error. // As long as it gets removed, we should be happy. func TestRemoveAllRace(t *testing.T) { if runtime.GOOS == "windows" { // Windows has very strict rules about things like // removing directories while someone else has // them open. The racing doesn't work out nicely // like it does on Unix. t.Skip("skipping on windows") } n := runtime.GOMAXPROCS(16) defer runtime.GOMAXPROCS(n) root, err := ioutil.TempDir("", "issue") if err != nil { t.Fatal(err) } mkdirTree(t, root, 1, 6) hold := make(chan struct{}) var wg sync.WaitGroup for i := 0; i < 4; i++ { wg.Add(1) go func() { defer wg.Done() <-hold err := RemoveAll(root) if err != nil { t.Errorf("unexpected error: %T, %q", err, err) } }() } close(hold) // let workers race to remove root wg.Wait() }
func TestIndexesAsync_ClientWaitScenario(t *testing.T) { testDBWrapper.CreateFreshDB(t) testBlockchainWrapper := newTestBlockchainWrapper(t) chain := testBlockchainWrapper.blockchain if chain.indexer.isSynchronous() { t.Skip("Skipping because blockchain is configured to index block data synchronously") } blocks, _, err := testBlockchainWrapper.populateBlockChainWithSampleData() if err != nil { t.Logf("Error populating block chain with sample data: %s", err) t.Fail() } t.Log("Increasing size of blockchain by one artificially so as to make client wait") chain.size = chain.size + 1 t.Log("Resetting size of blockchain to original and adding one block in a separate go routine so as to wake up the client") go func() { time.Sleep(2 * time.Second) chain.size = chain.size - 1 blk, err := buildTestBlock(t) if err != nil { t.Logf("Error building test block: %s", err) t.Fail() } testBlockchainWrapper.addNewBlock(blk, []byte("stateHash")) }() t.Log("Executing client query. The client would wait and will be woken up") blockHash, _ := blocks[0].GetHash() block := testBlockchainWrapper.getBlockByHash(blockHash) testutil.AssertEquals(t, block, blocks[0]) }
func TestUntarInvalidFilenames(t *testing.T) { // TODO Windows: Figure out how to fix this test. if runtime.GOOS == "windows" { t.Skip("Passes but hits breakoutError: platform and architecture is not supported") } for i, headers := range [][]*tar.Header{ { { Name: "../victim/dotdot", Typeflag: tar.TypeReg, Mode: 0644, }, }, { { // Note the leading slash Name: "/../victim/slash-dotdot", Typeflag: tar.TypeReg, Mode: 0644, }, }, } { if err := testBreakout("untar", "docker-TestUntarInvalidFilenames", headers); err != nil { t.Fatalf("i=%d. %v", i, err) } } }
func TestSetICMPFilter(t *testing.T) { switch runtime.GOOS { case "nacl", "plan9", "solaris", "windows": t.Skipf("not supported on %s", runtime.GOOS) } if !supportsIPv6 { t.Skip("ipv6 is not supported") } if m, ok := nettest.SupportsRawIPSocket(); !ok { t.Skip(m) } c, err := net.ListenPacket("ip6:ipv6-icmp", "::1") if err != nil { t.Fatal(err) } defer c.Close() p := ipv6.NewPacketConn(c) var f ipv6.ICMPFilter f.SetAll(true) f.Accept(ipv6.ICMPTypeEchoRequest) f.Accept(ipv6.ICMPTypeEchoReply) if err := p.SetICMPFilter(&f); err != nil { t.Fatal(err) } kf, err := p.ICMPFilter() if err != nil { t.Fatal(err) } if !reflect.DeepEqual(kf, &f) { t.Fatalf("got %#v; want %#v", kf, f) } }
func TestOverThousandBlobs(t *testing.T) { if skipS3() != "" { t.Skip(skipS3()) } rootDir, err := ioutil.TempDir("", "driver-") if err != nil { t.Fatalf("unexpected error creating temporary directory: %v", err) } defer os.Remove(rootDir) standardDriver, err := s3DriverConstructor(rootDir, s3.StorageClassStandard) if err != nil { t.Fatalf("unexpected error creating driver with standard storage: %v", err) } ctx := context.Background() for i := 0; i < 1005; i++ { filename := "/thousandfiletest/file" + strconv.Itoa(i) contents := []byte("contents") err = standardDriver.PutContent(ctx, filename, contents) if err != nil { t.Fatalf("unexpected error creating content: %v", err) } } // cant actually verify deletion because read-after-delete is inconsistent, but can ensure no errors err = standardDriver.Delete(ctx, "/thousandfiletest") if err != nil { t.Fatalf("unexpected error deleting thousand files: %v", err) } }
func TestTypeScriptFile(t *testing.T) { bin := os.Getenv("STATIX_TEST_TYPESCRIPT_BIN") if bin == "" { t.Skip("STATIX_TEST_TYPESCRIPT_BIN is not set") } s := resource.NewFile("./testFiles/test-main.ts") a := NewTypeScript(bin) r, err := a.Alter(s) if err != nil { t.Error("could not alter resource", err.Error()) } content, err := r.Dump() if err != nil { t.Error("could not dump content") } expected := `var Test = (function () { function Test() { } return Test; })(); /// <reference path="./test-ref.ts"/> ` if !bytes.Equal(content, []byte(expected)) { t.Error("content dumped is not correct", string(content)) } }
func TestRawConnUnicastSocketOptions(t *testing.T) { switch runtime.GOOS { case "nacl", "plan9": t.Skipf("not supported on %s", runtime.GOOS) } if m, ok := nettest.SupportsRawIPSocket(); !ok { t.Skip(m) } ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) if ifi == nil { t.Skipf("not available on %s", runtime.GOOS) } c, err := net.ListenPacket("ip4:icmp", "127.0.0.1") if err != nil { t.Fatal(err) } defer c.Close() r, err := ipv4.NewRawConn(c) if err != nil { t.Fatal(err) } testUnicastSocketOptions(t, r) }
func TestWindowsPaths(t *testing.T) { if runtime.GOOS != "windows" { t.Skip("Not useful on non-Windows") return } folder := FolderConfiguration{ RawPath: `e:\`, } expected := `\\?\e:\` actual := folder.Path() if actual != expected { t.Errorf("%q != %q", actual, expected) } folder.RawPath = `\\192.0.2.22\network\share` expected = folder.RawPath actual = folder.Path() if actual != expected { t.Errorf("%q != %q", actual, expected) } folder.RawPath = `relative\path` expected = folder.RawPath actual = folder.Path() if actual == expected || !strings.HasPrefix(actual, "\\\\?\\") { t.Errorf("%q == %q, expected absolutification", actual, expected) } }
func TestGetppid(t *testing.T) { switch runtime.GOOS { case "nacl": t.Skip("skipping on nacl") return case "plan9": // TODO: golang.org/issue/8206 t.Skipf("skipping test on plan9; see issue 8206") } if Getenv("GO_WANT_HELPER_PROCESS") == "1" { fmt.Print(Getppid()) Exit(0) } cmd := osexec.Command(Args[0], "-test.run=TestGetppid") cmd.Env = append(Environ(), "GO_WANT_HELPER_PROCESS=1") // verify that Getppid() from the forked process reports our process id output, err := cmd.CombinedOutput() if err != nil { t.Fatalf("Failed to spawn child process: %v %q", err, string(output)) } childPpid := string(output) ourPid := fmt.Sprintf("%d", Getpid()) if childPpid != ourPid { t.Fatalf("Child process reports parent process id '%v', expected '%v'", childPpid, ourPid) } }
func TestDialTimeout(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } listener := newLocalListener(t) addr := listener.Addr().String() defer listener.Close() complete := make(chan bool) defer close(complete) go func() { conn, err := listener.Accept() if err != nil { t.Error(err) return } <-complete conn.Close() }() dialer := &net.Dialer{ Timeout: 10 * time.Millisecond, } var err error if _, err = DialWithDialer(dialer, "tcp", addr, nil); err == nil { t.Fatal("DialWithTimeout completed successfully") } if !isTimeoutError(err) { t.Errorf("resulting error not a timeout: %v\nType %T: %#v", err, err, err) } }
func TestAccVcdSNAT_Basic(t *testing.T) { if v := os.Getenv("VCD_EXTERNAL_IP"); v == "" { t.Skip("Environment variable VCD_EXTERNAL_IP must be set to run SNAT tests") return } var e govcd.EdgeGateway resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckVcdSNATDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: fmt.Sprintf(testAccCheckVcdSnat_basic, os.Getenv("VCD_EDGE_GATWEWAY"), os.Getenv("VCD_EXTERNAL_IP")), Check: resource.ComposeTestCheckFunc( testAccCheckVcdSNATExists("vcd_snat.bar", &e), resource.TestCheckResourceAttr( "vcd_snat.bar", "external_ip", os.Getenv("VCD_EXTERNAL_IP")), resource.TestCheckResourceAttr( "vcd_snat.bar", "internal_ip", "10.10.102.0/24"), ), }, }, }) }
func TestRunSedotanReadRecHistory(t *testing.T) { t.Skip("Skip : Comment this line to do test") arrcmd := make([]string, 0, 0) result := toolkit.M{} arrcmd = append(arrcmd, EC_APP_PATH+`\bin\sedotanread.exe`) arrcmd = append(arrcmd, `-readtype=rechistory`) arrcmd = append(arrcmd, `-recfile=E:\EACIIT\src\github.com\eaciit\colony-app\data-root\webgrabber\historyrec\irondcecomcn.Iron01-20160316022830.csv`) if runtime.GOOS == "windows" { cmd = exec.Command(arrcmd[0], arrcmd[1:]...) rechistory, err := toolkit.RunCommand(arrcmd[0], arrcmd[1:]...) err = toolkit.UnjsonFromString(rechistory, &result) if err != nil { t.Errorf("Error, %s \n", err) } byteoutput, err := cmd.CombinedOutput() if err != nil { // Log.AddLog(fmt.Sprintf("[%v] run at %v, found error : %v", eid, sedotan.DateToString(thistime), err.Error()), "ERROR") } err = toolkit.UnjsonFromString(string(byteoutput), &result) } else { // cmd = exec.Command("sudo", "../daemon/sedotandaemon", `-config="`+tbasepath+`\config-daemon.json"`, `-logpath="`+tbasepath+`\log"`) } fmt.Println(result) }
func TestClose(t *testing.T) { if runtime.GOOS == "plan9" { t.Skip("see golang.org/issue/11454") } once.Do(startServer) conn, err := net.Dial("tcp", serverAddr) if err != nil { t.Fatal("dialing", err) } cc := closerConn{Conn: conn} client, err := NewClient(newConfig(t, "/echo"), &cc) if err != nil { t.Fatalf("WebSocket handshake: %v", err) } // set the deadline to ten minutes ago, which will have expired by the time // client.Close sends the close status frame. conn.SetDeadline(time.Now().Add(-10 * time.Minute)) if err := client.Close(); err == nil { t.Errorf("ws.Close(): expected error, got %v", err) } if cc.closed < 1 { t.Fatalf("ws.Close(): expected underlying ws.rwc.Close to be called > 0 times, got: %v", cc.closed) } }
func TestInterfaceGenerator(t *testing.T) { if _, err := os.Stat("/etc/fedora-release"); err == nil { t.Skip("The OS seems to be Fedora. Skipping interface test for now") } if os.Getenv("TRAVIS") != "" { t.Skip("Skip: in Travis, Skipping interface test for now") } g := &InterfaceGenerator{1 * time.Second} values, err := g.Generate() if err != nil { t.Errorf("should not raise error: %v", err) } metrics := []string{ "rxBytes", "txBytes", } for _, metric := range metrics { if value, ok := values["interface.eth0."+metric+".delta"]; !ok { t.Errorf("Value for interface.eth0.%s.delta should be collected", metric) } else { t.Logf("Interface eth0 '%s' delta collected: %+v", metric, value) } } for _, metric := range metrics { if _, ok := values["interface.lo."+metric+".delta"]; ok { t.Errorf("Value for interface.lo.%s should NOT be collected", metric) } else { t.Logf("Interface lo '%s' NOT collected", metric) } } }
func TestQemuDriver_RequiresMemory(t *testing.T) { if !qemuLocated() { t.Skip("QEMU not found; skipping") } // TODO: use test server to load from a fixture task := &structs.Task{ Name: "linux", Config: map[string]string{ "image_source": "https://dl.dropboxusercontent.com/u/47675/jar_thing/linux-0.2.img", "accelerator": "tcg", "host_port": "8080", "guest_port": "8081", "checksum": "a5e836985934c3392cbbd9b26db55a7d35a8d7ae1deb7ca559dd9c0159572544", // ssh u/p would be here }, } driverCtx := testDriverContext(task.Name) ctx := testDriverExecContext(task, driverCtx) defer ctx.AllocDir.Destroy() d := NewQemuDriver(driverCtx) _, err := d.Start(ctx, task) if err == nil { t.Fatalf("Expected error when not specifying memory") } }
func TestUntarHardlinkToSymlink(t *testing.T) { // TODO Windows. There may be a way of running this, but turning off for now if runtime.GOOS == "windows" { t.Skip("hardlinks on Windows") } for i, headers := range [][]*tar.Header{ { { Name: "symlink1", Typeflag: tar.TypeSymlink, Linkname: "regfile", Mode: 0644, }, { Name: "symlink2", Typeflag: tar.TypeLink, Linkname: "symlink1", Mode: 0644, }, { Name: "regfile", Typeflag: tar.TypeReg, Mode: 0644, }, }, } { if err := testBreakout("untar", "docker-TestUntarHardlinkToSymlink", headers); err != nil { t.Fatalf("i=%d. %v", i, err) } } }
func TestLookupIPDeadline(t *testing.T) { if !*testDNSFlood { t.Skip("test disabled; use -dnsflood to enable") } const N = 5000 const timeout = 3 * time.Second c := make(chan error, 2*N) for i := 0; i < N; i++ { name := fmt.Sprintf("%d.net-test.golang.org", i) go func() { _, err := lookupIPDeadline(name, time.Now().Add(timeout/2)) c <- err }() go func() { _, err := lookupIPDeadline(name, time.Now().Add(timeout)) c <- err }() } qstats := struct { succeeded, failed int timeout, temporary, other int unknown int }{} deadline := time.After(timeout + time.Second) for i := 0; i < 2*N; i++ { select { case <-deadline: t.Fatal("deadline exceeded") case err := <-c: switch err := err.(type) { case nil: qstats.succeeded++ case Error: qstats.failed++ if err.Timeout() { qstats.timeout++ } if err.Temporary() { qstats.temporary++ } if !err.Timeout() && !err.Temporary() { qstats.other++ } default: qstats.failed++ qstats.unknown++ } } } // A high volume of DNS queries for sub-domain of golang.org // would be coordinated by authoritative or recursive server, // or stub resolver which implements query-response rate // limitation, so we can expect some query successes and more // failures including timeout, temporary and other here. // As a rule, unknown must not be shown but it might possibly // happen due to issue 4856 for now. t.Logf("%v succeeded, %v failed (%v timeout, %v temporary, %v other, %v unknown)", qstats.succeeded, qstats.failed, qstats.timeout, qstats.temporary, qstats.other, qstats.unknown) }
// Run this shell script, but do it in Go so it can be run by "go test". // go build -o testvet // $(GOROOT)/test/errchk ./testvet -shadow -printfuncs='Warn:1,Warnf:1' testdata/*.go testdata/*.s // rm testvet // func TestVet(t *testing.T) { // Plan 9 and Windows systems can't be guaranteed to have Perl and so can't run errchk. switch runtime.GOOS { case "plan9", "windows": t.Skip("skipping test; no Perl on %q", runtime.GOOS) } // go build cmd := exec.Command("go", "build", "-o", binary) run(cmd, t) // defer removal of vet defer os.Remove(binary) // errchk ./testvet gos, err := filepath.Glob(filepath.Join(dataDir, "*.go")) if err != nil { t.Fatal(err) } asms, err := filepath.Glob(filepath.Join(dataDir, "*.s")) if err != nil { t.Fatal(err) } files := append(gos, asms...) errchk := filepath.Join(runtime.GOROOT(), "test", "errchk") flags := []string{ "./" + binary, "-printfuncs=Warn:1,Warnf:1", "-test", // TODO: Delete once -shadow is part of -all. } cmd = exec.Command(errchk, append(flags, files...)...) if !run(cmd, t) { t.Fatal("vet command failed") } }
func TestLookupGoogleSRV(t *testing.T) { if testing.Short() || !*testExternal { t.Skip("avoid external network") } if !supportsIPv4 || !*testIPv4 { t.Skip("IPv4 is required") } for _, tt := range lookupGoogleSRVTests { cname, srvs, err := LookupSRV(tt.service, tt.proto, tt.name) if err != nil { t.Fatal(err) } if len(srvs) == 0 { t.Error("got no record") } if !strings.HasSuffix(cname, tt.cname) && !strings.HasSuffix(cname, tt.cname+".") { t.Errorf("got %s; want %s", cname, tt.cname) } for _, srv := range srvs { if !strings.HasSuffix(srv.Target, tt.target) && !strings.HasSuffix(srv.Target, tt.target+".") { t.Errorf("got %v; want a record containing %s", srv, tt.target) } } } }
func TestClientRunContainer(t *testing.T) { t.Skip() dockerCli, err := dockerclient.New() if err != nil { t.Fatal(err) } cli, err := NewClient(&DockerClient{Docker: dockerCli}) if err != nil { t.Fatal(err) } yml := ` namespace: test containers: main: image: "busybox:buildroot-2013.08.1" labels: foo: bar xxx: yyy ` config, err := config.ReadConfig("test.yml", strings.NewReader(yml), map[string]interface{}{}, map[string]interface{}{}, false) if err != nil { t.Fatal(err) } for _, container := range GetContainersFromConfig(config) { if err := cli.RunContainer(container); err != nil { t.Fatal(err) } } }
func TestTimeout(t *testing.T) { if testing.Short() { t.Skip("Integration test - skipping for short mode.") } sleepForeverHandler := func(w http.ResponseWriter, req *http.Request) { req.Close = true notify := w.(http.CloseNotifier).CloseNotify() <-notify } server := httptest.NewServer(http.HandlerFunc(sleepForeverHandler)) defer server.Close() rg := NewRecordGenerator(500 * time.Millisecond) host, port, err := net.SplitHostPort(server.Listener.Addr().String()) _, err = rg.loadFromMaster(host, port) if err == nil { t.Fatal("Expect error because of timeout handler") } urlErr, ok := (err).(*url.Error) if !ok { t.Fatalf("Expected url.Error, instead: %#v", urlErr) } netErr, ok := urlErr.Err.(net.Error) if !ok { t.Fatalf("Expected net.Error, instead: %#v", netErr) } if !netErr.Timeout() { t.Errorf("Did not receive a timeout, instead: %#v", err) } }
func TestUnixgramAutobind(t *testing.T) { if runtime.GOOS != "linux" { t.Skip("skipping: autobind is linux only") } laddr := &UnixAddr{Name: "", Net: "unixgram"} c1, err := ListenUnixgram("unixgram", laddr) if err != nil { t.Fatalf("ListenUnixgram failed: %v", err) } defer c1.Close() // retrieve the autobind address autoAddr := c1.LocalAddr().(*UnixAddr) if len(autoAddr.Name) <= 1 { t.Fatalf("invalid autobind address: %v", autoAddr) } if autoAddr.Name[0] != '@' { t.Fatalf("invalid autobind address: %v", autoAddr) } c2, err := DialUnix("unixgram", nil, autoAddr) if err != nil { t.Fatalf("DialUnix failed: %v", err) } defer c2.Close() if !reflect.DeepEqual(c1.LocalAddr(), c2.RemoteAddr()) { t.Fatalf("expected autobind address %v, got %v", c1.LocalAddr(), c2.RemoteAddr()) } }
func TestPostgresqlDefaultsToAllDatabases(t *testing.T) { if testing.Short() { t.Skip("Skipping integration test in short mode") } p := &Postgresql{ Address: fmt.Sprintf("host=%s user=postgres sslmode=disable", testutil.GetLocalHost()), } var acc testutil.Accumulator err := p.Gather(&acc) require.NoError(t, err) var found bool for _, pnt := range acc.Metrics { if pnt.Measurement == "postgresql" { if pnt.Tags["db"] == "postgres" { found = true break } } } assert.True(t, found) }
func TestCacheComplete(t *testing.T) { paths := DefaultPaths() if len(paths) == 0 { t.Skip("No default paths available") } tests := []string{"mscorlib.dll", "System.dll"} t.Log(paths) c := Cache{paths: paths} for _, test := range tests { if asm, err := c.Load(test); err != nil { t.Error(err) } else { t.Logf("Found %s (%s)", test, asm.Name()) } } tests2 := []content.Type{ content.Type{Name: content.FullyQualifiedName{Absolute: "net://type/System.String"}}, } for _, test := range tests2 { if res, err := c.Complete(&test); err != nil { t.Error(err) } else { t.Log(res) } } }
func TestLoadBasic_import(t *testing.T) { // Skip because we disabled importing t.Skip() c, err := Load(filepath.Join(fixtureDir, "import.tf")) if err != nil { t.Fatalf("err: %s", err) } if c == nil { t.Fatal("config should not be nil") } actual := variablesStr(c.Variables) if actual != strings.TrimSpace(importVariablesStr) { t.Fatalf("bad:\n%s", actual) } actual = providerConfigsStr(c.ProviderConfigs) if actual != strings.TrimSpace(importProvidersStr) { t.Fatalf("bad:\n%s", actual) } actual = resourcesStr(c.Resources) if actual != strings.TrimSpace(importResourcesStr) { t.Fatalf("bad:\n%s", actual) } }
func TestCommandRelativeName(t *testing.T) { if runtime.GOOS == "darwin" && runtime.GOARCH == "arm" { t.Skip("skipping on darwin/arm") } // Run our own binary as a relative path // (e.g. "_test/exec.test") our parent directory. base := filepath.Base(os.Args[0]) // "exec.test" dir := filepath.Dir(os.Args[0]) // "/tmp/go-buildNNNN/os/exec/_test" if dir == "." { t.Skip("skipping; running test at root somehow") } parentDir := filepath.Dir(dir) // "/tmp/go-buildNNNN/os/exec" dirBase := filepath.Base(dir) // "_test" if dirBase == "." { t.Skipf("skipping; unexpected shallow dir of %q", dir) } cmd := exec.Command(filepath.Join(dirBase, base), "-test.run=TestHelperProcess", "--", "echo", "foo") cmd.Dir = parentDir cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} out, err := cmd.Output() if err != nil { t.Errorf("echo: %v", err) } if g, e := string(out), "foo\n"; g != e { t.Errorf("echo: want %q, got %q", e, g) } }
func TestWildWildcardListener(t *testing.T) { switch runtime.GOOS { case "plan9": t.Skipf("skipping test on %q", runtime.GOOS) } if testing.Short() || !*testExternal { t.Skip("skipping test to avoid external network") } defer func() { if recover() != nil { t.Fatalf("panicked") } }() if ln, err := Listen("tcp", ""); err == nil { ln.Close() } if ln, err := ListenPacket("udp", ""); err == nil { ln.Close() } if ln, err := ListenTCP("tcp", nil); err == nil { ln.Close() } if ln, err := ListenUDP("udp", nil); err == nil { ln.Close() } if ln, err := ListenIP("ip:icmp", nil); err == nil { ln.Close() } }