MCPcopy
hub / github.com/restic/restic / Random

Function Random

internal/test/helpers.go:70–98  ·  view source on GitHub ↗

Random returns size bytes of pseudo-random data derived from the seed.

(seed, count int)

Source from the content-addressed store, hash-verified

68
69// Random returns size bytes of pseudo-random data derived from the seed.
70func Random(seed, count int) []byte {
71 p := make([]byte, count)
72
73 rnd := rand.New(rand.NewSource(int64(seed)))
74
75 for i := 0; i < len(p); i += 8 {
76 val := rnd.Int63()
77 var data = []byte{
78 byte((val >> 0) & 0xff),
79 byte((val >> 8) & 0xff),
80 byte((val >> 16) & 0xff),
81 byte((val >> 24) & 0xff),
82 byte((val >> 32) & 0xff),
83 byte((val >> 40) & 0xff),
84 byte((val >> 48) & 0xff),
85 byte((val >> 56) & 0xff),
86 }
87
88 for j := range data {
89 cur := i + j
90 if cur >= len(p) {
91 break
92 }
93 p[cur] = data[j]
94 }
95 }
96
97 return p
98}
99
100// SetupTarTestFixture extracts the tarFile to outputDir.
101func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) {

Callers 15

randomDataFunction · 0.92
saveRandomFileFunction · 0.92
BenchmarkSaveMethod · 0.92
TestLoadMethod · 0.92
TestListMethod · 0.92
TestSaveMethod · 0.92
TestSaveErrorMethod · 0.92
TestSaveWrongHashMethod · 0.92
TestBackendSaveRetryFunction · 0.92
TestBackendLoadRetryFunction · 0.92

Calls

no outgoing calls

Tested by 8

randomDataFunction · 0.74
TestBackendSaveRetryFunction · 0.74
TestBackendLoadRetryFunction · 0.74
TestFSReaderFunction · 0.74
TestFSReaderNestedFunction · 0.74
TestFSReaderDirFunction · 0.74