From cb9347b6541e808bca7205a6274a52c5019485dc Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 21 Apr 2022 20:10:07 -0700 Subject: [PATCH] check for expected divmnu failures --- openpower/sv/biginteger/divmnu64.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/openpower/sv/biginteger/divmnu64.c b/openpower/sv/biginteger/divmnu64.c index 99aa20c56..57d007798 100644 --- a/openpower/sv/biginteger/divmnu64.c +++ b/openpower/sv/biginteger/divmnu64.c @@ -385,11 +385,12 @@ int main() { int m, n; uint32_t u[10], v[10], cq[10], cr[10]; + bool error; } test[] = { // clang-format off - {.m=1, .n=1, .u={3}, .v={0}, .cq={1}, .cr={1}}, // Error, divide by 0. - {.m=1, .n=2, .u={7}, .v={1,3}, .cq={0}, .cr={7,0}}, // Error, n > m. - {.m=2, .n=2, .u={0,0}, .v={1,0}, .cq={0}, .cr={0,0}}, // Error, incorrect remainder cr. + {.m=1, .n=1, .u={3}, .v={0}, .cq={1}, .cr={1}, .error=true}, // Error, divide by 0. + {.m=1, .n=2, .u={7}, .v={1,3}, .cq={0}, .cr={7,0}, .error=true}, // Error, n > m. + {.m=2, .n=2, .u={0,0}, .v={1,0}, .cq={0}, .cr={0,0}, .error=true}, // Error, incorrect remainder cr. {.m=1, .n=1, .u={3}, .v={2}, .cq={1}, .cr={1}}, {.m=1, .n=1, .u={3}, .v={3}, .cq={1}, .cr={0}}, {.m=1, .n=1, .u={3}, .v={4}, .cq={0}, .cr={3}}, @@ -437,16 +438,23 @@ int main() uint32_t *cr = test[i].cr; int f = divmnu(q, r, u, v, m, n); - if (f) + if (f && !test[i].error) { - dumpit("Error return code for dividend u =", m, u); - dumpit(" divisor v =", n, v); + dumpit("Unexpected error return code for dividend u =", m, u); + dumpit(" divisor v =", n, v); errors = errors + 1; } - else + else if (!f && test[i].error) + { + dumpit("Unexpected success return code for dividend u =", m, u); + dumpit(" divisor v =", n, v); + errors = errors + 1; + } + + if (!f) check(q, r, u, v, m, n, cq, cr); } - printf("%d errors out of %d cases; there should be 3.\n", errors, ncases); + printf("%d test failures out of %d cases.\n", errors, ncases); return 0; } -- 2.30.2