Added small test program that opens and reads a few bytes from
/dev/urandom. It verifies that Haiku's dev/urandom is performance-wise totally unusable -- it takes several seconds. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23904 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
SubDir HAIKU_TOP src tests add-ons kernel drivers ;
|
SubDir HAIKU_TOP src tests add-ons kernel drivers ;
|
||||||
|
|
||||||
|
SubInclude HAIKU_TOP src tests add-ons kernel drivers random ;
|
||||||
SubInclude HAIKU_TOP src tests add-ons kernel drivers tty ;
|
SubInclude HAIKU_TOP src tests add-ons kernel drivers tty ;
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
SubDir HAIKU_TOP src tests add-ons kernel drivers random ;
|
||||||
|
|
||||||
|
SimpleTest random_test : random_test.cpp ;
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const char* kRandomDevice = "/dev/urandom";
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
int fd = open(kRandomDevice, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
fprintf(stderr, "Error: Failed to open \"%s\": %s", kRandomDevice,
|
||||||
|
strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t buffer[16];
|
||||||
|
ssize_t bytesRead = read(fd, buffer, sizeof(buffer));
|
||||||
|
if (bytesRead < 0) {
|
||||||
|
fprintf(stderr, "Error: Failed to read from random device: %s",
|
||||||
|
strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Read %d bytes from random device: ", (int)bytesRead);
|
||||||
|
for (int i = 0; i < bytesRead; i++)
|
||||||
|
printf("%02x", buffer[i]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user