From nobody Mon Oct 09 17:46:42 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 4S460g0b5Cz4x9Bd; Mon, 9 Oct 2023 17:46:43 +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 4S460g072Yz4JJv; Mon, 9 Oct 2023 17:46:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696873603; 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=sljD6CWKr8EYj37crlB2H/ynxU8kdX0x2yoiC6ytS7I=; b=wfslukGuIug06/cbjImU2qLcOrw1KCP5fgU+9BngVRsCj0CLFCkf1YgIY78v9Lsgn1Qyz+ PaR9Jo8TwHTAvY/LGxtygrVRPaNjzqwQ5VgnOd/Z1EB58USmgaVUzS5fNkGF7N8AVxqutu f32G02Mhm7Vn60FXzaYjF3swiQs6UTS3QTj4yMtDhixAwWmqXXuViWgXQMpVIzpTu6E4TZ ARFPRWndB9rE331K7dVRXuqyzZ5Acmgs1iHB9h9XUXF1Cr+lfQ3sd8ZOZlZJo+QvyJ99QF oocS38F9ZcR3160G0aiRNjKDqyFj8KHFp0eljqzN6vZilLUHisuysa4aFsH+PA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696873603; a=rsa-sha256; cv=none; b=p2Mp4Ym612UAzsvzktM4sD6+KhwJJ2VRLK9Pv4RCy5y9zIQYhhiy3WYLmF4xUCKr/bAdHb 6RiVpM2Rjh2dM199JMda9gwhAoP2hGn5UT96PFm/xSHrx9ApmQD0WnxUC0QMQ/gBmmmcSM FbytQqh7G0THoO1jM5HD6ZBPl00mto4yXliWaWQapbRsIKRH12vzuYZ851YkWgjr0kbbOp lIHGpqdO3tJb9Z9g7eFN2pDmC14RFOSPywzOypeYRJw3i82o6WN49YQoOjk7fvUtoWTOkL ac+ANbqB49+zNqajDW/k2Lp5fA4cnE+1Zi9DWJg12ZxN6cV5iAPjHyvI6GKqww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696873603; 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=sljD6CWKr8EYj37crlB2H/ynxU8kdX0x2yoiC6ytS7I=; b=jQFgshTt3zv07ftH6knJPZWCDoSS8tA3g6M53qkL60ZkPm28woLpsePYaojArpV4fQxXz8 zYZwgnMUTPokt0vobLKtZkAfbomwqrbdPcffMumAJH2lnsmQErJ2MhrRMufU3uFqEvPQPi qTv/7rczjUaVdsVTsVwrdnfXZMFp8Higq0lNA9lTkdEUvtjnw9GhrYUsYxEwFGM7O2g+xm t6FDXjL24YUOb4ML1rO0cBxKT+hVGkJDUorq6NGdDsWBxPDqxHrEYdtuaVlrGvYXY6EZpy eFejKTl0/lHuhuV5R7uEuI9i+m3iE9iC9UjSsPolxcH9QiExEabqCOFxMyt1DQ== 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 4S460f6HYxz15BC; Mon, 9 Oct 2023 17:46:42 +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 399HkgBd022375; Mon, 9 Oct 2023 17:46:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 399HkgQB022372; Mon, 9 Oct 2023 17:46:42 GMT (envelope-from git) Date: Mon, 9 Oct 2023 17:46:42 GMT Message-Id: <202310091746.399HkgQB022372@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: 8f75390c66bd - main - file: Support testing multiple magic files. 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: delphij X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8f75390c66bdcde95e1b383aecaa27b4adf88279 Auto-Submitted: auto-generated The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=8f75390c66bdcde95e1b383aecaa27b4adf88279 commit 8f75390c66bdcde95e1b383aecaa27b4adf88279 Author: Xin LI AuthorDate: 2023-10-09 06:06:20 +0000 Commit: Xin LI CommitDate: 2023-10-09 17:44:42 +0000 file: Support testing multiple magic files. This is based on upstream b74150490be904801378b2712fe0d532e1700124 but adapted to ATF. Reviewed by: jlduran@gmail.com, markj, vangyzen Differential Revision: https://reviews.freebsd.org/D42129 --- usr.bin/file/tests/Makefile | 2 +- usr.bin/file/tests/file_test.sh | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/usr.bin/file/tests/Makefile b/usr.bin/file/tests/Makefile index ea0ebaa12ce2..cd3d00ae742c 100644 --- a/usr.bin/file/tests/Makefile +++ b/usr.bin/file/tests/Makefile @@ -2,7 +2,7 @@ PACKAGE= tests ATF_TESTS_SH= file_test SRCDIR= ${SRCTOP}/contrib/file/tests -_files!= echo ${SRCDIR}/*.testfile ${SRCDIR}/*.result ${SRCDIR}/*.magic +_files!= echo ${SRCDIR}/*.testfile ${SRCDIR}/*.flags ${SRCDIR}/*.result ${SRCDIR}/*.magic ${PACKAGE}FILES+=${_files} .include diff --git a/usr.bin/file/tests/file_test.sh b/usr.bin/file/tests/file_test.sh index 02d494b0f643..490274c05892 100644 --- a/usr.bin/file/tests/file_test.sh +++ b/usr.bin/file/tests/file_test.sh @@ -32,14 +32,26 @@ contrib_file_tests_body() { for testfile in "${srcdir}"/*.testfile; do test_name="${testfile%.testfile}" result_file="${test_name}.result" - magic_file="${test_name}.magic" file_args= - if [ -e "${magic_file}" ]; then - file_args="${file_args} --magic-file ${magic_file}" + magic_files= + for magic_file in ${test_name}*.magic; do + if [ -f "${magic_file}" ]; then + if [ -z "${magic_files}" ]; then + magic_files="${magic_file}" + else + magic_files="${magic_files}:${magic_file}" + fi + fi + done + if [ -z "${magic_files}" ]; then + magic_files=/usr/share/misc/magic + fi + if [ -f "${test_name}.flags" ]; then + file_args="${file_args} -$(cat "${test_name}.flags")" fi # The result files were created in UTC. - TZ=Z atf_check -o save:actual_output file ${file_args} \ - --brief "$testfile" + atf_check -o save:actual_output -e ignore env TZ=Z MAGIC="${magic_files}" \ + file ${file_args} --brief "$testfile" atf_check cmp actual_output "$result_file" done }