diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-18 13:28:10 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-18 13:28:10 -0800 |
commit | 4d2b97a3473c6f7d94fe048558b662011e7d5e56 (patch) | |
tree | 3d7da3d5d310a8d9e0b3409ce370c385a8103632 /tests/runner.py | |
parent | cf5947187de4390ad0440940f323470b37befbc8 (diff) | |
parent | 9ec2ec222eb0fc140556a325025ae8a07d9005a0 (diff) |
Merge pull request #176 from jterrace/mmap_allocate_opts
mmap and allocate optimizations
Diffstat (limited to 'tests/runner.py')
-rw-r--r-- | tests/runner.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index b90eda35..1ea50f79 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -3975,6 +3975,40 @@ def process(filename): } ''' self.do_run(src, 'value:10') + + def test_mmap(self): + src = ''' + #include <stdio.h> + #include <sys/types.h> + #include <sys/mman.h> + #include <assert.h> + + int main(int argc, char *argv[]) { + const int NUM_BYTES = 8 * 1024 * 1024; + const int NUM_INTS = NUM_BYTES / sizeof(int); + + int* map = (int*)mmap(0, NUM_BYTES, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANON, -1, 0); + assert(map != MAP_FAILED); + + int i; + + for (i = 0; i < NUM_INTS; i++) { + map[i] = i; + } + + for (i = 0; i < NUM_INTS; i++) { + assert(map[i] == i); + } + + assert(munmap(map, NUM_BYTES) == 0); + + printf("hello,world"); + return 0; + } + ''' + self.do_run(src, 'hello,world') + self.do_run(src, 'hello,world', force_c=True) def test_cubescript(self): if self.emcc_args is not None and '-O2' in self.emcc_args: |