go-hep.org/x/hep@v0.38.1/xrootd/cmd/xrd-cp/main_test.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "os" 9 "path/filepath" 10 "testing" 11 ) 12 13 func TestXrdCp(t *testing.T) { 14 dir, err := os.MkdirTemp("", "xrootd-xrdcp-") 15 if err != nil { 16 t.Fatal(err) 17 } 18 defer os.RemoveAll(dir) 19 20 dst := filepath.Join(dir, "chain.1.root") 21 src := "root://ccxrootdgotest.in2p3.fr:9001/tmp/rootio/testdata/chain.1.root" 22 23 const ( 24 recursive = false 25 verbose = true 26 ) 27 28 err = xrdcopy(dst, src, recursive, verbose) 29 if err != nil { 30 t.Fatalf("could not copy remote file: %v", err) 31 } 32 } 33 34 func BenchmarkXrdCp_Small(b *testing.B) { 35 benchmarkXrdCp(b, "root://ccxrootdgotest.in2p3.fr:9001/tmp/rootio/testdata/chain.1.root") 36 } 37 38 func BenchmarkXrdCp_Medium(b *testing.B) { 39 benchmarkXrdCp(b, "root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/SMHiggsToZZTo4L.root") 40 } 41 42 func BenchmarkXrdCp_Large(b *testing.B) { 43 benchmarkXrdCp(b, "root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleElectron.root") 44 } 45 46 func benchmarkXrdCp(b *testing.B, src string) { 47 dir, err := os.MkdirTemp("", "xrootd-xrdcp-") 48 if err != nil { 49 b.Fatal(err) 50 } 51 defer os.RemoveAll(dir) 52 53 dst := filepath.Join(dir, filepath.Base(src)) 54 55 const ( 56 recursive = false 57 verbose = false 58 ) 59 60 b.ResetTimer() 61 for i := 0; i < b.N; i++ { 62 os.RemoveAll(dst) 63 err = xrdcopy(dst, src, recursive, verbose) 64 if err != nil { 65 b.Fatalf("could not copy remote file: %v", err) 66 } 67 } 68 }