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