]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
tests: factorize some code
authorBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 14 Feb 2023 08:34:23 +0000 (09:34 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 14 Feb 2023 08:34:23 +0000 (09:34 +0100)
tests/Makefile.am
tests/mlmmj.c

index 432329b4fb8118f480b721b1346f0142fa08f706..4ee5e359015751da1a2f98049de28d84c67d2d0a 100644 (file)
@@ -7,7 +7,7 @@ mlmmj_SOURCES = mlmmj.c \
 EXTRA_DIST = *.sh *.h
 CLEANFILES= $(test_scripts:.sh=)
 
-AM_CFLAGS = -g -Wall -std=gnu99 -D_GNU_SOURCE=1 -Wextra -pedantic -Wsign-compare -DDEFAULTTEXTDIR='"@textlibdir@"' -I$(srcdir)/../include @ATF_CFLAGS@
+AM_CFLAGS = -g -Wall -std=gnu11 -D_GNU_SOURCE=1 -Wextra -pedantic -Wsign-compare -DDEFAULTTEXTDIR='"@textlibdir@"' -I$(srcdir)/../include @ATF_CFLAGS@
 mlmmj_LDADD =  $(top_builddir)/src/libmlmmj.a @ATF_LIBS@ -lrt
 AM_LDFLAGS =
 if WANT_COVERAGE
index 40ae95e0164454b9619ad526639cd1404a65ba35..ca3724c92eec29cc75154580fa63a0071646ba67 100644 (file)
@@ -919,10 +919,7 @@ ATF_TC_BODY(smtp, tc)
        ATF_REQUIRE(socketpair(AF_UNIX, SOCK_STREAM, 0, smtppipe) >= 0);
        pid_t p = atf_utils_fork();
        if (p == 0) {
-               dprintf(smtppipe[0], "220 me fake smtp\n");
-               /* EHLO */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
+               const char *replies[] = {
                    "250-hostname.net\n"
                    "250-PIPELINEING\n"
                    "250-SIZE 20480000\n"
@@ -932,35 +929,20 @@ ATF_TC_BODY(smtp, tc)
                    "250-8BITMIME\n"
                    "250-DSN\n"
                    "250-SMTPUTF8\n"
-                   "250 CHUNKING\n");
-               /* HELO */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "250-hostname.net\n");
-               /* MAIL FROM */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "250 2.1.0 Ok\n");
-               /* RCPT TO */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "250 2.1.0 Ok\n");
-               /* DATA */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "354 Send message content; end with <CRLF>.<CRLF>\n");
-               /* DATA */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "250 2.1.0 Ok\n");
-               /* QUIT */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "221 2.0.0 Bye\n");
-               /* RSET */
-               reply = mygetline(smtppipe[0]);
-               dprintf(smtppipe[0],
-                   "250 2.0.0 Ok\n");
+                   "250 CHUNKING\n", /* EHLO */
+                   "250-hostname.net\n", /* HELO */
+                   "250 2.1.0 Ok\n", /* MAIL FROM */
+                   "250 2.1.0 Ok\n", /* RCPT TO */
+                   "354 Send message content; end with <CRLF>.<CRLF>\n", /* DATA */
+                   "250 2.1.0 Ok\n", /* DATA */
+                   "221 2.0.0 Bye\n", /* QUIT */
+                   "250 2.0.0 Ok\n", /* RSET */
+               };
+               dprintf(smtppipe[0], "220 me fake smtp\n");
+               for (uint8_t i = 0; i < NELEM(replies); i++) {
+                       reply = atf_utils_readline(smtppipe[0]);
+                       dprintf(smtppipe[0], "%s", replies[i]);
+               }
                exit (0);
        }
        close(smtppipe[0]);