Beispiel #1
0
func TestExtChanges(t *testing.T) {
	os.Args[0] = "rzx.test"
	fstest.Verb = testing.Verbose()
	ccfg, err := net.TLSCfg("/Users/nemo/.ssh/client")
	if err != nil {
		t.Logf("no certs found, no tls conn")
	}
	scfg, err := net.TLSCfg("/Users/nemo/.ssh/server")
	if err != nil || ccfg == nil {
		ccfg = nil
		scfg = nil
		t.Logf("no certs found, no tls conn")
	}
	_, _ = scfg, ccfg
	fstest.MkTree(t, tdir)
	defer os.RemoveAll(tdir)
	lfs, err := zux.NewZX(tdir)
	if err != nil {
		t.Fatal(err)
	}
	defer lfs.Sync()

	cfs, err := New(lfs)
	if err != nil {
		t.Fatal(err)
	}
	defer cfs.Close()
	cfs.Debug = testing.Verbose()
	lfs.Debug = testing.Verbose()
	cfs.Flags.Set("rfsdebug", cfs.Debug)
	cfs.Flags.Set("cachedebug", cfs.Debug)
	cfs.Flags.Set("verb", cfs.Debug)
	rc := fscmp.Diff(lfs, cfs)
	out := ""
	for c := range rc {
		s := fmt.Sprintf("pre chg %s %s\n", c.Type, c.D.Fmt())
		out += s
	}
	if len(out) > 0 {
		t.Fatalf("had changes")
	}
	cfs.Dprintf("%s", out)
	fstest.MkZXChgs(t, lfs)
	fstest.MkZXChgs2(t, lfs)
	cacheTout = time.Millisecond
	time.Sleep(cacheTout)
	rc = fscmp.Diff(lfs, cfs)
	out = ""
	for c := range rc {
		s := fmt.Sprintf("post chg %s %s\n", c.Type, c.D.Fmt())
		out += s
	}
	cfs.Dprintf("%s", out)
	if len(out) > 0 {
		t.Fatalf("had missed external changes")
	}
	if cfs.Debug {
		cfs.c.dump()
	}
}
Beispiel #2
0
func runTest(t *testing.T, fn fstest.TestFunc) {
	os.Args[0] = "rzx.test"
	fstest.Verb = testing.Verbose()
	ccfg, err := net.TLSCfg("/Users/nemo/.ssh/client")
	if err != nil {
		t.Logf("no certs found, no tls conn")
	}
	scfg, err := net.TLSCfg("/Users/nemo/.ssh/server")
	if err != nil || ccfg == nil {
		ccfg = nil
		scfg = nil
		t.Logf("no certs found, no tls conn")
	}
	_, _ = scfg, ccfg
	fstest.MkTree(t, tdir)
	defer os.RemoveAll(tdir)
	lfs, err := zux.NewZX(tdir)
	if err != nil {
		t.Fatal(err)
	}
	defer lfs.Sync()

	cfs, err := New(lfs)
	if err != nil {
		t.Fatal(err)
	}
	defer cfs.Close()
	cfs.Debug = testing.Verbose()
	lfs.Debug = testing.Verbose()
	cfs.Flags.Set("rfsdebug", cfs.Debug)
	cfs.Flags.Set("cachedebug", cfs.Debug)
	if fn != nil {
		fn(t, cfs)
	} else {
		d, err := zx.Stat(cfs, "/")
		if err != nil {
			t.Fatalf("stat /: %v", err)
		}
		t.Logf("/ stat is %s\n", d.TestFmt())
	}
	if cfs.Debug {
		cfs.c.dump()
	}
}