patch-2.1.80 linux/arch/arm/lib/testm.c
Next file: linux/arch/arm/lib/uaccess-armo.S
Previous file: linux/arch/arm/lib/system.S
Back to the patch index
Back to the overall index
- Lines: 82
- Date:
Tue Jan 20 16:39:42 1998
- Orig file:
v2.1.79/linux/arch/arm/lib/testm.c
- Orig date:
Wed Dec 31 16:00:00 1969
diff -u --recursive --new-file v2.1.79/linux/arch/arm/lib/testm.c linux/arch/arm/lib/testm.c
@@ -0,0 +1,81 @@
+char buffer[1036];
+char buffer2[1036];
+
+int main ()
+{
+ char *p;
+ int i, o, o2, l;
+
+ printf ("Testing memset\n");
+ for (l = 1; l < 1020; l ++) {
+ for (o = 0; o < 4; o++) {
+ p = buffer + o + 4;
+ for (i = 0; i < l + 12; i++)
+ buffer[i] = 0x55;
+
+ memset (p, 0xaa, l);
+
+ for (i = 0; i < l; i++)
+ if (p[i] != 0xaa)
+ printf ("Error: %X+%d\n", p, i);
+ if (p[-1] != 0x55 || p[-2] != 0x55 || p[-3] != 0x55 || p[-4] != 0x55)
+ printf ("Error before %X\n", p);
+ if (p[l] != 0x55 || p[l+1] != 0x55 || p[l+2] != 0x55 || p[l+3] != 0x55)
+ printf ("Error at end: %p: %02X %02X %02X %02X\n", p+l, p[l], p[l+1], p[l+2], p[l+3]);
+ }
+ }
+
+ printf ("Testing memcpy s > d\n");
+ for (l = 1; l < 1020; l++) {
+ for (o = 0; o < 4; o++) {
+ for (o2 = 0; o2 < 4; o2++) {
+ char *d, *s;
+
+ for (i = 0; i < l + 12; i++)
+ buffer[i] = (i & 0x3f) + 0x40;
+ for (i = 0; i < 1036; i++)
+ buffer2[i] = 0;
+
+ s = buffer + o;
+ d = buffer2 + o2 + 4;
+
+ memcpy (d, s, l);
+
+ for (i = 0; i < l; i++)
+ if (s[i] != d[i])
+ printf ("Error at %X+%d -> %X+%d (%02X != %02X)\n", s, i, d, i, s[i], d[i]);
+ if (d[-1] || d[-2] || d[-3] || d[-4])
+ printf ("Error before %X\n", d);
+ if (d[l] || d[l+1] || d[l+2] || d[l+3])
+ printf ("Error after %X\n", d+l);
+ }
+ }
+ }
+
+ printf ("Testing memcpy s < d\n");
+ for (l = 1; l < 1020; l++) {
+ for (o = 0; o < 4; o++) {
+ for (o2 = 0; o2 < 4; o2++) {
+ char *d, *s;
+
+ for (i = 0; i < l + 12; i++)
+ buffer2[i] = (i & 0x3f) + 0x40;
+ for (i = 0; i < 1036; i++)
+ buffer[i] = 0;
+
+ s = buffer2 + o;
+ d = buffer + o2 + 4;
+
+ memcpy (d, s, l);
+
+ for (i = 0; i < l; i++)
+ if (s[i] != d[i])
+ printf ("Error at %X+%d -> %X+%d (%02X != %02X)\n", s, i, d, i, s[i], d[i]);
+ if (d[-1] || d[-2] || d[-3] || d[-4])
+ printf ("Error before %X\n", d);
+ if (d[l] || d[l+1] || d[l+2] || d[l+3])
+ printf ("Error after %X\n", d+l);
+ }
+ }
+ }
+}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov