Commit b184a261 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Willy Tarreau

selftests/nolibc: simplify status printing

pad_spc() is only ever used to print the status message of testcases.
The line size is always constant, the return value is never used and the
format string is never used as such.

Remove all the unneeded logic and simplify the API and its users.
Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 3097783e
...@@ -127,17 +127,25 @@ static void putcharn(char c, size_t n) ...@@ -127,17 +127,25 @@ static void putcharn(char c, size_t n)
fputs(buf, stdout); fputs(buf, stdout);
} }
static int pad_spc(int llen, int cnt, const char *fmt, ...) enum RESULT {
OK,
FAIL,
SKIPPED,
};
static void result(int llen, enum RESULT r)
{ {
va_list args; const char *msg;
int ret;
putcharn(' ', cnt - llen); if (r == OK)
msg = " [OK]";
else if (r == SKIPPED)
msg = "[SKIPPED]";
else
msg = "[FAIL]";
va_start(args, fmt); putcharn(' ', 64 - llen);
ret = vfprintf(stdout, fmt, args); puts(msg);
va_end(args);
return ret < 0 ? ret : ret + cnt - llen;
} }
/* The tests below are intended to be used by the macroes, which evaluate /* The tests below are intended to be used by the macroes, which evaluate
...@@ -147,111 +155,111 @@ static int pad_spc(int llen, int cnt, const char *fmt, ...) ...@@ -147,111 +155,111 @@ static int pad_spc(int llen, int cnt, const char *fmt, ...)
*/ */
#define EXPECT_ZR(cond, expr) \ #define EXPECT_ZR(cond, expr) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_zr(expr, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_zr(expr, llen); } while (0)
static int expect_zr(int expr, int llen) static int expect_zr(int expr, int llen)
{ {
int ret = !(expr == 0); int ret = !(expr == 0);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_NZ(cond, expr, val) \ #define EXPECT_NZ(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_nz(expr, llen; } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_nz(expr, llen; } while (0)
static int expect_nz(int expr, int llen) static int expect_nz(int expr, int llen)
{ {
int ret = !(expr != 0); int ret = !(expr != 0);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_EQ(cond, expr, val) \ #define EXPECT_EQ(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_eq(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_eq(expr, llen, val); } while (0)
static int expect_eq(uint64_t expr, int llen, uint64_t val) static int expect_eq(uint64_t expr, int llen, uint64_t val)
{ {
int ret = !(expr == val); int ret = !(expr == val);
llen += printf(" = %lld ", (long long)expr); llen += printf(" = %lld ", (long long)expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_NE(cond, expr, val) \ #define EXPECT_NE(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ne(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ne(expr, llen, val); } while (0)
static int expect_ne(int expr, int llen, int val) static int expect_ne(int expr, int llen, int val)
{ {
int ret = !(expr != val); int ret = !(expr != val);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_GE(cond, expr, val) \ #define EXPECT_GE(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ge(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ge(expr, llen, val); } while (0)
static int expect_ge(int expr, int llen, int val) static int expect_ge(int expr, int llen, int val)
{ {
int ret = !(expr >= val); int ret = !(expr >= val);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_GT(cond, expr, val) \ #define EXPECT_GT(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_gt(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_gt(expr, llen, val); } while (0)
static int expect_gt(int expr, int llen, int val) static int expect_gt(int expr, int llen, int val)
{ {
int ret = !(expr > val); int ret = !(expr > val);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_LE(cond, expr, val) \ #define EXPECT_LE(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_le(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_le(expr, llen, val); } while (0)
static int expect_le(int expr, int llen, int val) static int expect_le(int expr, int llen, int val)
{ {
int ret = !(expr <= val); int ret = !(expr <= val);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_LT(cond, expr, val) \ #define EXPECT_LT(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_lt(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_lt(expr, llen, val); } while (0)
static int expect_lt(int expr, int llen, int val) static int expect_lt(int expr, int llen, int val)
{ {
int ret = !(expr < val); int ret = !(expr < val);
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
#define EXPECT_SYSZR(cond, expr) \ #define EXPECT_SYSZR(cond, expr) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syszr(expr, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syszr(expr, llen); } while (0)
static int expect_syszr(int expr, int llen) static int expect_syszr(int expr, int llen)
{ {
...@@ -260,17 +268,17 @@ static int expect_syszr(int expr, int llen) ...@@ -260,17 +268,17 @@ static int expect_syszr(int expr, int llen)
if (expr) { if (expr) {
ret = 1; ret = 1;
llen += printf(" = %d %s ", expr, errorname(errno)); llen += printf(" = %d %s ", expr, errorname(errno));
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_SYSEQ(cond, expr, val) \ #define EXPECT_SYSEQ(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syseq(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syseq(expr, llen, val); } while (0)
static int expect_syseq(int expr, int llen, int val) static int expect_syseq(int expr, int llen, int val)
{ {
...@@ -279,17 +287,17 @@ static int expect_syseq(int expr, int llen, int val) ...@@ -279,17 +287,17 @@ static int expect_syseq(int expr, int llen, int val)
if (expr != val) { if (expr != val) {
ret = 1; ret = 1;
llen += printf(" = %d %s ", expr, errorname(errno)); llen += printf(" = %d %s ", expr, errorname(errno));
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_SYSNE(cond, expr, val) \ #define EXPECT_SYSNE(cond, expr, val) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_sysne(expr, llen, val); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_sysne(expr, llen, val); } while (0)
static int expect_sysne(int expr, int llen, int val) static int expect_sysne(int expr, int llen, int val)
{ {
...@@ -298,17 +306,17 @@ static int expect_sysne(int expr, int llen, int val) ...@@ -298,17 +306,17 @@ static int expect_sysne(int expr, int llen, int val)
if (expr == val) { if (expr == val) {
ret = 1; ret = 1;
llen += printf(" = %d %s ", expr, errorname(errno)); llen += printf(" = %d %s ", expr, errorname(errno));
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += printf(" = %d ", expr); llen += printf(" = %d ", expr);
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_SYSER2(cond, expr, expret, experr1, experr2) \ #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) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0)
#define EXPECT_SYSER(cond, expr, expret, experr) \ #define EXPECT_SYSER(cond, expr, expret, experr) \
EXPECT_SYSER2(cond, expr, expret, experr, 0) EXPECT_SYSER2(cond, expr, expret, experr, 0)
...@@ -325,16 +333,16 @@ static int expect_syserr2(int expr, int expret, int experr1, int experr2, int ll ...@@ -325,16 +333,16 @@ static int expect_syserr2(int expr, int expret, int experr1, int experr2, int ll
llen += printf(" != (%d %s) ", expret, errorname(experr1)); llen += printf(" != (%d %s) ", expret, errorname(experr1));
else else
llen += printf(" != (%d %s %s) ", expret, errorname(experr1), errorname(experr2)); llen += printf(" != (%d %s %s) ", expret, errorname(experr1), errorname(experr2));
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_PTRZR(cond, expr) \ #define EXPECT_PTRZR(cond, expr) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ptrzr(expr, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrzr(expr, llen); } while (0)
static int expect_ptrzr(const void *expr, int llen) static int expect_ptrzr(const void *expr, int llen)
{ {
...@@ -343,16 +351,16 @@ static int expect_ptrzr(const void *expr, int llen) ...@@ -343,16 +351,16 @@ static int expect_ptrzr(const void *expr, int llen)
llen += printf(" = <%p> ", expr); llen += printf(" = <%p> ", expr);
if (expr) { if (expr) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_PTRNZ(cond, expr) \ #define EXPECT_PTRNZ(cond, expr) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ptrnz(expr, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrnz(expr, llen); } while (0)
static int expect_ptrnz(const void *expr, int llen) static int expect_ptrnz(const void *expr, int llen)
{ {
...@@ -361,15 +369,15 @@ static int expect_ptrnz(const void *expr, int llen) ...@@ -361,15 +369,15 @@ static int expect_ptrnz(const void *expr, int llen)
llen += printf(" = <%p> ", expr); llen += printf(" = <%p> ", expr);
if (!expr) { if (!expr) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_PTREQ(cond, expr, cmp) \ #define EXPECT_PTREQ(cond, expr, cmp) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ptreq(expr, llen, cmp); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptreq(expr, llen, cmp); } while (0)
static int expect_ptreq(const void *expr, int llen, const void *cmp) static int expect_ptreq(const void *expr, int llen, const void *cmp)
{ {
...@@ -378,15 +386,15 @@ static int expect_ptreq(const void *expr, int llen, const void *cmp) ...@@ -378,15 +386,15 @@ static int expect_ptreq(const void *expr, int llen, const void *cmp)
llen += printf(" = <%p> ", expr); llen += printf(" = <%p> ", expr);
if (expr != cmp) { if (expr != cmp) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_PTRNE(cond, expr, cmp) \ #define EXPECT_PTRNE(cond, expr, cmp) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ptrne(expr, llen, cmp); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrne(expr, llen, cmp); } while (0)
static int expect_ptrne(const void *expr, int llen, const void *cmp) static int expect_ptrne(const void *expr, int llen, const void *cmp)
{ {
...@@ -395,15 +403,15 @@ static int expect_ptrne(const void *expr, int llen, const void *cmp) ...@@ -395,15 +403,15 @@ static int expect_ptrne(const void *expr, int llen, const void *cmp)
llen += printf(" = <%p> ", expr); llen += printf(" = <%p> ", expr);
if (expr == cmp) { if (expr == cmp) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_PTRER2(cond, expr, expret, experr1, experr2) \ #define EXPECT_PTRER2(cond, expr, expret, experr1, experr2) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_ptrerr2(expr, expret, experr1, experr2, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrerr2(expr, expret, experr1, experr2, llen); } while (0)
#define EXPECT_PTRER(cond, expr, expret, experr) \ #define EXPECT_PTRER(cond, expr, expret, experr) \
EXPECT_PTRER2(cond, expr, expret, experr, 0) EXPECT_PTRER2(cond, expr, expret, experr, 0)
...@@ -420,15 +428,15 @@ static int expect_ptrerr2(const void *expr, const void *expret, int experr1, int ...@@ -420,15 +428,15 @@ static int expect_ptrerr2(const void *expr, const void *expret, int experr1, int
llen += printf(" != (<%p> %s) ", expret, errorname(experr1)); llen += printf(" != (<%p> %s) ", expret, errorname(experr1));
else else
llen += printf(" != (<%p> %s %s) ", expret, errorname(experr1), errorname(experr2)); llen += printf(" != (<%p> %s %s) ", expret, errorname(experr1), errorname(experr2));
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_STRZR(cond, expr) \ #define EXPECT_STRZR(cond, expr) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_strzr(expr, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strzr(expr, llen); } while (0)
static int expect_strzr(const char *expr, int llen) static int expect_strzr(const char *expr, int llen)
{ {
...@@ -437,16 +445,16 @@ static int expect_strzr(const char *expr, int llen) ...@@ -437,16 +445,16 @@ static int expect_strzr(const char *expr, int llen)
llen += printf(" = <%s> ", expr); llen += printf(" = <%s> ", expr);
if (expr) { if (expr) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_STRNZ(cond, expr) \ #define EXPECT_STRNZ(cond, expr) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_strnz(expr, llen); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strnz(expr, llen); } while (0)
static int expect_strnz(const char *expr, int llen) static int expect_strnz(const char *expr, int llen)
{ {
...@@ -455,16 +463,16 @@ static int expect_strnz(const char *expr, int llen) ...@@ -455,16 +463,16 @@ static int expect_strnz(const char *expr, int llen)
llen += printf(" = <%s> ", expr); llen += printf(" = <%s> ", expr);
if (!expr) { if (!expr) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_STREQ(cond, expr, cmp) \ #define EXPECT_STREQ(cond, expr, cmp) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_streq(expr, llen, cmp); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_streq(expr, llen, cmp); } while (0)
static int expect_streq(const char *expr, int llen, const char *cmp) static int expect_streq(const char *expr, int llen, const char *cmp)
{ {
...@@ -473,16 +481,16 @@ static int expect_streq(const char *expr, int llen, const char *cmp) ...@@ -473,16 +481,16 @@ static int expect_streq(const char *expr, int llen, const char *cmp)
llen += printf(" = <%s> ", expr); llen += printf(" = <%s> ", expr);
if (strcmp(expr, cmp) != 0) { if (strcmp(expr, cmp) != 0) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
#define EXPECT_STRNE(cond, expr, cmp) \ #define EXPECT_STRNE(cond, expr, cmp) \
do { if (!(cond)) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_strne(expr, llen, cmp); } while (0) do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strne(expr, llen, cmp); } while (0)
static int expect_strne(const char *expr, int llen, const char *cmp) static int expect_strne(const char *expr, int llen, const char *cmp)
{ {
...@@ -491,9 +499,9 @@ static int expect_strne(const char *expr, int llen, const char *cmp) ...@@ -491,9 +499,9 @@ static int expect_strne(const char *expr, int llen, const char *cmp)
llen += printf(" = <%s> ", expr); llen += printf(" = <%s> ", expr);
if (strcmp(expr, cmp) == 0) { if (strcmp(expr, cmp) == 0) {
ret = 1; ret = 1;
llen += pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
} else { } else {
llen += pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
} }
return ret; return ret;
} }
...@@ -880,13 +888,13 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char ...@@ -880,13 +888,13 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char
fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600); fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600);
if (fd == -1) { if (fd == -1) {
pad_spc(llen, 64, "[SKIPPED]\n"); result(llen, SKIPPED);
return 0; return 0;
} }
memfile = fdopen(fd, "w+"); memfile = fdopen(fd, "w+");
if (!memfile) { if (!memfile) {
pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
return 1; return 1;
} }
...@@ -896,7 +904,7 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char ...@@ -896,7 +904,7 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char
if (w != c) { if (w != c) {
llen += printf(" written(%d) != %d", w, (int) c); llen += printf(" written(%d) != %d", w, (int) c);
pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
return 1; return 1;
} }
...@@ -910,14 +918,14 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char ...@@ -910,14 +918,14 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char
if (r != w) { if (r != w) {
llen += printf(" written(%d) != read(%d)", w, r); llen += printf(" written(%d) != read(%d)", w, r);
pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
return 1; return 1;
} }
llen += printf(" \"%s\" = \"%s\"", expected, buf); llen += printf(" \"%s\" = \"%s\"", expected, buf);
ret = strncmp(expected, buf, c); ret = strncmp(expected, buf, c);
pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); result(llen, ret ? FAIL : OK);
return ret; return ret;
} }
...@@ -973,14 +981,14 @@ static int run_protection(int min, int max) ...@@ -973,14 +981,14 @@ static int run_protection(int min, int max)
#if !defined(_NOLIBC_STACKPROTECTOR) #if !defined(_NOLIBC_STACKPROTECTOR)
llen += printf("not supported"); llen += printf("not supported");
pad_spc(llen, 64, "[SKIPPED]\n"); result(llen, SKIPPED);
return 0; return 0;
#endif #endif
#if defined(_NOLIBC_STACKPROTECTOR) #if defined(_NOLIBC_STACKPROTECTOR)
if (!__stack_chk_guard) { if (!__stack_chk_guard) {
llen += printf("__stack_chk_guard not initialized"); llen += printf("__stack_chk_guard not initialized");
pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
return 1; return 1;
} }
#endif #endif
...@@ -991,7 +999,7 @@ static int run_protection(int min, int max) ...@@ -991,7 +999,7 @@ static int run_protection(int min, int max)
switch (pid) { switch (pid) {
case -1: case -1:
llen += printf("fork()"); llen += printf("fork()");
pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
return 1; return 1;
case 0: case 0:
...@@ -1007,10 +1015,10 @@ static int run_protection(int min, int max) ...@@ -1007,10 +1015,10 @@ static int run_protection(int min, int max)
if (pid == -1 || !WIFSIGNALED(status) || WTERMSIG(status) != SIGABRT) { if (pid == -1 || !WIFSIGNALED(status) || WTERMSIG(status) != SIGABRT) {
llen += printf("waitpid()"); llen += printf("waitpid()");
pad_spc(llen, 64, "[FAIL]\n"); result(llen, FAIL);
return 1; return 1;
} }
pad_spc(llen, 64, " [OK]\n"); result(llen, OK);
return 0; return 0;
} }
} }
......
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