improve browser.test_split_memory_large_file

This commit is contained in:
Alon Zakai 2015-09-15 18:02:34 -07:00
Родитель 34d3d05a5f
Коммит e7d5a6863b
2 изменённых файлов: 37 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,34 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <emscripten.h>
#define TOTAL_SIZE (4*1024*1024)
int main() {
unsigned char temp;
printf("open file\n");
FILE *f = fopen("huge.dat", "r");
assert(f);
unsigned i;
for (i = 0; i < TOTAL_SIZE; i++) {
int ret = fseek(f, i, SEEK_SET);
assert(ret == 0);
int num = fread(&temp, 1, 1, f);
assert(num == 1);
unsigned char expected = (i*i)&255;
if (temp != expected) {
printf("%d: see %d != %d was expected :(\n", i, temp, expected);
abort();
}
if ((i & (1024*1024-1)) == 0) printf("%d of %d ..\n", i, TOTAL_SIZE);
}
printf("%d all ok.\n", i);
int result = 1;
REPORT_RESULT();
}

Просмотреть файл

@ -2912,6 +2912,7 @@ window.close = function() {
self.btest('in_flight_memfile_request.c', expected='0' if o < 2 else '1', args=opts) # should happen when there is a mem init file (-O2+)
def test_split_memory_large_file(self):
open('huge.dat', 'w').write('a'*(1024*1024*25)) # larger than a memory chunk
self.btest('browser_test_hello_world.c', expected='0', args=['-s', 'SPLIT_MEMORY=8388608', '-s', 'TOTAL_MEMORY=100000000', '--preload-file', 'huge.dat'])
size = 2*1024*1024
open('huge.dat', 'w').write(''.join([chr((x*x)&255) for x in range(size*2)])) # larger than a memory chunk
self.btest('split_memory_large_file.cpp', expected='1', args=['-s', 'SPLIT_MEMORY=' + str(size), '-s', 'TOTAL_MEMORY=100000000', '-s', 'TOTAL_STACK=10240', '--preload-file', 'huge.dat'])