git: 09aee570980b - main - tsort: Add unit tests.
- Reply: Steffen Nurpmeso : "Re: git: 09aee570980b - main - tsort: Add unit tests."
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 May 2023 13:46:18 UTC
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=09aee570980b7eca6e3c902a66f6db129b8c7376 commit 09aee570980b7eca6e3c902a66f6db129b8c7376 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2023-05-10 13:45:44 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2023-05-10 13:45:44 +0000 tsort: Add unit tests. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D40043 --- etc/mtree/BSD.tests.dist | 2 ++ usr.bin/tsort/Makefile | 5 +++ usr.bin/tsort/tests/Makefile | 6 ++++ usr.bin/tsort/tests/tsort_test.sh | 66 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index c9a13cec193e..5d99653100df 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -1116,6 +1116,8 @@ .. truncate .. + tsort + .. units .. unifdef diff --git a/usr.bin/tsort/Makefile b/usr.bin/tsort/Makefile index b0d353e4d8f7..c0933dac2de1 100644 --- a/usr.bin/tsort/Makefile +++ b/usr.bin/tsort/Makefile @@ -1,6 +1,11 @@ # @(#)Makefile 8.1 (Berkeley) 6/9/93 # $FreeBSD$ +.include <src.opts.mk> + PROG= tsort +HAS_TESTS= +SUBDIR.${MK_TESTS}= tests + .include <bsd.prog.mk> diff --git a/usr.bin/tsort/tests/Makefile b/usr.bin/tsort/tests/Makefile new file mode 100644 index 000000000000..ab16c2842dd0 --- /dev/null +++ b/usr.bin/tsort/tests/Makefile @@ -0,0 +1,6 @@ +PACKAGE= tests + +ATF_TESTS_SH= tsort_test +BINDIR= ${TESTSDIR} + +.include <bsd.test.mk> diff --git a/usr.bin/tsort/tests/tsort_test.sh b/usr.bin/tsort/tests/tsort_test.sh new file mode 100755 index 000000000000..88d4efaf2b9f --- /dev/null +++ b/usr.bin/tsort/tests/tsort_test.sh @@ -0,0 +1,66 @@ +# +# Copyright (c) 2023 Klara, Inc. +# +# SPDX-License-Identifier: BSD-2-Clause +# + +atf_test_case basic +basic_head() +{ + atf_set "descr" "Sort a basic graph" +} +basic_body() +{ + cat >input <<EOF +A B +A F +B C +B D +D E +EOF + cat >output <<EOF +A +F +B +D +C +E +EOF + atf_check -o file:output tsort input + atf_check -o file:output tsort <input +} + +atf_test_case cycle +cycle_head() +{ + atf_set "descr" "Sort a graph with a cycle" +} +cycle_body() +{ + cat >input <<EOF +A B +A F +B C +B D +D E +D A +EOF + cat >output<<EOF +D +E +A +F +B +C +EOF + atf_check -e match:cycle -o file:output tsort input + atf_check -e match:cycle -o file:output tsort <input + atf_check -o file:output tsort -q input + atf_check -o file:output tsort -q <input +} + +atf_init_test_cases() +{ + atf_add_test_case basic + atf_add_test_case cycle +}