From 99eb1759eb5a6c39e5410f1c1d907648aa393b55 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 8 Jan 2006 03:24:27 +0000 Subject: [PATCH] Add explanatory comments to vm tests. --- src/tests/vm/child-inherit.c | 4 ++++ src/tests/vm/child-linear.c | 4 ++++ src/tests/vm/child-mm-wrt.c | 5 +++++ src/tests/vm/child-sort.c | 4 ++++ src/tests/vm/mmap-bad-fd.c | 4 ++++ src/tests/vm/mmap-clean.c | 3 +++ src/tests/vm/mmap-close.c | 2 ++ src/tests/vm/mmap-exit.c | 3 +++ src/tests/vm/mmap-inherit.c | 3 +++ src/tests/vm/mmap-misalign.c | 2 ++ src/tests/vm/mmap-null.c | 2 ++ src/tests/vm/mmap-over-code.c | 2 ++ src/tests/vm/mmap-over-data.c | 2 ++ src/tests/vm/mmap-over-stk.c | 2 ++ src/tests/vm/mmap-overlap.c | 2 ++ src/tests/vm/mmap-read.c | 2 ++ src/tests/vm/mmap-remove.c | 3 +++ src/tests/vm/mmap-shuffle.c | 3 +++ src/tests/vm/mmap-twice.c | 3 +++ src/tests/vm/mmap-unmap.c | 3 +++ src/tests/vm/mmap-write.c | 4 ++++ src/tests/vm/mmap-zero.c | 5 +++++ 22 files changed, 67 insertions(+) diff --git a/src/tests/vm/child-inherit.c b/src/tests/vm/child-inherit.c index 4310520..d3186a1 100644 --- a/src/tests/vm/child-inherit.c +++ b/src/tests/vm/child-inherit.c @@ -1,3 +1,7 @@ +/* Child process for mmap-inherit test. + Tries to write to a mapping present in the parent. + The process must be terminated with -1 exit code. */ + #include #include "tests/vm/sample.inc" #include "tests/lib.h" diff --git a/src/tests/vm/child-linear.c b/src/tests/vm/child-linear.c index 4fde22c..7515e4e 100644 --- a/src/tests/vm/child-linear.c +++ b/src/tests/vm/child-linear.c @@ -1,3 +1,7 @@ +/* Child process of page-parallel. + Encrypts 128 kB of zeros, then decrypts it, and ensures that + the zeros are back. */ + #include #include "tests/arc4.h" #include "tests/lib.h" diff --git a/src/tests/vm/child-mm-wrt.c b/src/tests/vm/child-mm-wrt.c index 9372729..8419788 100644 --- a/src/tests/vm/child-mm-wrt.c +++ b/src/tests/vm/child-mm-wrt.c @@ -1,3 +1,8 @@ +/* Child process of mmap-exit. + Mmaps a file and writes to it via the mmap'ing, then exits + without calling munmap. The data in the mapped region must be + written out at program termination. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/child-sort.c b/src/tests/vm/child-sort.c index 638a66d..d755432 100644 --- a/src/tests/vm/child-sort.c +++ b/src/tests/vm/child-sort.c @@ -1,3 +1,7 @@ +/* Reads a 128 kB file and "sorts" the bytes in it, using + counting sort. The sorted data is written back to the same + file in-place. */ + #include #include #include "tests/lib.h" diff --git a/src/tests/vm/mmap-bad-fd.c b/src/tests/vm/mmap-bad-fd.c index 1461996..76a7b50 100644 --- a/src/tests/vm/mmap-bad-fd.c +++ b/src/tests/vm/mmap-bad-fd.c @@ -1,3 +1,7 @@ +/* Tries to mmap an invalid fd, + which must either fail silently or terminate the process with + exit code -1. */ + #include #include "tests/lib.h" #include "tests/main.h" diff --git a/src/tests/vm/mmap-clean.c b/src/tests/vm/mmap-clean.c index c01f69c..ea1dc9c 100644 --- a/src/tests/vm/mmap-clean.c +++ b/src/tests/vm/mmap-clean.c @@ -1,3 +1,6 @@ +/* Verifies that mmap'd regions are only written back on munmap + if the data was actually modified in memory. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-close.c b/src/tests/vm/mmap-close.c index f353304..d016ee3 100644 --- a/src/tests/vm/mmap-close.c +++ b/src/tests/vm/mmap-close.c @@ -1,3 +1,5 @@ +/* Verifies that memory mappings persist after file close. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-exit.c b/src/tests/vm/mmap-exit.c index 202e3c4..7a2278a 100644 --- a/src/tests/vm/mmap-exit.c +++ b/src/tests/vm/mmap-exit.c @@ -1,3 +1,6 @@ +/* Executes child-mm-wrt and verifies that the writes that should + have occurred really did. */ + #include #include "tests/vm/sample.inc" #include "tests/lib.h" diff --git a/src/tests/vm/mmap-inherit.c b/src/tests/vm/mmap-inherit.c index 1c02c24..7fa9607 100644 --- a/src/tests/vm/mmap-inherit.c +++ b/src/tests/vm/mmap-inherit.c @@ -1,3 +1,6 @@ +/* Maps a file into memory and runs child-inherit to verify that + mappings are not inherited. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-misalign.c b/src/tests/vm/mmap-misalign.c index d273468..34141a9 100644 --- a/src/tests/vm/mmap-misalign.c +++ b/src/tests/vm/mmap-misalign.c @@ -1,3 +1,5 @@ +/* Verifies that misaligned memory mappings are disallowed. */ + #include #include "tests/lib.h" #include "tests/main.h" diff --git a/src/tests/vm/mmap-null.c b/src/tests/vm/mmap-null.c index 98d7269..f8ef075 100644 --- a/src/tests/vm/mmap-null.c +++ b/src/tests/vm/mmap-null.c @@ -1,3 +1,5 @@ +/* Verifies that memory mappings at address 0 are disallowed. */ + #include #include "tests/lib.h" #include "tests/main.h" diff --git a/src/tests/vm/mmap-over-code.c b/src/tests/vm/mmap-over-code.c index e64e449..d3619a3 100644 --- a/src/tests/vm/mmap-over-code.c +++ b/src/tests/vm/mmap-over-code.c @@ -1,3 +1,5 @@ +/* Verifies that mapping over the code segment is disallowed. */ + #include #include #include diff --git a/src/tests/vm/mmap-over-data.c b/src/tests/vm/mmap-over-data.c index 0f18a2f..9ea5d49 100644 --- a/src/tests/vm/mmap-over-data.c +++ b/src/tests/vm/mmap-over-data.c @@ -1,3 +1,5 @@ +/* Verifies that mapping over the data segment is disallowed. */ + #include #include #include diff --git a/src/tests/vm/mmap-over-stk.c b/src/tests/vm/mmap-over-stk.c index 4dbf8f3..4e241e8 100644 --- a/src/tests/vm/mmap-over-stk.c +++ b/src/tests/vm/mmap-over-stk.c @@ -1,3 +1,5 @@ +/* Verifies that mapping over the stack segment is disallowed. */ + #include #include #include diff --git a/src/tests/vm/mmap-overlap.c b/src/tests/vm/mmap-overlap.c index 8a7a022..668ae5f 100644 --- a/src/tests/vm/mmap-overlap.c +++ b/src/tests/vm/mmap-overlap.c @@ -1,3 +1,5 @@ +/* Verifies that overlapping memory mappings are disallowed. */ + #include #include "tests/vm/sample.inc" #include "tests/lib.h" diff --git a/src/tests/vm/mmap-read.c b/src/tests/vm/mmap-read.c index e4ca961..c0f23a1 100644 --- a/src/tests/vm/mmap-read.c +++ b/src/tests/vm/mmap-read.c @@ -1,3 +1,5 @@ +/* Uses a memory mapping to read a file. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-remove.c b/src/tests/vm/mmap-remove.c index 0964e47..5f7444d 100644 --- a/src/tests/vm/mmap-remove.c +++ b/src/tests/vm/mmap-remove.c @@ -1,3 +1,6 @@ +/* Deletes and closes file that is mapped into memory + and verifies that it can still be read through the mapping. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-shuffle.c b/src/tests/vm/mmap-shuffle.c index 8ba625f..29921ad 100644 --- a/src/tests/vm/mmap-shuffle.c +++ b/src/tests/vm/mmap-shuffle.c @@ -1,3 +1,6 @@ +/* Creates a 128 kB file and repeatedly shuffles data in it + through a memory mapping. */ + #include #include #include diff --git a/src/tests/vm/mmap-twice.c b/src/tests/vm/mmap-twice.c index 1eca7a4..d277a37 100644 --- a/src/tests/vm/mmap-twice.c +++ b/src/tests/vm/mmap-twice.c @@ -1,3 +1,6 @@ +/* Maps the same file into memory twice and verifies that the + same data is readable in both. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-unmap.c b/src/tests/vm/mmap-unmap.c index 9a6a173..d35a79e 100644 --- a/src/tests/vm/mmap-unmap.c +++ b/src/tests/vm/mmap-unmap.c @@ -1,3 +1,6 @@ +/* Maps and unmaps a file and verifies that the mapped region is + inaccessible afterward. */ + #include #include "tests/vm/sample.inc" #include "tests/lib.h" diff --git a/src/tests/vm/mmap-write.c b/src/tests/vm/mmap-write.c index b231282..46e8043 100644 --- a/src/tests/vm/mmap-write.c +++ b/src/tests/vm/mmap-write.c @@ -1,3 +1,7 @@ +/* Writes to a file through a mapping, and unmaps the file, + then reads the data in the file back using the read system + call to verify. */ + #include #include #include "tests/vm/sample.inc" diff --git a/src/tests/vm/mmap-zero.c b/src/tests/vm/mmap-zero.c index 8b399c4..368b759 100644 --- a/src/tests/vm/mmap-zero.c +++ b/src/tests/vm/mmap-zero.c @@ -1,3 +1,8 @@ +/* Tries to map a zero-length file, which may or may not work but + should not terminate the process or crash. + Then dereferences the address that we tried to map, + and the process must be terminated with -1 exit code. */ + #include #include "tests/lib.h" #include "tests/main.h" -- 2.30.2