From nobody Sat Nov 04 03:07:12 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 4SMjFs1KnDz50NhP; Sat, 4 Nov 2023 03:07:13 +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 4SMjFs0hXSz3NCX; Sat, 4 Nov 2023 03:07:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699067233; 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=/g8250iKFFFwPU41CZ6ctp2y5qXxlStjfIfHa5hk31A=; b=xLu01BLv353gu7L/cszqvtyy27mq12kv0/H9VEGB2i9LKkPTk/aHaJF7D7yS3oMzBDTVIb tYteSrR3F0Y5A55bfVOYO/lYb+3YllusIZmgrcQETSUrOyplIu/fY8F9EgGXFoc0cUVeM4 GUDQqzUHYP8Ttv40EdX+uPIp6iXr+Vg9Xe7Zvu0KqxJHvogYtAIAzgLhZCd0l+JEbKhuW0 KpjlJnmZnKadGzG0Xb9DOYXxBL+4hj4mRq8wwjKyz2F0O5fwjOPqSiYOZtiDV5QhYUoWW2 U6QpiYJd4V1nj8zSxTOdiBcWwMtDYwSd5PMPHOlm408QeKt58lJ6MDtUr+mmuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699067233; 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=/g8250iKFFFwPU41CZ6ctp2y5qXxlStjfIfHa5hk31A=; b=BlTRO8X0+aFqU4JDdRYNnBYB5vNgneevP522glLDyx55R0sSLtdijXNJYL/nwhZfia0SDv mM188L7PtljMuQ/sukY9jLIVuh4bdutLtAZt3X8jvrY3OfuAU204lAXeLfetOzPvvHbzfV EcnUrvoTr9owgblxu52q49qp4OCVvXFhEJfESngcLemzgikM0Z5rvPEWCWdI+BoCvCkIWD vBjxHt1etExT+N02Bwk8xgZWZiic71+eajHBekf6xUBEEePUyafH1J5ynv7MEwzWprKcse Kr7r431zuSACs7kYI2C0y+fsgltIgG8SY8R29Wfv0oHzAQ/SgznXWizWmBb2Ag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699067233; a=rsa-sha256; cv=none; b=xoYL/R6oxkmWoyXPlk+It4DJhAVwGAmDUQMlWuSlSWlctz1tfnGabJTMaADXrvV7K/2+ZT Se6Ya672nRmg6poGAZHdD6k56Ajevc5XJbYbiB+CGicZzNk9pEw2TFVGuD2O0sfhdX7BWy kEHRPG1d0IE8tPcvJuPr3WT4sHzYVlmAltdLtz0F9LaCJbNcR3dRIQZTUnT0Ljq8gmAFWz 4Hrhq1gJM2CPQmpZng/IQvSovwsIaLnxErm10SoNWM4/aZko5NP70ACBdms/882RGuamgW N/AiOMPJq0y/Ij9b+K8HniizkqStkdcAjaT38zl+jAPWzy2Vq95hDR0ZoMdFXg== 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 4SMjFr6jSwzgwn; Sat, 4 Nov 2023 03:07:12 +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 3A437CEn085058; Sat, 4 Nov 2023 03:07:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A437C5N085055; Sat, 4 Nov 2023 03:07:12 GMT (envelope-from git) Date: Sat, 4 Nov 2023 03:07:12 GMT Message-Id: <202311040307.3A437C5N085055@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 660be17a01ff - stable/14 - 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 660be17a01ffdfa9494ff6039b7b6ddd82e61e65 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=660be17a01ffdfa9494ff6039b7b6ddd82e61e65 commit 660be17a01ffdfa9494ff6039b7b6ddd82e61e65 Author: Xin LI AuthorDate: 2023-10-09 06:06:20 +0000 Commit: Ed Maste CommitDate: 2023-11-04 03:05:19 +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 (cherry picked from commit 8f75390c66bdcde95e1b383aecaa27b4adf88279) --- 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 }