func TestSimple(t *testing.T) { const blocksize = 512 dirname := MakeTempDir() MkdirP(dirname + "/a/1") MkdirP(dirname + "/b") MakeFile(dirname+"/a/1/file1", blocksize*11) MakeFile(dirname+"/a/1/file2", blocksize*20) MakeFile(dirname+"/file3", blocksize*15) x := multithread_du.TotalFileSize(dirname) AssertEqual(t, x, 56) }
func main() { flag.Parse() var args = flag.Args() var filename = "." if len(args) > 0 { filename = args[0] } first_filename := filename total_size := multithread_du.TotalFileSize(first_filename) fmt.Printf("%d\t%s\n", total_size, first_filename) }
// don't double count hard links func TestHardLinks(t *testing.T) { const blocksize = 512 dirname := MakeTempDir() MkdirP(dirname + "/a/1") MkdirP(dirname + "/b") MakeFile(dirname+"/a/1/file1", blocksize*11) MakeFile(dirname+"/a/1/file2", blocksize*20) MakeFile(dirname+"/file3", blocksize*15) err := os.Link(dirname+"/file3", dirname+"/hardlink") if err != nil { panic(err) } x := multithread_du.TotalFileSize(dirname) AssertEqual(t, x, 56) }
func TestEmptyDir(t *testing.T) { dirname := MakeTempDir() x := multithread_du.TotalFileSize(dirname) AssertEqual(t, x, 0) }