Commit 75d75a7b authored by Zhangjin Wu's avatar Zhangjin Wu Committed by Paul E. McKenney

selftests/nolibc: support two errnos with EXPECT_SYSER2()

Some functions may be implemented with different syscalls in different
platforms, these syscalls may set different errnos for the same
arguments, let's support such cases.
Suggested-by: default avatarWilly Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/Signed-off-by: default avatarZhangjin Wu <falcon@tinylab.org>
Reviewed-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent f62ec079
......@@ -300,18 +300,24 @@ static int expect_sysne(int expr, int llen, int val)
}
#define EXPECT_SYSER2(cond, expr, expret, experr1, experr2) \
do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0)
#define EXPECT_SYSER(cond, expr, expret, experr) \
do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr(expr, expret, experr, llen); } while (0)
EXPECT_SYSER2(cond, expr, expret, experr, 0)
static int expect_syserr(int expr, int expret, int experr, int llen)
static int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen)
{
int ret = 0;
int _errno = errno;
llen += printf(" = %d %s ", expr, errorname(_errno));
if (expr != expret || _errno != experr) {
if (expr != expret || (_errno != experr1 && _errno != experr2)) {
ret = 1;
llen += printf(" != (%d %s) ", expret, errorname(experr));
if (experr2 == 0)
llen += printf(" != (%d %s) ", expret, errorname(experr1));
else
llen += printf(" != (%d %s %s) ", expret, errorname(experr1), errorname(experr2));
llen += pad_spc(llen, 64, "[FAIL]\n");
} else {
llen += pad_spc(llen, 64, " [OK]\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment