From nobody Fri Jan 12 15:44:27 2024 X-Original-To: dev-commits-src-main@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 4TBQnl6lTFz5734R; Fri, 12 Jan 2024 15:44:27 +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 4TBQnl69XGz4LxT; Fri, 12 Jan 2024 15:44:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705074267; 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=rSE/OcjV4p+Xw48nzsp7zsjhn2q5ngSxYqfeq8lLNIs=; b=jzso9jVKAKgS86qPnZxYYIfXAMe5nDEh81lcRU7RnX6Kt2+A875qck0l75RFCc+POGdRCB dPqX1AJ9Kzu06Zd+yDNmZx5xjtUCac90NpdlSNaz1w79xlooG4LrVJnd6eZstIznu1UpJn 5M6mWJ8CFnGFuFbpAMZnBclmrvcdDDE2CcuFBQPq1oEWeQ+ODAUndpczYQb8HWbXQ5bO8h Z5WgQbb1wniNKZC5FFtlgdGidBL9f27PCUGuZY1lXyJy2331KnfvuvBwGpi/E9L1HHHzSK sM3xOm8uliiLiZwXd+pXVixBxUQTDr1Ua3Yubj6T7KcOYFt0fA6wEROgJUNDFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705074267; 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=rSE/OcjV4p+Xw48nzsp7zsjhn2q5ngSxYqfeq8lLNIs=; b=pIrMuQZLo5f7+Ey+Wk/KtH5lxnLETZ7PvjaB0TRYelyBKt9misKw14tdNhwNeJbrxo7qz/ 3ULOLlZWZF/a2m4UYac7UQhMBPvqjBo2/Qp16Zfi3vBR90U6Lo5FZ76RLka0Nhhz+I/u1s qP+GxS5Y6LComRCjJ4HkLONPGXNoetQTAwaanxXO+Zhhyksjd7HZzP1uKpBEeBtuuEwd71 4n3Km+7oNIlRIB9nyTTL/FcI6eUOEl7WiOieT4siSL71P26xNm/5U7Vxsp4FpZHoIeItPZ mj9GfvGdGp81/o6d/D1HXnnf+HVqoNBS3MgayBAbb6tXbP7az5lz0aEZL30tCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705074267; a=rsa-sha256; cv=none; b=HhDiTLQWniXBGT2xWE9cds00O2qPedLOXOQWF8Ya5poXpQTxp94TLfEVmpOGqVTEBf6vY8 lKi4ElEXhiGQ7+51cI1/mU6jRMB2lMJUzulU1EBWYJTzwsgGyeaz3e1sj2ixxg0s4W6xyc sWmch6AtWcN8xXEd743yqsNlqQ4apiVmR9erfYC8XqOwZrPr7bxTca5hhcp4xosA0xVwzd 8hlFdcJnfMxdyC0osYL3G2QYD1dFR1PIcWQvSmKNAVp074Su2IOuriZvS27ZQqSF++P1MN PBInEMx6B/i4tlJV5Df5I55nBtkh3zj366GqJor0xZXZdn67VIjROTwzS5SdJg== 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 4TBQnl5H4lz17B8; Fri, 12 Jan 2024 15:44:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40CFiRnX076587; Fri, 12 Jan 2024 15:44:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CFiRSx076584; Fri, 12 Jan 2024 15:44:27 GMT (envelope-from git) Date: Fri, 12 Jan 2024 15:44:27 GMT Message-Id: <202401121544.40CFiRSx076584@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: e762fd81e253 - main - uniq: Replace NetBSD's unit tests with our own. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e762fd81e253d4ae9b9f7d2e65cf448633bbe527 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=e762fd81e253d4ae9b9f7d2e65cf448633bbe527 commit e762fd81e253d4ae9b9f7d2e65cf448633bbe527 Author: Dag-Erling Smørgrav AuthorDate: 2024-01-12 15:40:26 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-01-12 15:43:49 +0000 uniq: Replace NetBSD's unit tests with our own. These new tests cover more functionality and are easier to extend. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D43381 --- ObsoleteFiles.inc | 8 +++ usr.bin/uniq/tests/Makefile | 13 +--- usr.bin/uniq/tests/uniq_test.sh | 149 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 12 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index da7e3d432bfb..ac936aebb574 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -51,6 +51,14 @@ # xargs -n1 | sort | uniq -d; # done +# 20240112: replaced NetBSD tests for uniq with our own +OLD_FILES+=usr/tests/usr.bin/uniq/d_basic.in +OLD_FILES+=usr/tests/usr.bin/uniq/d_basic.out +OLD_FILES+=usr/tests/usr.bin/uniq/d_counts.out +OLD_FILES+=usr/tests/usr.bin/uniq/d_input.in +OLD_FILES+=usr/tests/usr.bin/uniq/d_show_duplicates.out +OLD_FILES+=usr/tests/usr.bin/uniq/d_show_uniques.out + # 20231208: new clang import which bumps version from 16 to 17 OLD_FILES+=usr/lib/clang/16/include/__clang_cuda_builtin_vars.h OLD_FILES+=usr/lib/clang/16/include/__clang_cuda_cmath.h diff --git a/usr.bin/uniq/tests/Makefile b/usr.bin/uniq/tests/Makefile index d9c839aa35b6..55bb98e98c34 100644 --- a/usr.bin/uniq/tests/Makefile +++ b/usr.bin/uniq/tests/Makefile @@ -1,15 +1,4 @@ - PACKAGE= tests - -NETBSD_ATF_TESTS_SH= uniq_test - -${PACKAGE}FILES+= d_basic.in -${PACKAGE}FILES+= d_basic.out -${PACKAGE}FILES+= d_counts.out -${PACKAGE}FILES+= d_input.in -${PACKAGE}FILES+= d_show_duplicates.out -${PACKAGE}FILES+= d_show_uniques.out - -.include +ATF_TESTS_SH= uniq_test .include diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh new file mode 100755 index 000000000000..ddd9ec9881dd --- /dev/null +++ b/usr.bin/uniq/tests/uniq_test.sh @@ -0,0 +1,149 @@ +# +# Copyright (c) 2024 Klara, Inc. +# +# SPDX-License-Identifier: BSD-2-Clause +# + +atf_check_uniq() { + atf_check uniq "$@" input actual + atf_check diff -u actual expected + atf_check uniq "$@" - actual input + printf "a\nb\na\n" >expected + atf_check_uniq +} + +atf_test_case count +count_head() { + atf_set descr "basic test showing counts" +} +count_body() { + printf "a\na\nb\nb\nb\na\na\na\na\n" >input + printf " 2 a\n 3 b\n 4 a\n" >expected + atf_check_uniq -c + atf_check_uniq --count +} + +atf_test_case repeated +repeated_head() { + atf_set descr "print repeated lines only" +} +repeated_body() { + printf "a\na\nb\na\na\n" >input + printf "a\na\n" >expected + atf_check_uniq -d + atf_check_uniq --repeated +} + +atf_test_case count_repeated +count_repeated_head() { + atf_set descr "count and print repeated lines only" +} +count_repeated_body() { + printf "a\na\nb\nb\na\n" >input + printf " 2 a\n 2 b\n" >expected + atf_check_uniq --count --repeated +} + +atf_test_case all_repeated +all_repeated_head() { + atf_set descr "print every instance of repeated lines" +} +all_repeated_body() { + printf "a\na\nb\na\na\n" >input + printf "a\na\na\na\n" >expected + atf_check_uniq -D + atf_check_uniq --all-repeated +} + +atf_test_case skip_fields +skip_fields_head() { + atf_set descr "skip fields" +} +skip_fields_body() { + printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input + printf "1 a\n3 b\n5 a\n" >expected + atf_check_uniq -f 1 + atf_check_uniq --skip-fields 1 +} + +atf_test_case skip_fields_tab +skip_fields_tab_head() { + atf_set descr "skip fields (with tabs)" +} +skip_fields_tab_body() { + printf "1\ta\n2\ta\n3\tb\n4\tb\n5\ta\n6\ta\n" >input + printf "1\ta\n3\tb\n5\ta\n" >expected + atf_check_uniq -f 1 + atf_check_uniq --skip-fields 1 +} + +atf_test_case ignore_case +ignore_case_head() { + atf_set descr "ignore case" +} +ignore_case_body() { + printf "a\nA\nb\nB\na\nA\n" >input + printf "a\nb\na\n" >expected + atf_check_uniq -i + atf_check_uniq --ignore-case +} + +atf_test_case skip_chars +skip_chars_head() { + atf_set descr "skip chars" +} +skip_chars_body() { + printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input + printf "1 a\n3 b\n5 a\n" >expected + atf_check_uniq -s 2 + atf_check_uniq --skip-chars 2 +} + +atf_test_case unique +unique_head() { + atf_set descr "print non-repeated lines only" +} +unique_body() { + printf "a\na\nb\na\na\n" >input + printf "b\n" >expected + atf_check_uniq -u + atf_check_uniq --unique +} + +atf_test_case count_unique +count_unique_head() { + atf_set descr "print non-repeated lines with count" +} +count_unique_body() { + printf "a\na\nb\n" >input + printf " 1 b\n" >expected + atf_check_uniq --unique --count + atf_check_uniq --count --unique +} + +atf_init_test_cases() +{ + atf_add_test_case basic + atf_add_test_case count + atf_add_test_case repeated + atf_add_test_case count_repeated + atf_add_test_case all_repeated + atf_add_test_case skip_fields + atf_add_test_case skip_fields_tab + atf_add_test_case ignore_case + atf_add_test_case skip_chars + atf_add_test_case unique + atf_add_test_case count_unique +}