From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1659489-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id CA7B4159C83
	for <garchives@archives.gentoo.org>; Wed,  7 Aug 2024 08:59:03 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A18E02BC021;
	Wed,  7 Aug 2024 08:59:02 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(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)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 8593E2BC021
	for <gentoo-commits@lists.gentoo.org>; Wed,  7 Aug 2024 08:59:02 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 75B0934308F
	for <gentoo-commits@lists.gentoo.org>; Wed,  7 Aug 2024 08:59:01 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AC8521EBD
	for <gentoo-commits@lists.gentoo.org>; Wed,  7 Aug 2024 08:58:59 +0000 (UTC)
From: "Andrew Ammerlaan" <andrewammerlaan@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Andrew Ammerlaan" <andrewammerlaan@gentoo.org>
Message-ID: <1723021121.03e930a67cb99b686188d74e5f2168506b0447aa.andrewammerlaan@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/
X-VCS-Repository: repo/gentoo
X-VCS-Files: eclass/tests/dist-kernel-utils.sh
X-VCS-Directories: eclass/tests/
X-VCS-Committer: andrewammerlaan
X-VCS-Committer-Name: Andrew Ammerlaan
X-VCS-Revision: 03e930a67cb99b686188d74e5f2168506b0447aa
X-VCS-Branch: master
Date: Wed,  7 Aug 2024 08:58:59 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: fd404082-03d7-4a56-af8a-d5ded5e8036c
X-Archives-Hash: 7cc8e7ac691e84992b729df825227644

commit:     03e930a67cb99b686188d74e5f2168506b0447aa
Author:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  6 09:38:34 2024 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Wed Aug  7 08:58:41 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03e930a6

eclass/tests/dist-kernel-utils.sh: add compressed_module_cleanup tests

Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/37985
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 eclass/tests/dist-kernel-utils.sh | 59 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh
index 50ba001f8e9c..28c8f7213a53 100755
--- a/eclass/tests/dist-kernel-utils.sh
+++ b/eclass/tests/dist-kernel-utils.sh
@@ -20,9 +20,68 @@ test_PV_to_KV() {
 	tend $?
 }
 
+test_compressed_module_cleanup() {
+	mkdir -p "${tmpdir}/source" || die
+	pushd "${tmpdir}" >/dev/null || die
+
+	local module option fail=0
+	for option in NONE GZIP XZ ZSTD; do
+		tbegin "CONFIG_MODULE_COMPRESS_${option}"
+		echo "CONFIG_MODULE_COMPRESS_${option}=y" > source/.config
+
+		touch a.ko b.ko.gz c.ko.xz d.ko.gz e.ko f.ko.xz || die
+		# ensure some files are older
+		touch -d "2 hours ago" d.ko e.ko.xz f.ko.gz || die
+
+		IUSE=modules-compress dist-kernel_compressed_module_cleanup .
+
+		local to_keep=( a.ko b.ko.gz c.ko.xz )
+		local to_remove=()
+
+		case ${option} in
+			NONE)
+				to_keep+=( d.ko e.ko f.ko.xz )
+				to_remove+=( d.ko.gz e.ko.xz f.ko.gz )
+				;;
+			GZIP)
+				to_keep+=( d.ko.gz e.ko f.ko.gz )
+				to_remove+=( d.ko e.ko.xz f.ko.xz )
+				;;
+			XZ)
+				to_keep+=( d.ko.gz e.ko.xz f.ko.xz )
+				to_remove+=( d.ko e.ko f.ko.gz )
+				;;
+			ZSTD)
+				to_keep+=( d.ko.gz e.ko f.ko.xz )
+				to_remove+=( d.ko e.ko.xz f.ko.gz )
+				;;
+		esac
+
+		for module in "${to_keep[@]}"; do
+			if [[ ! -f ${module} ]]; then
+				eerror "Module ${module} was removed"
+				fail=1
+			fi
+		done
+
+		for module in "${to_remove[@]}"; do
+			if [[ -f ${module} ]]; then
+				eerror "Module ${module} was not removed"
+				fail=1
+			fi
+		done
+		tend ${fail}
+	done
+
+	popd >/dev/null || die
+}
+
+
 test_PV_to_KV 6.0_rc1 6.0.0-rc1
 test_PV_to_KV 6.0 6.0.0
 test_PV_to_KV 6.0.1_rc1 6.0.1-rc1
 test_PV_to_KV 6.0.1 6.0.1
 
+test_compressed_module_cleanup
+
 texit