From nobody Wed Jun 14 13:26:30 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qh5mQ3XmKz4dhZV; Wed, 14 Jun 2023 13:26:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qh5mQ2nDWz3tH2; Wed, 14 Jun 2023 13:26:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686749190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8NjkV6yaQbjQ8U6RopOxxicF/RkF5o3Qud9PAy7KHHU=; b=gh1+nnY8Xm5YLSh+4iNNbg8sDeKxA1KLvQlQc4Mmb7TM0Qabxbf7Pvzp8OPIRsGeMEDAeM kpPVYeNYXxi3Yz1GkgNlz+zUn5CkXfPsN5ktHbr0PVt7P7P7qlcdTVE53RMVn3noPTyqJh ABhKT/9MDcEaIVJbUMrMxcriEpjyqUt5kehx9UYTQj19QPGf3fiH1DSdde8WPKLEdf7XFo uFZnUmoq88AOPkAnqnXEmyvXx4NR6L8UpYO/TXv9uDYHwp7UOTfD2alnNTJ9KcXrNDxY9C MzZrt6DaJQ1C4oSjDNlSI/ieFEjY942nBBT26aQgRjrvg4zEDH56KgMobWaJZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686749190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8NjkV6yaQbjQ8U6RopOxxicF/RkF5o3Qud9PAy7KHHU=; b=L5R6yqWDjIWFq9KdMf8cbACXVyYFf6tZndaCmPL239fE0+YRnppBLt9JRyGY/5aHF8WrhQ cdpaCR1iHkzJ7Nb1tZhWjSqvxS4Qi0lv62eRU/Z6vG7+LMFF1qqSvEvmeQCWOjx7KgX5bD L7tOV/PsbnhdoNC3GrZvOekGA85IwgYvJBgpbrZQ5jnrguueXvF8L7UTVxGiR8wFsbyzWj LcgTkAYejS0knazlKVm47u9GHK6M3TKBbURc16MliPZunI74HzFNqVVc/MAmMSFjMePlKD S4CTkSV+3foEgN54vVbLFBr2Tx65oaNpjkxN7GtVVDKSioV1wKPXgCq49ru5nw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686749190; a=rsa-sha256; cv=none; b=kDUKioak41fgyKN8t1fg+3LYmiffYYExpDXlun/E4i1yjHOTv/3jOR9JYlaDACuUKURPoI di/+z+4UgPkOucF8LCa1Sr1d8fi/+q3eaDNGRw1tBhS9S16PC9tYWSuhYR+5Z6JkiCPWyl R5w1ZTQLN0+rAF4Xpjpe1i+QdBJuBP68bx8/9SdONJHScvTtU6ByYdh2299jhd9yk/ZucV BP/+N4OBwmkd8A89cxbMzg7oGc8YYgWS6wWtYe0OYcU7OQmc0Ghp+HQLRprH76AwG3KRcP yJoyN2m7ukdSRrv0evEWnwtH+2ERcVDqNjFElLBwEEw3J8bB7vHDIg2nLjeNEw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Qh5mQ10tDz1569; Wed, 14 Jun 2023 13:26:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35EDQUq6099477; Wed, 14 Jun 2023 13:26:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35EDQUN7099476; Wed, 14 Jun 2023 13:26:30 GMT (envelope-from git) Date: Wed, 14 Jun 2023 13:26:30 GMT Message-Id: <202306141326.35EDQUN7099476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: cfa209265a30 - stable/13 - tsort: Error out if writing to stdout failed. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cfa209265a30952ffc5c58d7d63439a6f61d3f49 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=cfa209265a30952ffc5c58d7d63439a6f61d3f49 commit cfa209265a30952ffc5c58d7d63439a6f61d3f49 Author: Dag-Erling Smørgrav AuthorDate: 2023-05-04 17:26:59 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-06-14 12:48:52 +0000 tsort: Error out if writing to stdout failed. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans, imp Differential Revision: https://reviews.freebsd.org/D39959 (cherry picked from commit cb46f47c7969b619d1b2547d06a75ad5b375eda9) tsort: Replace bcopy() with memcpy(). Also fix an indentation error I introduced in the previous commit. Fixes: cb46f47c7969 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D40042 (cherry picked from commit b55bc49e8694d9226a82041ff23ad61a5c7a6a76) tsort: Add unit tests. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D40043 (cherry picked from commit 09aee570980b7eca6e3c902a66f6db129b8c7376) --- 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 +++++++++++++++++++++++++++++++++++++++ usr.bin/tsort/tsort.c | 6 ++-- 5 files changed, 83 insertions(+), 2 deletions(-) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 1b2c94f42a6b..eb62812bfcd8 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -1096,6 +1096,8 @@ .. truncate .. + tsort + .. units .. uudecode 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 + PROG= tsort +HAS_TESTS= +SUBDIR.${MK_TESTS}= tests + .include 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 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 <output <input <output<get)(db, &key, &data, 0)) { case 0: - bcopy(data.data, &n, sizeof(n)); + memcpy(&n, data.data, sizeof(n)); return (n); case 1: break; @@ -266,7 +268,7 @@ get_node(char *name) n->n_arcs = NULL; n->n_refcnt = 0; n->n_flags = 0; - bcopy(name, n->n_name, key.size); + memcpy(n->n_name, name, key.size); /* Add to linked list. */ if ((n->n_next = graph) != NULL)