Chromium Code Reviews| Index: tests/dynamic_code_loading/dynamic_load_test.c |
| =================================================================== |
| --- tests/dynamic_code_loading/dynamic_load_test.c (revision 3655) |
| +++ tests/dynamic_code_loading/dynamic_load_test.c (working copy) |
| @@ -17,6 +17,12 @@ |
| #include "native_client/tests/dynamic_code_loading/templates.h" |
| #include "native_client/tests/inbrowser_test_runner/test_runner.h" |
| +#if defined(__x86_64__) |
| +#define BUF_SIZE 64 |
|
bsy
2010/11/11 21:27:21
why should code buffers be 64 bytes on x86-64 cpus
petr
2010/11/12 18:11:06
on X86-64 we operate with code samples that do not
|
| +#else |
| +#define BUF_SIZE 32 |
| +#endif |
| + |
| #define NACL_BUNDLE_SIZE 32 |
| /* |
| * TODO(bsy): get this value from the toolchain. Get the toolchain |
| @@ -94,7 +100,7 @@ |
| const char *fragment_end) { |
| int fragment_size = fragment_end - fragment_start; |
| assert(dest_size % 32 == 0); |
|
bsy
2010/11/11 21:27:21
is this 32 (always) correct? should it be 16 or 3
petr
2010/11/12 18:11:06
Done.
|
| - assert(fragment_size < dest_size); |
| + assert(fragment_size <= dest_size); |
| fill_nops(dest, dest_size); |
| memcpy(dest, fragment_start, fragment_size); |
| } |
| @@ -102,7 +108,7 @@ |
| /* Check that we can load and run code. */ |
| void test_loading_code() { |
| void *load_area = allocate_code_space(1); |
| - uint8_t buf[32]; |
| + uint8_t buf[BUF_SIZE]; |
| int rc; |
| int (*func)(); |
| @@ -124,7 +130,7 @@ |
| Check that we can load to non-page-aligned addresses. */ |
| void test_loading_code_non_page_aligned() { |
| char *load_area = allocate_code_space(1); |
| - uint8_t buf[32]; |
| + uint8_t buf[BUF_SIZE]; |
| int rc; |
| copy_and_pad_fragment(buf, sizeof(buf), &template_func, &template_func_end); |
| @@ -133,7 +139,7 @@ |
| assert(rc == 0); |
| assert(memcmp(load_area, buf, sizeof(buf)) == 0); |
| - load_area += 32; |
| + load_area += sizeof(buf); |
| rc = nacl_load_code(load_area, buf, sizeof(buf)); |
| assert(rc == 0); |
| assert(memcmp(load_area, buf, sizeof(buf)) == 0); |
| @@ -186,7 +192,7 @@ |
| void test_fail_on_validation_error() { |
| void *load_area = allocate_code_space(1); |
| - uint8_t buf[32]; |
| + uint8_t buf[BUF_SIZE]; |
| int rc; |
| copy_and_pad_fragment(buf, sizeof(buf), &invalid_code, &invalid_code_end); |
| @@ -246,7 +252,7 @@ |
| void test_fail_on_overwrite() { |
| void *load_area = allocate_code_space(1); |
| - uint8_t buf[32]; |
| + uint8_t buf[BUF_SIZE]; |
| int rc; |
| copy_and_pad_fragment(buf, sizeof(buf), &template_func, &template_func_end); |