Added a small program to generate "random" data. It's not really random,
but it's only for tests. This allows the large files containing random data to be removed from the tree.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.98 2000/08/01 01:12:30 tale Exp $
|
||||
# $Id: Makefile.in,v 1.99 2000/08/08 21:47:49 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -42,7 +42,7 @@ LIBS = @LIBS@
|
||||
SUBDIRS = db dst master mem names net rbt sockaddr tasks timers system
|
||||
|
||||
# Alphabetically
|
||||
TARGETS =
|
||||
TARGETS = genrandom
|
||||
|
||||
XTARGETS = adb_test \
|
||||
byaddr_test \
|
||||
@@ -133,6 +133,9 @@ SRCS = adb_test.c \
|
||||
|
||||
all_tests: ${XTARGETS}
|
||||
|
||||
genrandom: genrandom.@O@
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ genrandom.@O@
|
||||
|
||||
adb_test: adb_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ adb_test.@O@ \
|
||||
${DNSLIBS} ${ISCLIBS} ${LIBS}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.23 2000/08/01 01:13:39 tale Exp $
|
||||
# $Id: Makefile.in,v 1.24 2000/08/08 21:47:51 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -51,6 +51,7 @@ t_dst: t_dst.@O@ ${DEPLIBS} ${TLIB}
|
||||
${LIBTOOL} ${CC} -o $@ t_dst.@O@ ${TLIB} ${LIBS}
|
||||
|
||||
test: t_dst
|
||||
../genrandom 50 randomfile
|
||||
-@ ./t_dst -b @srcdir@ -q 1800 -a
|
||||
|
||||
clean distclean::
|
||||
|
||||
Binary file not shown.
67
bin/tests/genrandom.c
Normal file
67
bin/tests/genrandom.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
unsigned int bytes;
|
||||
unsigned int k;
|
||||
char *endp;
|
||||
FILE *urandom, *fp;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: genrandom k file\n");
|
||||
exit(1);
|
||||
}
|
||||
k = strtoul(argv[1], &endp, 10);
|
||||
if (*endp != 0) {
|
||||
printf("usage: genrandom k file\n");
|
||||
exit(1);
|
||||
}
|
||||
bytes = k << 10;
|
||||
|
||||
fp = fopen(argv[2], "w");
|
||||
if (fp == NULL) {
|
||||
printf("failed to open %s\n", argv[2]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
urandom = fopen("/dev/urandom", "r");
|
||||
if (urandom != NULL) {
|
||||
unsigned char data[1024];
|
||||
while (bytes > 0) {
|
||||
size_t n, toread;
|
||||
toread = sizeof(data);
|
||||
if (toread > bytes)
|
||||
toread = bytes;
|
||||
n = fread(data, 1, toread, urandom);
|
||||
if (n <= 0) {
|
||||
printf("error reading /dev/urandom\n");
|
||||
exit(1);
|
||||
}
|
||||
if (fwrite(data, 1, n, fp) != n) {
|
||||
printf("error writing to file\n");
|
||||
exit(1);
|
||||
}
|
||||
bytes -= n;
|
||||
}
|
||||
fclose(urandom);
|
||||
} else {
|
||||
unsigned int seed = (unsigned int) time(NULL);
|
||||
srand(seed);
|
||||
while (bytes > 0) {
|
||||
int x = rand();
|
||||
if (fwrite(&x, 1, sizeof(int), fp) != sizeof(int)) {
|
||||
printf("error writing to file\n");
|
||||
exit(1);
|
||||
}
|
||||
bytes -= sizeof(int);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -15,7 +15,9 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: setup.sh,v 1.8 2000/08/01 01:14:32 tale Exp $
|
||||
# $Id: setup.sh,v 1.9 2000/08/08 21:47:55 bwelling Exp $
|
||||
|
||||
../../genrandom 400 random.data
|
||||
|
||||
cd ns1 && sh sign.sh
|
||||
|
||||
|
||||
Reference in New Issue
Block a user