Random returns size bytes of pseudo-random data derived from the seed.
(seed, count int)
| 68 | |
| 69 | // Random returns size bytes of pseudo-random data derived from the seed. |
| 70 | func 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. |
| 101 | func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) { |
no outgoing calls