-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·61 lines (46 loc) · 1.75 KB
/
test.sh
File metadata and controls
executable file
·61 lines (46 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Shell script for comparing frandom with urandom
# May be executed as a non-root user
if [ ! -e /dev/frandom ]; then
echo "It looks like you need to insmod frandom. (/dev/frandom file missing)";
exit 1;
fi
if [ ! -e /dev/urandom ]; then
echo "/dev/urandom does not exist. Weird...";
exit 1;
fi
# Now verify that our generators work:
if ! head --bytes=1k /dev/frandom > /dev/null; then
echo -e "\n/dev/frandom doesn't work! See the INSTALL file.";
exit 1;
fi
if ! head --bytes=1k /dev/urandom > /dev/null; then
echo -e "\n/dev/urandom doesn't work! (This is weird...)";
exit 1;
fi
# We don't want the test to take too long on slow computers, and it's
# meaningless if it goes to fast. Solution: Use bogomips as an
# indication of how fast or slow the computer is.
bogomips=`grep -i bogomips /proc/cpuinfo`;
bogomips=${bogomips##*:}; # Remove everything before ":"
bogomips=${bogomips%%.*}; # Remove anything after "."
urandomkbytes=$((bogomips*5));
frandomkbytes=$((bogomips*50));
failed=0
echo "Running tests... This may take up to a minute"
(
echo -e "Results of frandom vs. urandom test:"
echo -e "====================================\n"
date
echo -e "\nurandom created $urandomkbytes kBytes of data"
echo -e "frandom created $frandomkbytes kBytes of data\n"
echo -e "Note that frandom did 10 times as much data!\n"
echo -e "head --bytes=${frandomkbytes}k /dev/frandom > /dev/null"
time head --bytes=${frandomkbytes}k /dev/frandom > /dev/null
echo -e "\nhead --bytes=${urandomkbytes}k /dev/urandom > /dev/null"
time head --bytes=${urandomkbytes}k /dev/urandom > /dev/null
echo -e "\nPlatform info:";
uname -s -r
cat /proc/cpuinfo
) > frandom-res.txt 2>&1
echo -e "Test finished successfully. See frandom-res.txt for results";