Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / vm / child-linear.c
1 #include <string.h>
2 #include "tests/arc4.h"
3 #include "tests/lib.h"
4 #include "tests/main.h"
5
6 const char *test_name = "child-linear";
7
8 #define SIZE (128 * 1024)
9 static char buf[SIZE];
10
11 int
12 main (int argc, char *argv[])
13 {
14   const char *key = argv[argc - 1];
15   struct arc4 arc4;
16   size_t i;
17
18   /* Encrypt zeros. */
19   arc4_init (&arc4, key, strlen (key));
20   arc4_crypt (&arc4, buf, SIZE);
21
22   /* Decrypt back to zeros. */
23   arc4_init (&arc4, key, strlen (key));
24   arc4_crypt (&arc4, buf, SIZE);
25
26   /* Check that it's all zeros. */
27   for (i = 0; i < SIZE; i++)
28     if (buf[i] != '\0')
29       fail ("byte %zu != 0", i);
30
31   return 0x42;
32 }