summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/vm/page-linear.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
committermanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
commitb5f0874cd96ee2a62aabc645b9626c2749cb6a01 (patch)
tree1262e4bbe0634de6650be130c36e0538240f4cbf /pintos-progos/tests/vm/page-linear.c
downloadprogos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.gz
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.bz2
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.zip
initial pintos checkin
Diffstat (limited to 'pintos-progos/tests/vm/page-linear.c')
-rw-r--r--pintos-progos/tests/vm/page-linear.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/pintos-progos/tests/vm/page-linear.c b/pintos-progos/tests/vm/page-linear.c
new file mode 100644
index 0000000..652a47b
--- /dev/null
+++ b/pintos-progos/tests/vm/page-linear.c
@@ -0,0 +1,44 @@
1/* Encrypts, then decrypts, 2 MB of memory and verifies that the
2 values are as they should be. */
3
4#include <string.h>
5#include "tests/arc4.h"
6#include "tests/lib.h"
7#include "tests/main.h"
8
9#define SIZE (2 * 1024 * 1024)
10
11static char buf[SIZE];
12
13void
14test_main (void)
15{
16 struct arc4 arc4;
17 size_t i;
18
19 /* Initialize to 0x5a. */
20 msg ("initialize");
21 memset (buf, 0x5a, sizeof buf);
22
23 /* Check that it's all 0x5a. */
24 msg ("read pass");
25 for (i = 0; i < SIZE; i++)
26 if (buf[i] != 0x5a)
27 fail ("byte %zu != 0x5a", i);
28
29 /* Encrypt zeros. */
30 msg ("read/modify/write pass one");
31 arc4_init (&arc4, "foobar", 6);
32 arc4_crypt (&arc4, buf, SIZE);
33
34 /* Decrypt back to zeros. */
35 msg ("read/modify/write pass two");
36 arc4_init (&arc4, "foobar", 6);
37 arc4_crypt (&arc4, buf, SIZE);
38
39 /* Check that it's all 0x5a. */
40 msg ("read pass");
41 for (i = 0; i < SIZE; i++)
42 if (buf[i] != 0x5a)
43 fail ("byte %zu != 0x5a", i);
44}