xrootd: use mkdir+ioutil.TempDir for r/w tests
some of the xrootd tests create files on the remote server and somewhat modify them. it's racy and if the same 2 tests run "at the same time", the remote server will either complain or fail the test.
for r/w files that tests create, we should create them under /tmp/xrd-test-xxxxx
, with some helper function similar to:
$> go doc io/ioutil.TempDir
func TempDir(dir, prefix string) (name string, err error)
TempDir creates a new temporary directory in the directory dir with a name
beginning with prefix and returns the path of the new directory. If dir is
the empty string, TempDir uses the default directory for temporary files
(see os.TempDir). Multiple programs calling TempDir simultaneously will not
choose the same directory. It is the caller's responsibility to remove the
directory when no longer needed.
ie:
func tempdir(cli *xrdclient.Client, dir, prefix string) (name string, err error) {
// ...
}
func TestFoo(t *testing.T) {
dir, err := tempdir(cli, "", "xrd-test-")
if err != nil {
t.Fatalf("could not create temporary directory: %v", err)
}
defer cli.FS().RemoveAll(dir)
}
this requires to have both:
kXR_rmdir
-
kXR_mkdir
implemented...