]> arthur.barton.de Git - bup.git/blob - randomgen.c
test-sh: don't truncate stderr.
[bup.git] / randomgen.c
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <stdint.h>
5 #include <assert.h>
6
7 int main(int argc, char **argv)
8 {
9     if (argc != 2)
10     {
11         fprintf(stderr, "usage: %s <kbytes>\n", argv[0]);
12         return 1;
13     }
14     
15     int kbytes = atoi(argv[1]);
16     uint32_t buf[1024/4];
17     ssize_t written;
18     int i;
19     
20     for (; kbytes > 0; kbytes--)
21     {
22         for (i = 0; i < sizeof(buf)/sizeof(buf[0]); i++)
23             buf[i] = random();
24         written = write(1, buf, sizeof(buf));
25         assert(written = sizeof(buf)); // we'd die from SIGPIPE otherwise
26         if (!(kbytes%1024))
27             fprintf(stderr, ".");
28     }
29     
30     return 0;
31 }