man/mlmmj-sub.1 man/mlmmj-maintd.1 man/mlmmj-process.1 \
man/mlmmj-send.1 man/mlmmj-unsub.1 man/mlmmj-list.1
-SUBDIRS = src listtexts contrib
-
-test_scripts = tests/mlmmj-list.sh \
- tests/mlmmj-send.sh \
- tests/mlmmj-sub.sh
-
-check_SCRIPTS=$(test_scripts:.sh=)
-SUFFIXES=.sh
-
-check: $(check_SCRIPTS)
- kyua --config=none test --kyuafile='$(top_builddir)/Kyuafile' \
- --build-root='$(top_builddir)'
-
-.sh:
- install -m 755 $< $@
-
+SUBDIRS = src listtexts contrib tests
AC_CHECK_FUNCS([ftruncate memset socket strerror strncasecmp snprintf fcntl])
AC_CHECK_FUNCS([nanosleep time strftime syslog regcomp regexec])
AC_CHECK_FUNCS([arc4random_uniform])
+PKG_CHECK_MODULES([ATF], [atf-c])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([contrib/Makefile])
AC_CONFIG_FILES([contrib/receivestrip/Makefile])
AC_CONFIG_FILES([Kyuafile])
+AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([tests/Kyuafile])
AC_CONFIG_FILES([tests/test_env.sh])
AC_OUTPUT
return rand();
#else
- return arc4random_uniform(sizeof(int));
+ return arc4random_uniform(INT_MAX);
#endif
}
#if 0
--- /dev/null
+syntax(2)
+
+test_suite('mlmmj')
+
+atf_test_program{name='mlmmj'}
+atf_test_program{name='mlmmj-list'}
+atf_test_program{name='mlmmj-send'}
+atf_test_program{name='mlmmj-sub'}
--- /dev/null
+AUTOMAKE_OPTIONS = foreign
+
+check_PROGRAMS = mlmmj
+
+mlmmj_SOURCES = mlmmj.c $(top_srcdir)/src/prepstdreply.c $(top_srcdir)/include/prepstdreply.h \
+ $(top_srcdir)/src/memory.c $(top_srcdir)/src/controls.c $(top_srcdir)/src/utils.c \
+ $(top_srcdir)/src/strgen.c $(top_srcdir)/src/random-int.c $(top_srcdir)/src/readn.c \
+ $(top_srcdir)/src/log_error.c $(top_srcdir)/src/chomp.c $(top_srcdir)/src/mygetline.c $(top_srcdir)/src/unistr.c
+mlmmj_CFLAGS = @ATF_CFLAGS@ -g -Wall -pedantic -Wsign-compare -DDEFAULTTEXTDIR='"@textlibdir@"' -I$(top_srcdir)/include
+mlmmj_LDADD = @ATF_LIBS@
+
+test_scripts = mlmmj-list.sh \
+ mlmmj-send.sh \
+ mlmmj-sub.sh
+
+check_SCRIPTS=$(test_scripts:.sh=)
+SUFFIXES=.sh
+
+check: $(check_SCRIPTS) $(check_PROGRAMS)
+ kyua --config=none test --kyuafile='$(builddir)/Kyuafile' \
+ --build-root='$(builddir)'
+
+.sh:
+ install -m 755 $< $@
+
--- /dev/null
+#!/usr/bin/env atf-sh
+
+. $(atf_get_srcdir)/test_env.sh
+
+tests_init \
+ normail \
+ nomail \
+ digest \
+ moderators \
+ owner
+
+normail_body()
+{
+ init_ml ml
+ echo "john@doe.org" > ml/subscribers.d/j
+ atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -s
+ atf_check -o "inline:1\n" mlmmj-list -L ml -s -c
+
+ # check the default
+ atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml
+ atf_check -o "inline:1\n" mlmmj-list -L ml -c
+}
+
+nomail_body()
+{
+ init_ml ml
+ echo "john@doe.org" > ml/nomailsubs.d/j
+ atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -n
+ atf_check -o "inline:1\n" mlmmj-list -L ml -n -c
+}
+
+digest_body()
+{
+ init_ml ml
+ echo "john@doe.org"> ml/digesters.d/j
+ atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -d
+ atf_check -o "inline:1\n" mlmmj-list -L ml -d -c
+}
+
+moderators_body()
+{
+ init_ml ml
+ echo "john@doe.org"> ml/control/moderators
+ atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -m
+ atf_check -o "inline:1\n" mlmmj-list -L ml -m -c
+}
+
+owner_body()
+{
+ init_ml ml
+ echo "john@doe.org"> ml/control/owner
+ atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -o
+ atf_check -o "inline:1\n" mlmmj-list -L ml -o -c
+}
--- /dev/null
+#!/usr/bin/env atf-sh
+
+. $(atf_get_srcdir)/test_env.sh
+
+tests_init \
+ mlmmj-makeml
+
--- /dev/null
+/*
+ * Copyright (C) 2021 Baptiste Daroussin <bapt@FreeBSD.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <atf-c.h>
+#include <wrappers.h>
+#include <inttypes.h>
+#include <sys/limits.h>
+
+ATF_TC(random_int);
+
+ATF_TC_HEAD(random_int, tc) { }
+
+ATF_TC_BODY(random_int, tc)
+{
+ intmax_t val = random_int();
+
+ ATF_CHECK_MSG(val < INT_MAX, "Invalid integer");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, random_int);
+ return (atf_no_error());
+}
--- /dev/null
+srcdir="$(atf_get_srcdir)"
+export PATH="$srcdir/../src:${PATH}"
+
+selfdir="/home/bapt/dev/mlmmjng/tests"
+LIBRARY_PATH_ENV="LIBRARY_PATH"
+SYSROOT_DIR="${selfdir}"
+
+prefix="/usr/local"
+exec_prefix="${prefix}"
+datarootdir="${prefix}/share"
+pcpath="@PKG_DEFAULT_PATH@"
+
+tests_init()
+{
+ TESTS="$@"
+ export TESTS
+ for t ; do
+ atf_test_case $t
+ done
+}
+
+atf_init_test_cases() {
+ for t in ${TESTS}; do
+ atf_add_test_case $t
+ done
+}
+
+init_ml()
+{
+ local ml="$1"
+ mkdir "$ml"
+ for d in incoming queue queue/discarded archive text subconf unsubconf \
+ bounce control moderation subscribers.d digesters.d requeue \
+ nomailsubs.d; do
+ mkdir $ml/$d
+ done
+}
--- /dev/null
+srcdir="$(atf_get_srcdir)"
+export PATH="$srcdir/../src:${PATH}"
+
+selfdir="@abs_top_srcdir@/tests"
+LIBRARY_PATH_ENV="LIBRARY_PATH"
+SYSROOT_DIR="${selfdir}"
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+datarootdir="@datarootdir@"
+pcpath="@PKG_DEFAULT_PATH@"
+
+tests_init()
+{
+ TESTS="$@"
+ export TESTS
+ for t ; do
+ atf_test_case $t
+ done
+}
+
+atf_init_test_cases() {
+ for t in ${TESTS}; do
+ atf_add_test_case $t
+ done
+}
+
+init_ml()
+{
+ local ml="$1"
+ mkdir "$ml"
+ for d in incoming queue queue/discarded archive text subconf unsubconf \
+ bounce control moderation subscribers.d digesters.d requeue \
+ nomailsubs.d; do
+ mkdir $ml/$d
+ done
+}