diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-06 12:50:18 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-06 18:41:19 -0500 |
commit | c06ff614145248c7b45dd7cec2d1fac49de81b90 (patch) | |
tree | 7ddefac602c6b531dd0a4ac12b937a516c76349d | |
parent | 51d39aaa3dda0a7f433fa38c365f86011b5fe84c (diff) |
add memset test
-rw-r--r-- | tests/core/test_memset.c | 51 | ||||
-rw-r--r-- | tests/core/test_memset.out | 81 | ||||
-rw-r--r-- | tests/test_core.py | 6 |
3 files changed, 138 insertions, 0 deletions
diff --git a/tests/core/test_memset.c b/tests/core/test_memset.c new file mode 100644 index 00000000..747765f2 --- /dev/null +++ b/tests/core/test_memset.c @@ -0,0 +1,51 @@ +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#define TOTAL 10240 + +#define TEST(size, type) { \ + for (int i = 0; i < TOTAL; i++) { \ + buffer[i] = i*seed; \ + } \ + memset(buffer+size%17, 0xA5, size); \ + int v = 0; \ + for (int i = 0; i < TOTAL; i++) { \ + v += buffer[i]; \ + } \ + printf("final %d:%d\n", size, v); \ +} + +int main() { + #define RUN(type) \ + { \ + type buffer[TOTAL]; \ + volatile int seed = 123; \ + TEST(1, type); \ + TEST(2, type); \ + TEST(3, type); \ + TEST(4, type); \ + TEST(5, type); \ + TEST(6, type); \ + TEST(7, type); \ + TEST(8, type); \ + TEST(9, type); \ + TEST(10, type); \ + TEST(16, type); \ + TEST(32, type); \ + TEST(64, type); \ + TEST(128, type); \ + TEST(256, type); \ + TEST(512, type); \ + TEST(1024, type); \ + for (int x = 10; x < 100; x += 10) { TEST(x, type) }; \ + } + printf("8\n"); + RUN(unsigned char); + printf("16\n"); + RUN(unsigned short); + printf("32\n"); + RUN(unsigned); + return 1; +} + diff --git a/tests/core/test_memset.out b/tests/core/test_memset.out new file mode 100644 index 00000000..7517e6ba --- /dev/null +++ b/tests/core/test_memset.out @@ -0,0 +1,81 @@ +8 +final 1:1305642 +final 2:1305571 +final 3:1305643 +final 4:1305602 +final 5:1305704 +final 6:1305693 +final 7:1305825 +final 8:1305844 +final 9:1306006 +final 10:1306055 +final 16:1306280 +final 32:1307056 +final 64:1308384 +final 128:1310400 +final 256:1315200 +final 512:1324800 +final 1024:1344000 +final 10:1306055 +final 20:1306310 +final 30:1306867 +final 40:1307060 +final 50:1307463 +final 60:1307850 +final 70:1308037 +final 80:1308424 +final 90:1308805 +16 +final 1:332555306 +final 2:332597423 +final 3:332597229 +final 4:332638967 +final 5:332638793 +final 6:332679896 +final 7:332679486 +final 8:332720210 +final 9:332719820 +final 10:332759909 +final 16:332875316 +final 32:333189464 +final 64:333800048 +final 128:334950368 +final 256:336967616 +final 512:339333248 +final 1024:337924352 +final 10:332759909 +final 20:332970089 +final 30:333154439 +final 40:333365234 +final 50:333529289 +final 60:333740699 +final 70:333957644 +final 80:334096484 +final 90:334314044 +32 +final 1:-2141821910 +final 2:-2141779793 +final 3:-2130966476 +final 4:637274041 +final 5:637273857 +final 6:637315339 +final 7:648128533 +final 8:-878598369 +final 9:-878598523 +final 10:-878557932 +final 16:384620786 +final 32:-1383904756 +final 64:-625991496 +final 128:889823216 +final 256:-373561888 +final 512:1394178624 +final 1024:633133696 +final 10:-878557932 +final 20:-1131244490 +final 30:132010428 +final 40:-120673793 +final 50:1142572023 +final 60:889890139 +final 70:-2141802805 +final 80:1900447306 +final 90:-1131244285 diff --git a/tests/test_core.py b/tests/test_core.py index 55aeb697..47360fd6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2594,6 +2594,12 @@ The current type of b is: 9 src, output = (test_path + s for s in ('.c', '.out')) self.do_run_from_file(src, output) + def test_memset(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('need ta2') + test_path = path_from_root('tests', 'core', 'test_memset') + src, output = (test_path + s for s in ('.c', '.out')) + self.do_run_from_file(src, output) + def test_getopt(self): if self.emcc_args is None: return self.skip('needs emcc for libc') |