aboutsummaryrefslogtreecommitdiff
path: root/tests/core/test_memset.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/core/test_memset.c')
-rw-r--r--tests/core/test_memset.c51
1 files changed, 51 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;
+}
+