From 259de04636b352573c5bb05fe731fe47aa09355e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 5 Mar 2023 10:21:16 +0000 Subject: [PATCH] Run test_lineedit and test_terminal in the main build. These seem likely to carry on being useful, so let's make sure they pass before allowing any build to complete successfully. I've added code to both test programs to return a sensible exit status indicating pass/fail, and added runs of both to Buildscr. --- Buildscr | 2 ++ test/test_lineedit.c | 16 +++++++++++++++- test/test_terminal.c | 13 ++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Buildscr b/Buildscr index a7cb49df..bc225673 100644 --- a/Buildscr +++ b/Buildscr @@ -140,6 +140,8 @@ delegate - in putty do cmake . -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak" -DSTRICT=ON in putty do make -j$(nproc) VERBOSE=1 in putty do python3 test/cryptsuite.py +in putty do ./test_lineedit +in putty do ./test_terminal enddelegate delegate - diff --git a/test/test_lineedit.c b/test/test_lineedit.c index 488eca56..fe0be162 100644 --- a/test/test_lineedit.c +++ b/test/test_lineedit.c @@ -44,6 +44,8 @@ typedef struct Mock { strbuf *context; /* for printing in failed tests */ + bool any_test_failed; + TermWin tw; Seat seat; Backend backend; @@ -193,6 +195,7 @@ static void expect_backend(Mock *mk, const char *file, int line, printf("\", got \""); write_c_string_literal(stdout, actual); printf("\"\n"); + mk->any_test_failed = true; } } @@ -207,6 +210,7 @@ static void expect_terminal(Mock *mk, const char *file, int line, printf("\", got \""); write_c_string_literal(stdout, actual); printf("\"\n"); + mk->any_test_failed = true; } } @@ -252,6 +256,7 @@ static void expect_specials(Mock *mk, const char *file, int line, mk->specials[i].arg); } printf(" ]\n"); + mk->any_test_failed = true; } } @@ -754,6 +759,15 @@ int main(void) test_edit(mk, false); ldisc_free(ldisc); + + bool failed = mk->any_test_failed; mock_free(mk); - return 0; + + if (failed) { + printf("Test suite FAILED!\n"); + return 1; + } else { + printf("Test suite passed\n"); + return 0; + } } diff --git a/test/test_terminal.c b/test/test_terminal.c index d8bf3cb7..9fdca6cc 100644 --- a/test/test_terminal.c +++ b/test/test_terminal.c @@ -34,6 +34,8 @@ typedef struct Mock { strbuf *context; + bool any_test_failed; + TermWin tw; } Mock; @@ -118,6 +120,7 @@ static void report_fail(Mock *mk, const char *file, int line, vprintf(fmt, ap); va_end(ap); printf("\n"); + mk->any_test_failed = true; } static inline void check_iequal(Mock *mk, const char *file, int line, @@ -492,6 +495,14 @@ int main(void) test_wrap(mk); test_nonwrap(mk); + bool failed = mk->any_test_failed; mock_free(mk); - return 0; + + if (failed) { + printf("Test suite FAILED!\n"); + return 1; + } else { + printf("Test suite passed\n"); + return 0; + } }