selftests/nolibc: add EXPECT_PTRGE, EXPECT_PTRGT, EXPECT_PTRLE, EXPECT_PTRLT

4 new pointer compare macros are added, they are similar to the integer
compare macros.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
This commit is contained in:
Zhangjin Wu 2023-07-16 02:33:26 +08:00 committed by Willy Tarreau
parent c48d8af2fa
commit fd3a9efde8

View File

@ -410,6 +410,56 @@ static int expect_ptrne(const void *expr, int llen, const void *cmp)
return ret;
}
#define EXPECT_PTRGE(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrge(expr, llen, cmp); } while (0)
static int expect_ptrge(const void *expr, int llen, const void *cmp)
{
int ret = !(expr >= cmp);
llen += printf(" = <%p> ", expr);
result(llen, ret ? FAIL : OK);
return ret;
}
#define EXPECT_PTRGT(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrgt(expr, llen, cmp); } while (0)
static int expect_ptrgt(const void *expr, int llen, const void *cmp)
{
int ret = !(expr > cmp);
llen += printf(" = <%p> ", expr);
result(llen, ret ? FAIL : OK);
return ret;
}
#define EXPECT_PTRLE(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrle(expr, llen, cmp); } while (0)
static int expect_ptrle(const void *expr, int llen, const void *cmp)
{
int ret = !(expr <= cmp);
llen += printf(" = <%p> ", expr);
result(llen, ret ? FAIL : OK);
return ret;
}
#define EXPECT_PTRLT(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrlt(expr, llen, cmp); } while (0)
static int expect_ptrlt(const void *expr, int llen, const void *cmp)
{
int ret = !(expr < cmp);
llen += printf(" = <%p> ", expr);
result(llen, ret ? FAIL : OK);
return ret;
}
#define EXPECT_PTRER2(cond, expr, expret, experr1, experr2) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrerr2(expr, expret, experr1, experr2, llen); } while (0)