diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/vm/child-linear.c | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/vm/child-linear.c')
| -rw-r--r-- | tests/vm/child-linear.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/vm/child-linear.c b/tests/vm/child-linear.c new file mode 100644 index 0000000..eca3e3f --- /dev/null +++ b/tests/vm/child-linear.c | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* Child process of page-parallel. | ||
| 2 | Encrypts 1 MB of zeros, then decrypts it, and ensures that | ||
| 3 | the zeros are back. */ | ||
| 4 | |||
| 5 | #include <string.h> | ||
| 6 | #include "tests/arc4.h" | ||
| 7 | #include "tests/lib.h" | ||
| 8 | #include "tests/main.h" | ||
| 9 | |||
| 10 | const char *test_name = "child-linear"; | ||
| 11 | |||
| 12 | #define SIZE (1024 * 1024) | ||
| 13 | static char buf[SIZE]; | ||
| 14 | |||
| 15 | int | ||
| 16 | main (int argc, char *argv[]) | ||
| 17 | { | ||
| 18 | const char *key = argv[argc - 1]; | ||
| 19 | struct arc4 arc4; | ||
| 20 | size_t i; | ||
| 21 | |||
| 22 | /* Encrypt zeros. */ | ||
| 23 | arc4_init (&arc4, key, strlen (key)); | ||
| 24 | arc4_crypt (&arc4, buf, SIZE); | ||
| 25 | |||
| 26 | /* Decrypt back to zeros. */ | ||
| 27 | arc4_init (&arc4, key, strlen (key)); | ||
| 28 | arc4_crypt (&arc4, buf, SIZE); | ||
| 29 | |||
| 30 | /* Check that it's all zeros. */ | ||
| 31 | for (i = 0; i < SIZE; i++) | ||
| 32 | if (buf[i] != '\0') | ||
| 33 | fail ("byte %zu != 0", i); | ||
| 34 | |||
| 35 | return 0x42; | ||
| 36 | } | ||
