aboutsummaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2020-05-22 14:36:54 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-05-22 14:39:21 +0100
commite3b6fdf148bd001e7ada875361f3851e6460a3f9 (patch)
tree661e87cae78e7ea89f51c65ff7bcbb7c87bbeb57 /string
parent76203e7e1b19cc507484e10b9c0fae019d248edd (diff)
downloadarm-optimized-routines-e3b6fdf148bd001e7ada875361f3851e6460a3f9.tar.gz
string: Cleanup stpcpy test
Cleanup stpcpy test and improve test coverage.
Diffstat (limited to 'string')
-rw-r--r--string/test/stpcpy.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/string/test/stpcpy.c b/string/test/stpcpy.c
index de51ad8..e13b42c 100644
--- a/string/test/stpcpy.c
+++ b/string/test/stpcpy.c
@@ -34,16 +34,16 @@ static const struct fun
};
#undef F
-#define A 32
-#define LEN 250000
-static char dbuf[LEN + 2 * A + 1];
-static char sbuf[LEN + 2 * A + 1];
-static char wbuf[LEN + 2 * A + 1];
+#define ALIGN 32
+#define LEN 512
+static char dbuf[LEN + 3 * ALIGN];
+static char sbuf[LEN + 3 * ALIGN];
+static char wbuf[LEN + 3 * ALIGN];
static void *
alignup (void *p)
{
- return (void *) (((uintptr_t) p + A - 1) & -A);
+ return (void *) (((uintptr_t) p + ALIGN - 1) & -ALIGN);
}
static void
@@ -60,49 +60,50 @@ test (const struct fun *fun, int dalign, int salign, int len)
if (err_count >= ERR_LIMIT)
return;
- if (len > LEN || dalign >= A || salign >= A)
+ if (len > LEN || dalign >= ALIGN || salign >= ALIGN)
abort ();
- for (i = 0; i < len + A; i++)
+ for (i = 0; i < len + ALIGN; i++)
{
src[i] = '?';
want[i] = dst[i] = '*';
}
+ for (int i = 0; src + i < s; i++)
+ src[i] = 0;
+ for (int i = 1; i <= ALIGN; i++)
+ s[len + i] = (len + salign) & 1 ? 1 : 0;
for (i = 0; i < len; i++)
- s[i] = w[i] = 'a' + i % 23;
+ s[i] = w[i] = 'a' + (i & 31);
s[len] = w[len] = '\0';
p = fun->fun (d, s);
if (p != d + len)
- ERR ("%s(%p,..) returned %p\n", fun->name, d, p);
- for (i = 0; i < len + A; i++)
+ ERR ("%s (%p,..) returned %p expected %p\n", fun->name, d, p, d + len);
+
+ for (i = 0; i < len + ALIGN; i++)
{
if (dst[i] != want[i])
{
- ERR ("%s(align %d, align %d, %d) failed\n", fun->name, dalign, salign,
- len);
- quoteat ("got", dst, len + A, i);
- quoteat ("want", want, len + A, i);
+ ERR ("%s (align %d, align %d, %d) failed\n",
+ fun->name, dalign, salign, len);
+ quoteat ("got", dst, len + ALIGN, i);
+ quoteat ("want", want, len + ALIGN, i);
break;
}
}
}
int
-main ()
+main (void)
{
int r = 0;
for (int i = 0; funtab[i].name; i++)
{
err_count = 0;
- for (int d = 0; d < A; d++)
- for (int s = 0; s < A; s++)
- {
- int n;
- for (n = 0; n < 100; n++)
- test (funtab + i, d, s, n);
- for (; n < LEN; n *= 2)
- test (funtab + i, d, s, n);
- }
+ for (int d = 0; d < ALIGN; d++)
+ for (int s = 0; s < ALIGN; s++)
+ for (int n = 0; n < LEN; n++)
+ test (funtab + i, d, s, n);
+
printf ("%s %s\n", err_count ? "FAIL" : "PASS", funtab[i].name);
if (err_count)
r = -1;