From dc1e9a5eb81f2b9d8e16d5c80a5781e1e7d9d836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 13 Sep 2024 15:18:49 +0200 Subject: [PATCH] Add test cases for the parallel option. --- t/Makefile.am | 21 +++++++++++----- t/t_parallel-P.to | 4 +++ t/t_parallel-PDd.to | 4 +++ t/t_parallel-Pp.to | 4 +++ t/t_parallel-dp.to | 8 ++++++ t/t_parallel.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++ t/t_parallel.ti | 8 ++++++ 7 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 t/t_parallel-P.to create mode 100644 t/t_parallel-PDd.to create mode 100644 t/t_parallel-Pp.to create mode 100644 t/t_parallel-dp.to create mode 100755 t/t_parallel.sh create mode 100644 t/t_parallel.ti diff --git a/t/Makefile.am b/t/Makefile.am index 7c1d3db..09d6f9b 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -1,18 +1,27 @@ AM_CPPFLAGS = -I$(top_srcdir)/lib LIBPSORT = $(top_builddir)/lib/libptsort.a -if WITH_CRYB_TEST +check_PROGRAMS= +dist_check_SCRIPTS = +EXTRA_DIST = -check_PROGRAMS = t_aa +if WITH_CRYB_TEST +check_PROGRAMS += t_aa t_aa_LDADD = $(LIBPSORT) $(LIBCRYB_TEST) - endif -dist_check_SCRIPTS = t_dp_red.sh +dist_check_SCRIPTS += t_dp_red.sh +EXTRA_DIST += t_dp_red.ti +EXTRA_DIST += t_dp_red.to -${dist_check_SCRIPTS}: t_subr.sh +dist_check_SCRIPTS += t_parallel.sh +EXTRA_DIST += t_parallel.ti +EXTRA_DIST += t_parallel-dp.to +EXTRA_DIST += t_parallel-PDd.to +EXTRA_DIST += t_parallel-Pp.to +EXTRA_DIST += t_parallel-P.to -EXTRA_DIST = t_dp_red.ti t_dp_red.to +${dist_check_SCRIPTS}: t_subr.sh TESTS = $(check_PROGRAMS) $(dist_check_SCRIPTS) diff --git a/t/t_parallel-P.to b/t/t_parallel-P.to new file mode 100644 index 0000000..208deac --- /dev/null +++ b/t/t_parallel-P.to @@ -0,0 +1,4 @@ +r +b1 a1 c1 +b2 a2 +b3 a3 diff --git a/t/t_parallel-PDd.to b/t/t_parallel-PDd.to new file mode 100644 index 0000000..a0a2ca7 --- /dev/null +++ b/t/t_parallel-PDd.to @@ -0,0 +1,4 @@ + 3 r + 2 b1 a1 + 1 b2 a2 + 0 c1 b3 a3 diff --git a/t/t_parallel-Pp.to b/t/t_parallel-Pp.to new file mode 100644 index 0000000..52780fb --- /dev/null +++ b/t/t_parallel-Pp.to @@ -0,0 +1,4 @@ + 3 r + 2 b1 a1 c1 + 1 b2 a2 + 0 b3 a3 diff --git a/t/t_parallel-dp.to b/t/t_parallel-dp.to new file mode 100644 index 0000000..27bb4f8 --- /dev/null +++ b/t/t_parallel-dp.to @@ -0,0 +1,8 @@ + 3 3 r + 2 2 b1 + 2 2 a1 + 0 2 c1 + 1 1 b2 + 1 1 a2 + 0 0 b3 + 0 0 a3 diff --git a/t/t_parallel.sh b/t/t_parallel.sh new file mode 100755 index 0000000..06ee229 --- /dev/null +++ b/t/t_parallel.sh @@ -0,0 +1,59 @@ +#!/bin/sh +#- +# Copyright (c) 2017-2024 Dag-Erling Smørgrav +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +. ./t_subr.sh + +ptsort() { + local options="$1" + local ifile="${abs_srcdir}/t_parallel.ti" + local ofile="${abs_srcdir}/t_parallel$options.to" + local tfile="${abs_builddir}/t_parallel$options.t$$" + + grep '^[^#]' "${ifile}" | + "${abs_top_builddir}/bin/ptsort" $options ${_verbose:+"-v"} >"${tfile}" + + if cmp -s "${ofile}" "${tfile}" ; then + ok parallel: ptsort $options + else + if [ -n "${_verbose}" ] ; then + diff --side-by-side --width 80 "${ofile}" "${tfile}" >&2 + fi + not_ok parallel: ptsort $options + fi + + rm -f "${tfile}" +} + +ptsort -P +ptsort -PDd +ptsort -Pp +ptsort -dp + +tap diff --git a/t/t_parallel.ti b/t/t_parallel.ti new file mode 100644 index 0000000..0b0fd4b --- /dev/null +++ b/t/t_parallel.ti @@ -0,0 +1,8 @@ +r a1 +a1 a2 +a2 a3 +r b1 +b1 b2 +b2 b3 +r c1 +c1 2