Add the random_test app
Move the building of the test apps into this dir's Jamfile as it seems to make more sense that way. I'll be removing them from the one in kernel shortly. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@318 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9f2313755f
commit
9843673aa8
@ -2,7 +2,45 @@ SubDir OBOS_TOP src kernel apps tests ;
|
||||
|
||||
KernelObjects
|
||||
<$(SOURCE_GRIST)>thread_test.c
|
||||
<$(SOURCE_GRIST)>fops_test.c
|
||||
<$(SOURCE_GRIST)>fops_test.c
|
||||
<$(SOURCE_GRIST)>random_test.c
|
||||
:
|
||||
-fpic -Wno-unused
|
||||
;
|
||||
|
||||
KernelLd thread_test :
|
||||
libglue2.o
|
||||
<$(SOURCE_GRIST)>thread_test.o
|
||||
libc.so
|
||||
:
|
||||
$(OBOS_TOP)/src/kernel/ldscripts/$(OBOS_ARCH)/app.ld
|
||||
:
|
||||
:
|
||||
:
|
||||
bin/thread_test
|
||||
;
|
||||
|
||||
KernelLd fops_test :
|
||||
libglue2.o
|
||||
<$(SOURCE_GRIST)>fops_test.o
|
||||
libc.so
|
||||
:
|
||||
$(OBOS_TOP)/src/kernel/ldscripts/$(OBOS_ARCH)/app.ld
|
||||
:
|
||||
:
|
||||
:
|
||||
bin/fops_test
|
||||
;
|
||||
|
||||
KernelLd random_test :
|
||||
libglue2.o
|
||||
<$(SOURCE_GRIST)>random_test.o
|
||||
libc.so
|
||||
libm.so
|
||||
:
|
||||
$(OBOS_TOP)/src/kernel/ldscripts/$(OBOS_ARCH)/app.ld
|
||||
:
|
||||
:
|
||||
:
|
||||
bin/random_test
|
||||
;
|
||||
|
44
src/kernel/apps/tests/random_test.c
Normal file
44
src/kernel/apps/tests/random_test.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <syscalls.h>
|
||||
#include <ktypes.h>
|
||||
#include <resource.h>
|
||||
#include <Errors.h>
|
||||
#include <errno.h>
|
||||
#include <OS.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define RANDOM_DEVICE "/dev/urandom"
|
||||
#define RANDOM_CHECKS 5
|
||||
#define STR_LEN 16
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
char data[STR_LEN];
|
||||
int rv, i, j;
|
||||
|
||||
printf("/dev/urandom test\n"
|
||||
"=================\n\n");
|
||||
|
||||
fd = open(RANDOM_DEVICE, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
printf("Failed to open %s\n", RANDOM_DEVICE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i=0; i < RANDOM_CHECKS; i++) {
|
||||
rv = read(fd, data, STR_LEN);
|
||||
if (rv < STR_LEN)
|
||||
break;
|
||||
printf ("%d: ", i);
|
||||
for (j=0; j < sizeof(data);j++) {
|
||||
printf(" %02x ", (uint8)data[j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user