From: Martti Rannanjärvi Date: Thu, 23 May 2019 15:49:18 +0000 (+0300) Subject: lib: Add test-fd-util.c to test i_close() panic message X-Git-Tag: 2.3.9~471 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=674b05f31d11eb63c67951b1cd84db5635d67c2d;p=thirdparty%2Fdovecot%2Fcore.git lib: Add test-fd-util.c to test i_close() panic message --- diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index f1fd95c5ff..2726dd80da 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -349,6 +349,7 @@ test_lib_SOURCES = \ test-event-flatten.c \ test-event-log.c \ test-failures.c \ + test-fd-util.c \ test-file-create-locked.c \ test-guid.c \ test-hash.c \ diff --git a/src/lib/test-fd-util.c b/src/lib/test-fd-util.c new file mode 100644 index 0000000000..1058ecab4e --- /dev/null +++ b/src/lib/test-fd-util.c @@ -0,0 +1,24 @@ +/* Copyright (c) 2019 Dovecot authors, see the included COPYING file */ + +#include "test-lib.h" +#include "fd-util.h" + +enum fatal_test_state fatal_i_close(unsigned int stage) +{ + if (stage == 0) { + test_begin("fatal i_close"); + } else { + test_end(); + return FATAL_TEST_FINISHED; + } + + int fd = 0; + const char *fatal_string = t_strdup_printf( + "%s: close((&fd)) @ %s:%d attempted with fd=%d", + __func__, __FILE__, __LINE__ + 2, fd); + test_expect_fatal_string(fatal_string); + i_close_fd(&fd); + + /* This cannot be reached. */ + return FATAL_TEST_ABORT; +} diff --git a/src/lib/test-lib.inc b/src/lib/test-lib.inc index 12f9305bdb..0d2895fc29 100644 --- a/src/lib/test-lib.inc +++ b/src/lib/test-lib.inc @@ -27,6 +27,7 @@ TEST(test_hash_format) TEST(test_hash_method) TEST(test_hmac) TEST(test_hex_binary) +FATAL(fatal_i_close) TEST(test_imem) TEST(test_ioloop) TEST(test_iso8601_date)