From nobody Sun Feb 8 06:53:49 2026 Received: from mail-il1-f202.google.com (mail-il1-f202.google.com [209.85.166.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7DE81F9EA7 for ; Mon, 2 Dec 2024 07:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126160; cv=none; b=M364S7ykPEKA1gQsFWicCt/LDywCMji8vMIlqXY1+4v8Od2A1P5WGq/mByHmSKlqeV9U147YTxHs8gZZQZxBGJY1GlyN2RuvTqPAsosjXRDNmPiUNDro4NTZE4o4chibYrK53OkO0cyBXWucxnO0BhyKjDZeKL+KA1+ivZLYNTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126160; c=relaxed/simple; bh=CcwBr1pdX1hbhnO2lIC3mhYlJa/UfgyYzruDoRr12f4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pwGZMX1xz+8crQTmVnyRNmVeX63A+61WU5HFaPgVUANMMrAd8lF6nMWXgRrkPiMNIpp3VYD9UqsjEcWdPDXW1BgIMN0oIDb03YwZF9R6DJGFd/TH0O4cVLGAFGv/K+XESKNpxBPQ/fAeQitL7w+y1p3cHULhe1v30jajzBCNBQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kEQM101d; arc=none smtp.client-ip=209.85.166.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kEQM101d" Received: by mail-il1-f202.google.com with SMTP id e9e14a558f8ab-3a7807feadfso34498215ab.2 for ; Sun, 01 Dec 2024 23:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733126158; x=1733730958; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=94n4MHfZago95H2Ehby0lfepfNkVyiA7XUKBvPRgGq8=; b=kEQM101dV0bvz4Mhj3ghpczFChLIvm8u7YC5oBc1I229FCC0jVf09JWt8i/85x/ktV sDMgGO1DK6T5Qa7kohOpiye6+B6C6HNWpchj59cSsrrDw6UiQSDzt/2OR84A69HQAn50 McYnGcHVaTZ90e6IuzZH6iKRxyk4a9Mgafo9so88PAqNW3KXMHCz4N8ht1FLEUXINPHF MLVdhp5G4Rnpco7uSWZ3LKud9GmMuyymP1lmuZS5eJby4K+0rKSrntlp+ld0CB6fxt+X f0HIwES0OPx0Zpin/GHc/DcU9trDe+QRXpC6aj+ToBM0oHjKvpJDMRT+PbEvVjkCqxW+ XaTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733126158; x=1733730958; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=94n4MHfZago95H2Ehby0lfepfNkVyiA7XUKBvPRgGq8=; b=GYJMVIhoorXA//aa+ILQnGamjL95rhNcW3DsyeixNM8TMhlCwgoyH2dNq7Dds2yH7g BUOJrYViT1ZL1RlIbZf8LsGONspqNkRbxZPHDrJ1FEBGHdIrh89mMMZPa/FYOso9OPzD GDp7MTmZN9YmYaRarhiJNz1xoFZJPDySD8Xd9qlB9Nt7R6xwwO2h+nUa+3zWOYK+4rIj VAbQzOKEy7eTdgP1sU9wDlck7t3uJeuOe79rKopGgEriFpVMSnkSDOX1ALpaM5IyfsxU 6wirBzupyVS9dus81g65vulpW0i/3jF5oSfOPg/AQ+yocIoICUrYB8I59SkrXQcUJ4gB EEgA== X-Forwarded-Encrypted: i=1; AJvYcCVQfCSxZJNPMSf7TU45n5T0eHhUBnpfzIvQZw8Kvezd8/6v5ZndKK8CkfFgB/XabAOKoNox3U6FXVRPn94=@vger.kernel.org X-Gm-Message-State: AOJu0YxT4fhpKphpvqpk+yFlbJRg3eV4OepjdBRPoldCdsiJfNiy4c9s koLl8miId2uL3cIv8V6+OmreE3/wAUgN0LjBodtc1FzouPFg7nvoUHoAzFJsdC/xnJMlC9TmTHG bp4YtsDbyjw== X-Google-Smtp-Source: AGHT+IHuIFBcyPiV7QsjE3NU9vB7h2NpBJQm7Zferw0a07aEtyytICdGZvKQpzCBq7/XmaJK0mzFFVq/BDqupQ== X-Received: from pgcv26.prod.google.com ([2002:a05:6a02:531a:b0:7fb:d8e8:ded3]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6e02:194b:b0:3a7:9533:c3ac with SMTP id e9e14a558f8ab-3a7c55259cfmr190932205ab.4.1733126158041; Sun, 01 Dec 2024 23:55:58 -0800 (PST) Date: Mon, 2 Dec 2024 15:55:38 +0800 In-Reply-To: <20241202075545.3648096-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202075545.3648096-1-davidgow@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241202075545.3648096-2-davidgow@google.com> Subject: [PATCH v2 1/6] lib: math: Move kunit tests into tests/ subdir From: David Gow To: Andrew Morton , Shuah Khan , Rae Moar , Kees Cook , Geert Uytterhoeven Cc: Luis Felipe Hernandez , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Stephen Rothwell , Andy Shevchenko , Brendan Higgins , Nicolas Pitre , David Gow Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luis Felipe Hernandez This patch is a follow-up task from a discussion stemming from point 3 in a recent patch introducing the int_pow kunit test [1] and documentation regarding kunit test style and nomenclature [2]. Colocate all kunit test suites in lib/math/tests/ and follow recommended naming convention for files _kunit.c and kconfig entries CONFIG__KUNIT_TEST. Link: https://lore.kernel.org/all/CABVgOS=3D-vh5TqHFCq_jo=3Dffq8v_nGgr6JsPn= OZag3e6+19ysxQ@mail.gmail.com/ [1] Link: https://docs.kernel.org/dev-tools/kunit/style.html [2] Signed-off-by: Luis Felipe Hernandez Acked-by: Nicolas Pitre [Rebased on top of v6.13-rc1, removed non-kunit tests] Signed-off-by: David Gow Reviewed-by: Rae Moar --- lib/Kconfig.debug | 2 +- lib/math/Makefile | 4 ++-- lib/math/tests/Makefile | 3 ++- lib/math/{rational-test.c =3D> tests/rational_kunit.c} | 0 4 files changed, 5 insertions(+), 4 deletions(-) rename lib/math/{rational-test.c =3D> tests/rational_kunit.c} (100%) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index f3d723705879..7b90948666bf 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -3145,7 +3145,7 @@ config TEST_OBJPOOL =20 If unsure, say N. =20 -config INT_POW_TEST +config INT_POW_KUNIT_TEST tristate "Integer exponentiation (int_pow) test" if !KUNIT_ALL_TESTS depends on KUNIT default KUNIT_ALL_TESTS diff --git a/lib/math/Makefile b/lib/math/Makefile index 3ef11305f8d2..d1caba23baa0 100644 --- a/lib/math/Makefile +++ b/lib/math/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_CORDIC) +=3D cordic.o obj-$(CONFIG_PRIME_NUMBERS) +=3D prime_numbers.o obj-$(CONFIG_RATIONAL) +=3D rational.o =20 -obj-$(CONFIG_INT_POW_TEST) +=3D tests/int_pow_kunit.o obj-$(CONFIG_TEST_DIV64) +=3D test_div64.o obj-$(CONFIG_TEST_MULDIV64) +=3D test_mul_u64_u64_div_u64.o -obj-$(CONFIG_RATIONAL_KUNIT_TEST) +=3D rational-test.o + +obj-y +=3D tests/ diff --git a/lib/math/tests/Makefile b/lib/math/tests/Makefile index 6a169123320a..8ce8040e00c5 100644 --- a/lib/math/tests/Makefile +++ b/lib/math/tests/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only =20 -obj-$(CONFIG_INT_POW_TEST) +=3D int_pow_kunit.o +obj-$(CONFIG_INT_POW_KUNIT_TEST) +=3D int_pow_kunit.o +obj-$(CONFIG_RATIONAL_KUNIT_TEST) +=3D rational_kunit.o diff --git a/lib/math/rational-test.c b/lib/math/tests/rational_kunit.c similarity index 100% rename from lib/math/rational-test.c rename to lib/math/tests/rational_kunit.c --=20 2.47.0.338.g60cca15819-goog From nobody Sun Feb 8 06:53:49 2026 Received: from mail-ot1-f74.google.com (mail-ot1-f74.google.com [209.85.210.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48E521F9ECF for ; Mon, 2 Dec 2024 07:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126164; cv=none; b=K3InRyPTypywLQdX43tiK1MJ99Ry0p1uXydAzydSHuJG5nbu5n0gOsFk+C9pMAwNMlydi2KqOXzoxhSjQUU0WNj8mO+U1UfKoeA9BKvLXaYpDpIHjyI/kS4+1YZnvVE9D1qPAoAlszKJZStrY+9m3lPVHmgVq8RrtZURpu4UmQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126164; c=relaxed/simple; bh=nbueRVBos35Jd0w0Fs92uix6M/wXE70O/B7AJCCsung=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XMLXUxqWNSGb55XzN+1P4Dbdq/pPHkyQ52+P4Vi5LBmP2HYWa+VXR0ATxwwXMK3OC1ZzOPk6mmJClikiokKcJcKO9gvX/H4OreQ4TZFVzgi/uJdrENsLCcO8Dlr8fw+6xK8Ohtpp0zWPtu7g0En8XwOXbajmcBobFPkiUW+fOSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=f5wHyPu6; arc=none smtp.client-ip=209.85.210.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="f5wHyPu6" Received: by mail-ot1-f74.google.com with SMTP id 46e09a7af769-71d3fa73518so1428910a34.0 for ; Sun, 01 Dec 2024 23:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733126162; x=1733730962; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=N3kLn7RQs1ULBrkt7yOpn48cLrUbNfXddCOpEZeS+DI=; b=f5wHyPu6mXEzWqYwvl19tbaZ3coGMywcPk0kE43Uha4cijKMxDvl3bftMkSJ83LEeM 8qyymhOWbjm3BnvxffxSc4qAGikkgf5pLgr86Sr3qObc5+u0YIhf5C+JmxzJkteT4iVr 4JatMR3iFzj5HVYtdSFKX3LNhUXUJ+cp4KaOVEuS4TTwdEpN0x06YqRWK1ZzrRVeBNaI DDANqdk2SSfVT4Ab5pCglQ4e3js3WKEA2RXDQ/ea+J31ykK7AI2YA5uWa/Q0VQ8+/xeb MTYDvz8ntZE5KxFTgzgYsTBfzBzA1tNnrWxB610OXqU2GxDZy+KZIAWBFH7u97bUmuY5 gBjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733126162; x=1733730962; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=N3kLn7RQs1ULBrkt7yOpn48cLrUbNfXddCOpEZeS+DI=; b=f0Rdneo2uquQfjUsJo9clwocvG1HKKh/nP3itrSrmgQSNzSu9gt6+EATCLTcP5d13E hcYpO4Rpl9QrlW/H5DJfZkbvBCXZPgaR+rn9Z9XjiBj2vWaKQNPCfo1NLzy87mjEPBYG MTg9x73lINlRscA/Ilyvf1Fz+Eg+ebjqoSbi9qrAYUv6Sha9JfFqSSYK4kVXkb6pEWAv ZDR15fBrpv4Emw4obuEeUGdh8Pc5fzQOB8i97bOCUfIO2KEiViIggdbM8qCd1pjNGjy8 e2RRZxp6ixOgz36f107dQCxrdx5L04VAvFEEqKE3SIJss9cLgQfK8jUbA+0FCsm7CnUU aLVw== X-Forwarded-Encrypted: i=1; AJvYcCU/EJKIUzxdtTpwKpqhYbXxjeJxj0/jlQUE+7m0CNBVpvqWbVQJzK4FJal+2Un1AouTgzLtNp9TZspduZE=@vger.kernel.org X-Gm-Message-State: AOJu0YxB4LFt50W0hYGY+gDoYroexyaneuu9gPZ9YRFKTNseIpYgMgLZ 3uXqS1xvzPv0HNTIAG/rmUKznTcdJ92R/eF+pgOnGJclLXisvI+XqoIFJTx+/e3OsN8y7HiEkoY lmQeHcXoqyA== X-Google-Smtp-Source: AGHT+IFCO19Xvb3y7rt+r6XXmNI1VzwuYgyApTRsR5pWP46AKGk7VjUFzs89sMZSvzb+dXbwlWFlbGI4uMFIVQ== X-Received: from pgbcv13.prod.google.com ([2002:a05:6a02:420d:b0:7fc:3a6b:47f2]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6830:7318:b0:71a:6845:7d7a with SMTP id 46e09a7af769-71d65c7692dmr19101143a34.5.1733126162507; Sun, 01 Dec 2024 23:56:02 -0800 (PST) Date: Mon, 2 Dec 2024 15:55:39 +0800 In-Reply-To: <20241202075545.3648096-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202075545.3648096-1-davidgow@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241202075545.3648096-3-davidgow@google.com> Subject: [PATCH v2 2/6] lib/math: Add int_log test suite From: David Gow To: Andrew Morton , Shuah Khan , Rae Moar , Kees Cook , Geert Uytterhoeven Cc: "=?UTF-8?q?Bruno=20Sobreira=20Fran=C3=A7a?=" , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Stephen Rothwell , Andy Shevchenko , Brendan Higgins , David Gow Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bruno Sobreira Fran=C3=A7a This commit introduces KUnit tests for the intlog2 and intlog10 functions, which compute logarithms in base 2 and base 10, respectively. The tests cover a range of inputs to ensure the correctness of these functions across common and edge cases. Signed-off-by: Bruno Sobreira Fran=C3=A7a Reviewed-by: David Gow [Rebased on top of v6.13-rc1] Signed-off-by: David Gow Reviewed-by: Rae Moar --- lib/Kconfig.debug | 11 +++++ lib/math/tests/Makefile | 1 + lib/math/tests/int_log_kunit.c | 75 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 lib/math/tests/int_log_kunit.c diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 7b90948666bf..8cc8bca6386d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -3161,6 +3161,17 @@ config INT_POW_KUNIT_TEST =20 If unsure, say N =20 +config INT_LOG_KUNIT_TEST + tristate "Integer log (int_log) test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option enables the KUnit test suite for the int_log library= , which + provides two functions to compute the integer logarithm in base = 2 and + base 10, called respectively as intlog2 and intlog10. + + If unsure, say N + endif # RUNTIME_TESTING_MENU =20 config ARCH_USE_MEMTEST diff --git a/lib/math/tests/Makefile b/lib/math/tests/Makefile index 8ce8040e00c5..a1e9ddcbe038 100644 --- a/lib/math/tests/Makefile +++ b/lib/math/tests/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only =20 obj-$(CONFIG_INT_POW_KUNIT_TEST) +=3D int_pow_kunit.o +obj-$(CONFIG_INT_LOG_KUNIT_TEST) +=3D int_log_kunit.o obj-$(CONFIG_RATIONAL_KUNIT_TEST) +=3D rational_kunit.o diff --git a/lib/math/tests/int_log_kunit.c b/lib/math/tests/int_log_kunit.c new file mode 100644 index 000000000000..d750a1df37c1 --- /dev/null +++ b/lib/math/tests/int_log_kunit.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include + +struct test_case_params { + u32 value; + unsigned int expected_result; + const char *name; +}; + + +/* The expected result takes into account the log error */ +static const struct test_case_params intlog2_params[] =3D { + {0, 0, "Log base 2 of 0"}, + {1, 0, "Log base 2 of 1"}, + {2, 16777216, "Log base 2 of 2"}, + {3, 26591232, "Log base 2 of 3"}, + {4, 33554432, "Log base 2 of 4"}, + {8, 50331648, "Log base 2 of 8"}, + {16, 67108864, "Log base 2 of 16"}, + {32, 83886080, "Log base 2 of 32"}, + {U32_MAX, 536870911, "Log base 2 of MAX"}, +}; + +static const struct test_case_params intlog10_params[] =3D { + {0, 0, "Log base 10 of 0"}, + {1, 0, "Log base 10 of 1"}, + {6, 13055203, "Log base 10 of 6"}, + {10, 16777225, "Log base 10 of 10"}, + {100, 33554450, "Log base 10 of 100"}, + {1000, 50331675, "Log base 10 of 1000"}, + {10000, 67108862, "Log base 10 of 10000"}, + {U32_MAX, 161614247, "Log base 10 of MAX"} +}; + +static void get_desc(const struct test_case_params *tc, char *desc) +{ + strscpy(desc, tc->name, KUNIT_PARAM_DESC_SIZE); +} + + +KUNIT_ARRAY_PARAM(intlog2, intlog2_params, get_desc); + +static void intlog2_test(struct kunit *test) +{ + const struct test_case_params *tc =3D (const struct test_case_params *)te= st->param_value; + + KUNIT_EXPECT_EQ(test, tc->expected_result, intlog2(tc->value)); +} + +KUNIT_ARRAY_PARAM(intlog10, intlog10_params, get_desc); + +static void intlog10_test(struct kunit *test) +{ + const struct test_case_params *tc =3D (const struct test_case_params *)te= st->param_value; + + KUNIT_EXPECT_EQ(test, tc->expected_result, intlog10(tc->value)); +} + +static struct kunit_case math_int_log_test_cases[] =3D { + KUNIT_CASE_PARAM(intlog2_test, intlog2_gen_params), + KUNIT_CASE_PARAM(intlog10_test, intlog10_gen_params), + {} +}; + +static struct kunit_suite int_log_test_suite =3D { + .name =3D "math-int_log", + .test_cases =3D math_int_log_test_cases, +}; + +kunit_test_suites(&int_log_test_suite); + +MODULE_DESCRIPTION("math.int_log KUnit test suite"); +MODULE_LICENSE("GPL"); + --=20 2.47.0.338.g60cca15819-goog From nobody Sun Feb 8 06:53:49 2026 Received: from mail-ot1-f73.google.com (mail-ot1-f73.google.com [209.85.210.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D71431F9F44 for ; Mon, 2 Dec 2024 07:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126169; cv=none; b=NI/Jhj1BVbN9e/OjJeA7h5HZLnmrXg9txrOLHyijhU9LT+SN75vMmp+dC3KX3oOXd0hjmPb+QIbWterUL4t4QmA8yEhH7tccYTIuH8QkOBumZozDyZwhiaJOBFLacgA/w9nips/QBreblEPZe279VJtlUdHI0YX24g7QXRRLOxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126169; c=relaxed/simple; bh=PTwZG+xeW4r6TGRZabeBQgiUfqSbeBJL0Rc7EatVp7g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZMbq3QEqcTcramfpSP0DbuF+pZtUUnV4hlEXbbN1s96B90BRmnKN3DwWr67dHm5QZkNkrtgaVj0aKBSmB0j0xlgI/b2uwtcZo4tmzhVp82DuLxJ2ZC5zODY/6IvPy/AL/68FvYeQ3CcjEWU0fS0ECekz4bKqDw7otPjpfawbuXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kl/LlEgv; arc=none smtp.client-ip=209.85.210.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kl/LlEgv" Received: by mail-ot1-f73.google.com with SMTP id 46e09a7af769-71a3da16d58so3962620a34.3 for ; Sun, 01 Dec 2024 23:56:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733126167; x=1733730967; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9jM/9b5jx9DMRfGm5JMb8cVSoHQiHXfvZ3cw4a/aiN8=; b=kl/LlEgvROYQQrghJv4bWwzKd9Ulk2DKld/5+dsgFmMu1ekfdSaG+j0QxX9vcFmEWj 6hYXGByk4vL3ARL3YTYKU26NHT36MDqxOPgHJoX6qqsQDI6ybnEK0rxqencON2MJAZHE dHQSNQZvq/naULRCWowIjflDZpOjpgRkrp/8TJEZoudfVo/PILuoZTFjqfmE7wTjmDP/ NtYV9KWasZNYu62PM24uHgtVbLzPhd5tCpPim2jIteS58J2nNItZpFw5fpxJsuxkcRaR Uw8JgtY2ipLeb+QM+Io7TlFuwtJOdbQiur9F1zGL9PKJHkAUYmLjxxWBWdyMXwY8OZEq do/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733126167; x=1733730967; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9jM/9b5jx9DMRfGm5JMb8cVSoHQiHXfvZ3cw4a/aiN8=; b=q7+7P44T759QQyJM0ZL6PtZUDO6UnAxNmRwLOz8vLDE6nOMMa5dFQmU3LIZ943AarI LQLxMjFuhGAvqXJLR5UJTg6nceuFszndx3ulp0rME9/tZq48MDV+ES+yqOIjzRfxByIG bF1n3edDK/5Ccbe+vVhV5rktdnGd8TJ7fLUSJeCxoC6sxfPWOfRY4PXVGVhgcTwYvUMK 1KkhaFgZC/92DRZsFk/hFCm1ojF8hQK4Bd52l7K+HeL8xQDqqfIbJWknZMV2hLHgFcH8 NdPLyLoOISaWxKnAvBynH4e4j4bv46VAIHmsr41gXOEYtEs1Y5Tfjl5PSROixDvt5RhW CJQQ== X-Forwarded-Encrypted: i=1; AJvYcCVzcq/bjrUj3dV1E8tjTsMA8E7OC1ajujetOTld5o10Pt1qxkr1x5kNJq/kaIPRN7FsiGMQAO6nBo6VDHU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/jPe3Ii8L0bnpf/90LMsZWR4lfkT3d1toqRgwaRKI3Oi/HMHP w6IyfAYSasDLmhwXcW4CjPgcs73ah0FPNQ6lXpON+hIMvUyth4vFEMJ0YvHckzb5Q2DXd4m/3uI 6KzuSuTuq8g== X-Google-Smtp-Source: AGHT+IELB2c5ZfJpNRGUZy9vdSpjB/iCYlrbq6NGv7iDk6gjohS448uqDwSM8kx+wKR/U7gS9yci46f4T4pKiA== X-Received: from pgah11.prod.google.com ([2002:a05:6a02:4e8b:b0:7fc:2b57:38f5]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6830:44a5:b0:71d:3e91:31b0 with SMTP id 46e09a7af769-71d65c78435mr14160469a34.4.1733126166976; Sun, 01 Dec 2024 23:56:06 -0800 (PST) Date: Mon, 2 Dec 2024 15:55:40 +0800 In-Reply-To: <20241202075545.3648096-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202075545.3648096-1-davidgow@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241202075545.3648096-4-davidgow@google.com> Subject: [PATCH v2 3/6] lib: Move KUnit tests into tests/ subdirectory From: David Gow To: Andrew Morton , Shuah Khan , Rae Moar , Kees Cook , Geert Uytterhoeven Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Stephen Rothwell , Andy Shevchenko , Brendan Higgins , "Steven Rostedt (Google)" , Jakub Kicinski , "Masami Hiramatsu (Google)" , David Gow , Vlastimil Babka Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kees Cook Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/. Link: https://lore.kernel.org/lkml/20240720165441.it.320-kees@kernel.org/ [= 1] Signed-off-by: Kees Cook Acked-by: "Steven Rostedt (Google)" Acked-by: Jakub Kicinski Acked-by: "Masami Hiramatsu (Google)" Reviewed-by: David Gow Acked-by: Vlastimil Babka #slab [Rebased onto v6.13-rc1, moved crc16,usercopy,util-macros tests] Signed-off-by: David Gow Reviewed-by: Rae Moar --- MAINTAINERS | 19 ++++++------ lib/Makefile | 39 +------------------------ lib/tests/Makefile | 40 ++++++++++++++++++++++++++ lib/{ =3D> tests}/bitfield_kunit.c | 0 lib/{ =3D> tests}/checksum_kunit.c | 0 lib/{ =3D> tests}/cmdline_kunit.c | 0 lib/{ =3D> tests}/cpumask_kunit.c | 0 lib/{ =3D> tests}/crc16_kunit.c | 0 lib/{ =3D> tests}/fortify_kunit.c | 0 lib/{ =3D> tests}/hashtable_test.c | 0 lib/{ =3D> tests}/is_signed_type_kunit.c | 0 lib/{ =3D> tests}/kunit_iov_iter.c | 0 lib/{ =3D> tests}/list-test.c | 0 lib/{ =3D> tests}/memcpy_kunit.c | 0 lib/{ =3D> tests}/overflow_kunit.c | 0 lib/{ =3D> tests}/siphash_kunit.c | 0 lib/{ =3D> tests}/slub_kunit.c | 0 lib/{ =3D> tests}/stackinit_kunit.c | 0 lib/{ =3D> tests}/string_helpers_kunit.c | 0 lib/{ =3D> tests}/string_kunit.c | 0 lib/{ =3D> tests}/test_bits.c | 0 lib/{ =3D> tests}/test_fprobe.c | 0 lib/{ =3D> tests}/test_hash.c | 0 lib/{ =3D> tests}/test_kprobes.c | 0 lib/{ =3D> tests}/test_linear_ranges.c | 0 lib/{ =3D> tests}/test_list_sort.c | 0 lib/{ =3D> tests}/test_sort.c | 0 lib/{ =3D> tests}/usercopy_kunit.c | 0 lib/{ =3D> tests}/util_macros_kunit.c | 0 29 files changed, 51 insertions(+), 47 deletions(-) rename lib/{ =3D> tests}/bitfield_kunit.c (100%) rename lib/{ =3D> tests}/checksum_kunit.c (100%) rename lib/{ =3D> tests}/cmdline_kunit.c (100%) rename lib/{ =3D> tests}/cpumask_kunit.c (100%) rename lib/{ =3D> tests}/crc16_kunit.c (100%) rename lib/{ =3D> tests}/fortify_kunit.c (100%) rename lib/{ =3D> tests}/hashtable_test.c (100%) rename lib/{ =3D> tests}/is_signed_type_kunit.c (100%) rename lib/{ =3D> tests}/kunit_iov_iter.c (100%) rename lib/{ =3D> tests}/list-test.c (100%) rename lib/{ =3D> tests}/memcpy_kunit.c (100%) rename lib/{ =3D> tests}/overflow_kunit.c (100%) rename lib/{ =3D> tests}/siphash_kunit.c (100%) rename lib/{ =3D> tests}/slub_kunit.c (100%) rename lib/{ =3D> tests}/stackinit_kunit.c (100%) rename lib/{ =3D> tests}/string_helpers_kunit.c (100%) rename lib/{ =3D> tests}/string_kunit.c (100%) rename lib/{ =3D> tests}/test_bits.c (100%) rename lib/{ =3D> tests}/test_fprobe.c (100%) rename lib/{ =3D> tests}/test_hash.c (100%) rename lib/{ =3D> tests}/test_kprobes.c (100%) rename lib/{ =3D> tests}/test_linear_ranges.c (100%) rename lib/{ =3D> tests}/test_list_sort.c (100%) rename lib/{ =3D> tests}/test_sort.c (100%) rename lib/{ =3D> tests}/usercopy_kunit.c (100%) rename lib/{ =3D> tests}/util_macros_kunit.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 1e930c7a58b1..9c35902ffccf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3966,10 +3966,10 @@ F: include/vdso/bits.h F: lib/bitmap-str.c F: lib/bitmap.c F: lib/cpumask.c -F: lib/cpumask_kunit.c F: lib/find_bit.c F: lib/find_bit_benchmark.c F: lib/test_bitmap.c +F: lib/tests/cpumask_kunit.c F: tools/include/linux/bitfield.h F: tools/include/linux/bitmap.h F: tools/include/linux/bits.h @@ -8972,9 +8972,10 @@ L: linux-hardening@vger.kernel.org S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-ne= xt/hardening F: include/linux/fortify-string.h -F: lib/fortify_kunit.c -F: lib/memcpy_kunit.c F: lib/test_fortify/* +F: lib/tests/fortify_kunit.c +F: lib/tests/memcpy_kunit.c +F: scripts/test_fortify.sh K: \bunsafe_memcpy\b K: \b__NO_FORTIFY\b =20 @@ -9655,9 +9656,9 @@ F: include/linux/string.h F: include/linux/string_choices.h F: include/linux/string_helpers.h F: lib/string.c -F: lib/string_kunit.c F: lib/string_helpers.c -F: lib/string_helpers_kunit.c +F: lib/tests/string_helpers_kunit.c +F: lib/tests/string_kunit.c F: scripts/coccinelle/api/string_choices.cocci =20 GENERIC UIO DRIVER FOR PCI DEVICES @@ -12868,7 +12869,7 @@ F: Documentation/trace/kprobes.rst F: include/asm-generic/kprobes.h F: include/linux/kprobes.h F: kernel/kprobes.c -F: lib/test_kprobes.c +F: lib/tests/test_kprobes.c F: samples/kprobes =20 KS0108 LCD CONTROLLER DRIVER @@ -13198,7 +13199,7 @@ M: Mark Brown R: Matti Vaittinen F: include/linux/linear_range.h F: lib/linear_ranges.c -F: lib/test_linear_ranges.c +F: lib/tests/test_linear_ranges.c =20 LINUX FOR POWER MACINTOSH L: linuxppc-dev@lists.ozlabs.org @@ -13326,7 +13327,7 @@ M: David Gow L: linux-kselftest@vger.kernel.org L: kunit-dev@googlegroups.com S: Maintained -F: lib/list-test.c +F: lib/tests/list-test.c =20 LITEX PLATFORM M: Karol Gugala @@ -21490,7 +21491,7 @@ M: Jason A. Donenfeld S: Maintained F: include/linux/siphash.h F: lib/siphash.c -F: lib/siphash_kunit.c +F: lib/tests/siphash_kunit.c =20 SIS 190 ETHERNET DRIVER M: Francois Romieu diff --git a/lib/Makefile b/lib/Makefile index a8155c972f02..3fa31c4c1e57 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -52,9 +52,7 @@ obj-y +=3D bcd.o sort.o parser.o debug_locks.o random32.o= \ percpu-refcount.o rhashtable.o base64.o \ once.o refcount.o rcuref.o usercopy.o errseq.o bucket_locks.o \ generic-radix-tree.o bitmap-str.o -obj-$(CONFIG_STRING_KUNIT_TEST) +=3D string_kunit.o obj-y +=3D string_helpers.o -obj-$(CONFIG_STRING_HELPERS_KUNIT_TEST) +=3D string_helpers_kunit.o obj-y +=3D hexdump.o obj-$(CONFIG_TEST_HEXDUMP) +=3D test_hexdump.o obj-y +=3D kstrtox.o @@ -65,22 +63,17 @@ obj-$(CONFIG_TEST_DHRY) +=3D test_dhry.o obj-$(CONFIG_TEST_FIRMWARE) +=3D test_firmware.o obj-$(CONFIG_TEST_BITOPS) +=3D test_bitops.o CFLAGS_test_bitops.o +=3D -Werror -obj-$(CONFIG_CPUMASK_KUNIT_TEST) +=3D cpumask_kunit.o obj-$(CONFIG_TEST_SYSCTL) +=3D test_sysctl.o -obj-$(CONFIG_TEST_IOV_ITER) +=3D kunit_iov_iter.o -obj-$(CONFIG_HASH_KUNIT_TEST) +=3D test_hash.o obj-$(CONFIG_TEST_IDA) +=3D test_ida.o obj-$(CONFIG_TEST_UBSAN) +=3D test_ubsan.o CFLAGS_test_ubsan.o +=3D $(call cc-disable-warning, vla) CFLAGS_test_ubsan.o +=3D $(call cc-disable-warning, unused-but-set-variabl= e) UBSAN_SANITIZE_test_ubsan.o :=3D y obj-$(CONFIG_TEST_KSTRTOX) +=3D test-kstrtox.o -obj-$(CONFIG_TEST_LIST_SORT) +=3D test_list_sort.o obj-$(CONFIG_TEST_MIN_HEAP) +=3D test_min_heap.o obj-$(CONFIG_TEST_LKM) +=3D test_module.o obj-$(CONFIG_TEST_VMALLOC) +=3D test_vmalloc.o obj-$(CONFIG_TEST_RHASHTABLE) +=3D test_rhashtable.o -obj-$(CONFIG_TEST_SORT) +=3D test_sort.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_key_base.o obj-$(CONFIG_TEST_DYNAMIC_DEBUG) +=3D test_dynamic_debug.o @@ -98,7 +91,6 @@ obj-$(CONFIG_TEST_XARRAY) +=3D test_xarray.o obj-$(CONFIG_TEST_MAPLE_TREE) +=3D test_maple_tree.o obj-$(CONFIG_TEST_PARMAN) +=3D test_parman.o obj-$(CONFIG_TEST_KMOD) +=3D test_kmod.o -obj-$(CONFIG_TEST_RUNTIME) +=3D tests/ obj-$(CONFIG_TEST_DEBUG_VIRTUAL) +=3D test_debug_virtual.o obj-$(CONFIG_TEST_MEMCAT_P) +=3D test_memcat_p.o obj-$(CONFIG_TEST_OBJAGG) +=3D test_objagg.o @@ -107,10 +99,7 @@ obj-$(CONFIG_TEST_MEMINIT) +=3D test_meminit.o obj-$(CONFIG_TEST_LOCKUP) +=3D test_lockup.o obj-$(CONFIG_TEST_HMM) +=3D test_hmm.o obj-$(CONFIG_TEST_FREE_PAGES) +=3D test_free_pages.o -obj-$(CONFIG_KPROBES_SANITY_TEST) +=3D test_kprobes.o obj-$(CONFIG_TEST_REF_TRACKER) +=3D test_ref_tracker.o -CFLAGS_test_fprobe.o +=3D $(CC_FLAGS_FTRACE) -obj-$(CONFIG_FPROBE_SANITY_TEST) +=3D test_fprobe.o obj-$(CONFIG_TEST_OBJPOOL) +=3D test_objpool.o =20 obj-$(CONFIG_TEST_FPU) +=3D test_fpu.o @@ -132,7 +121,7 @@ endif obj-$(CONFIG_DEBUG_INFO_REDUCED) +=3D debug_info.o CFLAGS_debug_info.o +=3D $(call cc-option, -femit-struct-debug-detailed=3D= any) =20 -obj-y +=3D math/ crypto/ +obj-y +=3D math/ crypto/ tests/ =20 obj-$(CONFIG_GENERIC_IOMAP) +=3D iomap.o obj-$(CONFIG_HAS_IOMEM) +=3D iomap_copy.o devres.o @@ -370,32 +359,6 @@ obj-$(CONFIG_OBJAGG) +=3D objagg.o # pldmfw library obj-$(CONFIG_PLDMFW) +=3D pldmfw/ =20 -# KUnit tests -CFLAGS_bitfield_kunit.o :=3D $(DISABLE_STRUCTLEAK_PLUGIN) -obj-$(CONFIG_BITFIELD_KUNIT) +=3D bitfield_kunit.o -obj-$(CONFIG_CHECKSUM_KUNIT) +=3D checksum_kunit.o -obj-$(CONFIG_UTIL_MACROS_KUNIT) +=3D util_macros_kunit.o -obj-$(CONFIG_LIST_KUNIT_TEST) +=3D list-test.o -obj-$(CONFIG_HASHTABLE_KUNIT_TEST) +=3D hashtable_test.o -obj-$(CONFIG_LINEAR_RANGES_TEST) +=3D test_linear_ranges.o -obj-$(CONFIG_BITS_TEST) +=3D test_bits.o -obj-$(CONFIG_CMDLINE_KUNIT_TEST) +=3D cmdline_kunit.o -obj-$(CONFIG_SLUB_KUNIT_TEST) +=3D slub_kunit.o -obj-$(CONFIG_MEMCPY_KUNIT_TEST) +=3D memcpy_kunit.o -obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) +=3D is_signed_type_kunit.o -CFLAGS_overflow_kunit.o =3D $(call cc-disable-warning, tautological-consta= nt-out-of-range-compare) -obj-$(CONFIG_OVERFLOW_KUNIT_TEST) +=3D overflow_kunit.o -CFLAGS_stackinit_kunit.o +=3D $(call cc-disable-warning, switch-unreachabl= e) -obj-$(CONFIG_STACKINIT_KUNIT_TEST) +=3D stackinit_kunit.o -CFLAGS_fortify_kunit.o +=3D $(call cc-disable-warning, unsequenced) -CFLAGS_fortify_kunit.o +=3D $(call cc-disable-warning, stringop-overread) -CFLAGS_fortify_kunit.o +=3D $(call cc-disable-warning, stringop-truncation) -CFLAGS_fortify_kunit.o +=3D $(DISABLE_STRUCTLEAK_PLUGIN) -obj-$(CONFIG_FORTIFY_KUNIT_TEST) +=3D fortify_kunit.o -obj-$(CONFIG_SIPHASH_KUNIT_TEST) +=3D siphash_kunit.o -obj-$(CONFIG_USERCOPY_KUNIT_TEST) +=3D usercopy_kunit.o -obj-$(CONFIG_CRC16_KUNIT_TEST) +=3D crc16_kunit.o - obj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) +=3D devmem_is_allowed.o =20 obj-$(CONFIG_FIRMWARE_TABLE) +=3D fw_table.o diff --git a/lib/tests/Makefile b/lib/tests/Makefile index 8e4f42cb9c54..03bf5a884984 100644 --- a/lib/tests/Makefile +++ b/lib/tests/Makefile @@ -1 +1,41 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for tests of kernel library functions. + +# KUnit tests +CFLAGS_bitfield_kunit.o :=3D $(DISABLE_STRUCTLEAK_PLUGIN) +obj-$(CONFIG_BITFIELD_KUNIT) +=3D bitfield_kunit.o +obj-$(CONFIG_BITS_TEST) +=3D test_bits.o +obj-$(CONFIG_CHECKSUM_KUNIT) +=3D checksum_kunit.o +obj-$(CONFIG_CMDLINE_KUNIT_TEST) +=3D cmdline_kunit.o +obj-$(CONFIG_CPUMASK_KUNIT_TEST) +=3D cpumask_kunit.o +obj-$(CONFIG_CRC16_KUNIT_TEST) +=3D crc16_kunit.o +CFLAGS_fortify_kunit.o +=3D $(call cc-disable-warning, unsequenced) +CFLAGS_fortify_kunit.o +=3D $(call cc-disable-warning, stringop-overread) +CFLAGS_fortify_kunit.o +=3D $(call cc-disable-warning, stringop-truncation) +CFLAGS_fortify_kunit.o +=3D $(DISABLE_STRUCTLEAK_PLUGIN) +obj-$(CONFIG_FORTIFY_KUNIT_TEST) +=3D fortify_kunit.o +CFLAGS_test_fprobe.o +=3D $(CC_FLAGS_FTRACE) +obj-$(CONFIG_FPROBE_SANITY_TEST) +=3D test_fprobe.o +obj-$(CONFIG_HASHTABLE_KUNIT_TEST) +=3D hashtable_test.o +obj-$(CONFIG_HASH_KUNIT_TEST) +=3D test_hash.o +obj-$(CONFIG_TEST_IOV_ITER) +=3D kunit_iov_iter.o +obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) +=3D is_signed_type_kunit.o +obj-$(CONFIG_KPROBES_SANITY_TEST) +=3D test_kprobes.o +obj-$(CONFIG_LIST_KUNIT_TEST) +=3D list-test.o +obj-$(CONFIG_TEST_LIST_SORT) +=3D test_list_sort.o +obj-$(CONFIG_LINEAR_RANGES_TEST) +=3D test_linear_ranges.o +obj-$(CONFIG_MEMCPY_KUNIT_TEST) +=3D memcpy_kunit.o +CFLAGS_overflow_kunit.o =3D $(call cc-disable-warning, tautological-consta= nt-out-of-range-compare) +obj-$(CONFIG_OVERFLOW_KUNIT_TEST) +=3D overflow_kunit.o +obj-$(CONFIG_SIPHASH_KUNIT_TEST) +=3D siphash_kunit.o +obj-$(CONFIG_SLUB_KUNIT_TEST) +=3D slub_kunit.o +obj-$(CONFIG_TEST_SORT) +=3D test_sort.o +CFLAGS_stackinit_kunit.o +=3D $(call cc-disable-warning, switch-unreachabl= e) +obj-$(CONFIG_STACKINIT_KUNIT_TEST) +=3D stackinit_kunit.o +obj-$(CONFIG_STRING_KUNIT_TEST) +=3D string_kunit.o +obj-$(CONFIG_STRING_HELPERS_KUNIT_TEST) +=3D string_helpers_kunit.o +obj-$(CONFIG_USERCOPY_KUNIT_TEST) +=3D usercopy_kunit.o +obj-$(CONFIG_UTIL_MACROS_KUNIT) +=3D util_macros_kunit.o + obj-$(CONFIG_TEST_RUNTIME_MODULE) +=3D module/ diff --git a/lib/bitfield_kunit.c b/lib/tests/bitfield_kunit.c similarity index 100% rename from lib/bitfield_kunit.c rename to lib/tests/bitfield_kunit.c diff --git a/lib/checksum_kunit.c b/lib/tests/checksum_kunit.c similarity index 100% rename from lib/checksum_kunit.c rename to lib/tests/checksum_kunit.c diff --git a/lib/cmdline_kunit.c b/lib/tests/cmdline_kunit.c similarity index 100% rename from lib/cmdline_kunit.c rename to lib/tests/cmdline_kunit.c diff --git a/lib/cpumask_kunit.c b/lib/tests/cpumask_kunit.c similarity index 100% rename from lib/cpumask_kunit.c rename to lib/tests/cpumask_kunit.c diff --git a/lib/crc16_kunit.c b/lib/tests/crc16_kunit.c similarity index 100% rename from lib/crc16_kunit.c rename to lib/tests/crc16_kunit.c diff --git a/lib/fortify_kunit.c b/lib/tests/fortify_kunit.c similarity index 100% rename from lib/fortify_kunit.c rename to lib/tests/fortify_kunit.c diff --git a/lib/hashtable_test.c b/lib/tests/hashtable_test.c similarity index 100% rename from lib/hashtable_test.c rename to lib/tests/hashtable_test.c diff --git a/lib/is_signed_type_kunit.c b/lib/tests/is_signed_type_kunit.c similarity index 100% rename from lib/is_signed_type_kunit.c rename to lib/tests/is_signed_type_kunit.c diff --git a/lib/kunit_iov_iter.c b/lib/tests/kunit_iov_iter.c similarity index 100% rename from lib/kunit_iov_iter.c rename to lib/tests/kunit_iov_iter.c diff --git a/lib/list-test.c b/lib/tests/list-test.c similarity index 100% rename from lib/list-test.c rename to lib/tests/list-test.c diff --git a/lib/memcpy_kunit.c b/lib/tests/memcpy_kunit.c similarity index 100% rename from lib/memcpy_kunit.c rename to lib/tests/memcpy_kunit.c diff --git a/lib/overflow_kunit.c b/lib/tests/overflow_kunit.c similarity index 100% rename from lib/overflow_kunit.c rename to lib/tests/overflow_kunit.c diff --git a/lib/siphash_kunit.c b/lib/tests/siphash_kunit.c similarity index 100% rename from lib/siphash_kunit.c rename to lib/tests/siphash_kunit.c diff --git a/lib/slub_kunit.c b/lib/tests/slub_kunit.c similarity index 100% rename from lib/slub_kunit.c rename to lib/tests/slub_kunit.c diff --git a/lib/stackinit_kunit.c b/lib/tests/stackinit_kunit.c similarity index 100% rename from lib/stackinit_kunit.c rename to lib/tests/stackinit_kunit.c diff --git a/lib/string_helpers_kunit.c b/lib/tests/string_helpers_kunit.c similarity index 100% rename from lib/string_helpers_kunit.c rename to lib/tests/string_helpers_kunit.c diff --git a/lib/string_kunit.c b/lib/tests/string_kunit.c similarity index 100% rename from lib/string_kunit.c rename to lib/tests/string_kunit.c diff --git a/lib/test_bits.c b/lib/tests/test_bits.c similarity index 100% rename from lib/test_bits.c rename to lib/tests/test_bits.c diff --git a/lib/test_fprobe.c b/lib/tests/test_fprobe.c similarity index 100% rename from lib/test_fprobe.c rename to lib/tests/test_fprobe.c diff --git a/lib/test_hash.c b/lib/tests/test_hash.c similarity index 100% rename from lib/test_hash.c rename to lib/tests/test_hash.c diff --git a/lib/test_kprobes.c b/lib/tests/test_kprobes.c similarity index 100% rename from lib/test_kprobes.c rename to lib/tests/test_kprobes.c diff --git a/lib/test_linear_ranges.c b/lib/tests/test_linear_ranges.c similarity index 100% rename from lib/test_linear_ranges.c rename to lib/tests/test_linear_ranges.c diff --git a/lib/test_list_sort.c b/lib/tests/test_list_sort.c similarity index 100% rename from lib/test_list_sort.c rename to lib/tests/test_list_sort.c diff --git a/lib/test_sort.c b/lib/tests/test_sort.c similarity index 100% rename from lib/test_sort.c rename to lib/tests/test_sort.c diff --git a/lib/usercopy_kunit.c b/lib/tests/usercopy_kunit.c similarity index 100% rename from lib/usercopy_kunit.c rename to lib/tests/usercopy_kunit.c diff --git a/lib/util_macros_kunit.c b/lib/tests/util_macros_kunit.c similarity index 100% rename from lib/util_macros_kunit.c rename to lib/tests/util_macros_kunit.c --=20 2.47.0.338.g60cca15819-goog From nobody Sun Feb 8 06:53:49 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C6E51F9F6B for ; Mon, 2 Dec 2024 07:56:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126173; cv=none; b=EZZnyAPX76r44v2umA56t+ReQUgalv4KZ7TmEc2OVJWm5Xo237v6V7vBx4E+KmVk4DWt3kBpFOil4VtW11BSGmcCbQrFc2oWfBCCuWx+o4NizYW+zfjba1LICkU17z8uSxN0MLZJCivlPyBMqJRWOoR8xcLDN495H26Ciyb2cIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126173; c=relaxed/simple; bh=Jt+d7n57NGebk0I59uq9yI2X6UgA6r9S6uq4IT9yFLo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=m2vC7/nYrMKlp+s7dyLFMyBumjnUK1SbTcZgqtwT5Rwa+fAcegueUtjlWtEU65WATiW/r5BExESWh8hBY5ngsiK4WPaRDyksq4ORQbfXOt+ub6cSvKZiYqz2+QSts75YajS+Ao+rRdzhyyTNP/mBavdUqJeOhjKsoRlRryRYhbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VMm62Uhx; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VMm62Uhx" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-215a3fbb8d4so3383875ad.3 for ; Sun, 01 Dec 2024 23:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733126171; x=1733730971; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=pDhlosYfyrccC/tr5/HdB27e44y22hAH/rYm7JsJWfI=; b=VMm62Uhxcq+IpFwQ7wJ52dumUkj+/+eiFcIDi2+MRKv7mkAWcpt+VwgwgFCqf6FUhh liLVuEHvCzJ9fkYKlprIZzsqdLOysyRkx5rvMYUvi5t388cL1J1ZoQly1wxmKNhnpcPj mta6HQlteQgBsVpi7qhycpiJMvmB5v2CCwOTmZpo8HWJwD3Tf6F1+HoFzibQThG4uXHB jBMl/FNMUe8W4kp2PTn0CHRdYpW+4h8WNiFoTQEeeJF2raGyrjRLRJu+xaGtgVS3kVD+ vDLMygthgngOr5POXNcBc6B/y+92u1Bpz5uLJtXXSMCtaQEGm0q7I6GjKI1cOWXNGid8 RUwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733126171; x=1733730971; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pDhlosYfyrccC/tr5/HdB27e44y22hAH/rYm7JsJWfI=; b=gpWYbvi0DHBknBSd2dsHT1d3z7vn5C1SDMXWqSkS6iLu6+1n3IFKlHbHOCC5UmFdpO TGlk3IKd/6yUGj5j+eGsOetRR4FYEa3KNyyfG1IlAaGvACmRGgKq2vStvr+VeUp+8Joi 3jkzsL9kTyOdVs8gwTuXr9hvHIe1MEvz7aq+Z8+z6Tg5uVeLmRXd2/9/byKH1RRvPjnA 31GEonfrb9FtyfZubPbC5d3ZgyKqYC9RrcxWheimQS89KuYBxSrQ4yC8jvmnHnowh/n9 FhBPqt57ogHrOKqX3a33Zv7EbrvuT/kJlkrbv5cQu/BTX2zsxzFVSmQfQ6X7Hao5oCI/ UWjw== X-Forwarded-Encrypted: i=1; AJvYcCUKn6eNdSz1gCyleGZx2tzYG0T8QE4ZHTqt7nDfg4nzxAnhgrl9F3YOGdzC9DKE2K503IA6WyM1Tr6xfYA=@vger.kernel.org X-Gm-Message-State: AOJu0YyKZQIu4S6Bx5+jHmfdpyYNth544NlBg1FE/erfXzhN2PkrljVG TwUYyExAzgwo8+LdaGqLQjtFE17xwn1LGDozcx4rcg5WifYxBKsiaKohovRxfvV/pz7H/uLYpev R1KRGQViKFw== X-Google-Smtp-Source: AGHT+IHCrrtVK1G8Su8f/4p14UuYSnP45OLsJguyMHeQ4fuwQtsxSnbtnu3grfxkzKL1r/cnjFv9nejxcE0tMg== X-Received: from plge12.prod.google.com ([2002:a17:902:cf4c:b0:215:44af:311e]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e801:b0:20c:9936:f0ab with SMTP id d9443c01a7336-21501d57906mr314833595ad.47.1733126171412; Sun, 01 Dec 2024 23:56:11 -0800 (PST) Date: Mon, 2 Dec 2024 15:55:41 +0800 In-Reply-To: <20241202075545.3648096-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202075545.3648096-1-davidgow@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241202075545.3648096-5-davidgow@google.com> Subject: [PATCH v2 4/6] lib/tests/kfifo_kunit.c: add tests for the kfifo structure From: David Gow To: Andrew Morton , Shuah Khan , Rae Moar , Kees Cook , Geert Uytterhoeven Cc: Diego Vieira , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Stephen Rothwell , Andy Shevchenko , Brendan Higgins , David Gow Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Diego Vieira Add KUnit tests for the kfifo data structure. They test the vast majority of macros defined in the kfifo header (include/linux/kfifo.h). These are inspired by the existing tests for the doubly linked list in lib/tests/list-test.c (previously at lib/list-test.c) [1]. Note that this patch depends on the patch that moves the KUnit tests on lib/ into lib/tests/ [2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree= /lib/list-test.c?h=3Dv6.11-rc6 [2] https://lore.kernel.org/all/20240720181025.work.002-kees@kernel.org/ Signed-off-by: Diego Vieira Reviewed-by: David Gow Signed-off-by: David Gow Reviewed-by: Rae Moar --- lib/Kconfig.debug | 14 +++ lib/tests/Makefile | 1 + lib/tests/kfifo_kunit.c | 224 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 lib/tests/kfifo_kunit.c diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 8cc8bca6386d..960c4534dab7 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2681,6 +2681,20 @@ config SYSCTL_KUNIT_TEST =20 If unsure, say N. =20 +config KFIFO_KUNIT_TEST + tristate "KUnit Test for the generic kernel FIFO implementation" if !KUNI= T_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This builds the generic FIFO implementation KUnit test suite. + It tests that the API and basic functionality of the kfifo type + and associated macros. + + For more information on KUnit and unit tests in general please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. + config LIST_KUNIT_TEST tristate "KUnit Test for Kernel Linked-list structures" if !KUNIT_ALL_TES= TS depends on KUNIT diff --git a/lib/tests/Makefile b/lib/tests/Makefile index 03bf5a884984..3cda13c77551 100644 --- a/lib/tests/Makefile +++ b/lib/tests/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_TEST_IOV_ITER) +=3D kunit_iov_iter.o obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) +=3D is_signed_type_kunit.o obj-$(CONFIG_KPROBES_SANITY_TEST) +=3D test_kprobes.o obj-$(CONFIG_LIST_KUNIT_TEST) +=3D list-test.o +obj-$(CONFIG_KFIFO_KUNIT_TEST) +=3D kfifo_kunit.o obj-$(CONFIG_TEST_LIST_SORT) +=3D test_list_sort.o obj-$(CONFIG_LINEAR_RANGES_TEST) +=3D test_linear_ranges.o obj-$(CONFIG_MEMCPY_KUNIT_TEST) +=3D memcpy_kunit.o diff --git a/lib/tests/kfifo_kunit.c b/lib/tests/kfifo_kunit.c new file mode 100644 index 000000000000..a85eedc3195a --- /dev/null +++ b/lib/tests/kfifo_kunit.c @@ -0,0 +1,224 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit test for the generic kernel FIFO implementation. + * + * Copyright (C) 2024 Diego Vieira + */ +#include + +#include + +#define KFIFO_SIZE 32 +#define N_ELEMENTS 5 + +static void kfifo_test_reset_should_clear_the_fifo(struct kunit *test) +{ + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + kfifo_put(&my_fifo, 1); + kfifo_put(&my_fifo, 2); + kfifo_put(&my_fifo, 3); + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 3); + + kfifo_reset(&my_fifo); + + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 0); + KUNIT_EXPECT_TRUE(test, kfifo_is_empty(&my_fifo)); +} + +static void kfifo_test_define_should_define_an_empty_fifo(struct kunit *te= st) +{ + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + KUNIT_EXPECT_TRUE(test, kfifo_initialized(&my_fifo)); + KUNIT_EXPECT_TRUE(test, kfifo_is_empty(&my_fifo)); + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 0); +} + +static void kfifo_test_len_should_ret_n_of_stored_elements(struct kunit *t= est) +{ + u8 buffer1[N_ELEMENTS]; + + for (int i =3D 0; i < N_ELEMENTS; i++) + buffer1[i] =3D i + 1; + + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 0); + + kfifo_in(&my_fifo, buffer1, N_ELEMENTS); + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), N_ELEMENTS); + + kfifo_in(&my_fifo, buffer1, N_ELEMENTS); + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), N_ELEMENTS * 2); + + kfifo_reset(&my_fifo); + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 0); +} + +static void kfifo_test_put_should_insert_and_get_should_pop(struct kunit *= test) +{ + u8 out_data =3D 0; + int processed_elements; + u8 elements[] =3D { 3, 5, 11 }; + + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + // If the fifo is empty, get returns 0 + processed_elements =3D kfifo_get(&my_fifo, &out_data); + KUNIT_EXPECT_EQ(test, processed_elements, 0); + KUNIT_EXPECT_EQ(test, out_data, 0); + + for (int i =3D 0; i < 3; i++) + kfifo_put(&my_fifo, elements[i]); + + for (int i =3D 0; i < 3; i++) { + processed_elements =3D kfifo_get(&my_fifo, &out_data); + KUNIT_EXPECT_EQ(test, processed_elements, 1); + KUNIT_EXPECT_EQ(test, out_data, elements[i]); + } +} + +static void kfifo_test_in_should_insert_multiple_elements(struct kunit *te= st) +{ + u8 in_buffer[] =3D { 11, 25, 65 }; + u8 out_data; + int processed_elements; + + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + kfifo_in(&my_fifo, in_buffer, 3); + + for (int i =3D 0; i < 3; i++) { + processed_elements =3D kfifo_get(&my_fifo, &out_data); + KUNIT_EXPECT_EQ(test, processed_elements, 1); + KUNIT_EXPECT_EQ(test, out_data, in_buffer[i]); + } +} + +static void kfifo_test_out_should_pop_multiple_elements(struct kunit *test) +{ + u8 in_buffer[] =3D { 11, 25, 65 }; + u8 out_buffer[3]; + int copied_elements; + + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + for (int i =3D 0; i < 3; i++) + kfifo_put(&my_fifo, in_buffer[i]); + + copied_elements =3D kfifo_out(&my_fifo, out_buffer, 3); + KUNIT_EXPECT_EQ(test, copied_elements, 3); + + for (int i =3D 0; i < 3; i++) + KUNIT_EXPECT_EQ(test, out_buffer[i], in_buffer[i]); + KUNIT_EXPECT_TRUE(test, kfifo_is_empty(&my_fifo)); +} + +static void kfifo_test_dec_init_should_define_an_empty_fifo(struct kunit *= test) +{ + DECLARE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + INIT_KFIFO(my_fifo); + + // my_fifo is a struct with an inplace buffer + KUNIT_EXPECT_FALSE(test, __is_kfifo_ptr(&my_fifo)); + + KUNIT_EXPECT_TRUE(test, kfifo_initialized(&my_fifo)); +} + +static void kfifo_test_define_should_equal_declare_init(struct kunit *test) +{ + // declare a variable my_fifo of type struct kfifo of u8 + DECLARE_KFIFO(my_fifo1, u8, KFIFO_SIZE); + // initialize the my_fifo variable + INIT_KFIFO(my_fifo1); + + // DEFINE_KFIFO declares the variable with the initial value + // essentially the same as calling DECLARE_KFIFO and INIT_KFIFO + DEFINE_KFIFO(my_fifo2, u8, KFIFO_SIZE); + + // my_fifo1 and my_fifo2 have the same size + KUNIT_EXPECT_EQ(test, sizeof(my_fifo1), sizeof(my_fifo2)); + KUNIT_EXPECT_EQ(test, kfifo_initialized(&my_fifo1), + kfifo_initialized(&my_fifo2)); + KUNIT_EXPECT_EQ(test, kfifo_is_empty(&my_fifo1), + kfifo_is_empty(&my_fifo2)); +} + +static void kfifo_test_alloc_should_initiliaze_a_ptr_fifo(struct kunit *te= st) +{ + int ret; + DECLARE_KFIFO_PTR(my_fifo, u8); + + INIT_KFIFO(my_fifo); + + // kfifo_initialized returns false signaling the buffer pointer is NULL + KUNIT_EXPECT_FALSE(test, kfifo_initialized(&my_fifo)); + + // kfifo_alloc allocates the buffer + ret =3D kfifo_alloc(&my_fifo, KFIFO_SIZE, GFP_KERNEL); + KUNIT_EXPECT_EQ_MSG(test, ret, 0, "Memory allocation should succeed"); + KUNIT_EXPECT_TRUE(test, kfifo_initialized(&my_fifo)); + + // kfifo_free frees the buffer + kfifo_free(&my_fifo); +} + +static void kfifo_test_peek_should_not_remove_elements(struct kunit *test) +{ + u8 out_data; + int processed_elements; + + DEFINE_KFIFO(my_fifo, u8, KFIFO_SIZE); + + // If the fifo is empty, peek returns 0 + processed_elements =3D kfifo_peek(&my_fifo, &out_data); + KUNIT_EXPECT_EQ(test, processed_elements, 0); + + kfifo_put(&my_fifo, 3); + kfifo_put(&my_fifo, 5); + kfifo_put(&my_fifo, 11); + + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 3); + + processed_elements =3D kfifo_peek(&my_fifo, &out_data); + KUNIT_EXPECT_EQ(test, processed_elements, 1); + KUNIT_EXPECT_EQ(test, out_data, 3); + + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 3); + + // Using peek doesn't remove the element + // so the read element and the fifo length + // remains the same + processed_elements =3D kfifo_peek(&my_fifo, &out_data); + KUNIT_EXPECT_EQ(test, processed_elements, 1); + KUNIT_EXPECT_EQ(test, out_data, 3); + + KUNIT_EXPECT_EQ(test, kfifo_len(&my_fifo), 3); +} + +static struct kunit_case kfifo_test_cases[] =3D { + KUNIT_CASE(kfifo_test_reset_should_clear_the_fifo), + KUNIT_CASE(kfifo_test_define_should_define_an_empty_fifo), + KUNIT_CASE(kfifo_test_len_should_ret_n_of_stored_elements), + KUNIT_CASE(kfifo_test_put_should_insert_and_get_should_pop), + KUNIT_CASE(kfifo_test_in_should_insert_multiple_elements), + KUNIT_CASE(kfifo_test_out_should_pop_multiple_elements), + KUNIT_CASE(kfifo_test_dec_init_should_define_an_empty_fifo), + KUNIT_CASE(kfifo_test_define_should_equal_declare_init), + KUNIT_CASE(kfifo_test_alloc_should_initiliaze_a_ptr_fifo), + KUNIT_CASE(kfifo_test_peek_should_not_remove_elements), + {}, +}; + +static struct kunit_suite kfifo_test_module =3D { + .name =3D "kfifo", + .test_cases =3D kfifo_test_cases, +}; + +kunit_test_suites(&kfifo_test_module); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Diego Vieira "); +MODULE_DESCRIPTION("KUnit test for the kernel FIFO"); --=20 2.47.0.338.g60cca15819-goog From nobody Sun Feb 8 06:53:49 2026 Received: from mail-oi1-f202.google.com (mail-oi1-f202.google.com [209.85.167.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEEA81FA152 for ; Mon, 2 Dec 2024 07:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126178; cv=none; b=KvkkQtcxU/Ll5MrpZ6WKnHKp9N3WJ6CRg6ltsX/OczfLsJEPIGBiK2pc7vbT73Zlma2unaAqTwI9BBpZeVQG07lbIIozReAymZSpiOrGlipEFKqofRbpGfrIxPm1z2+fBNwM4QquhZKOQheargiFPGyLKd9YsEgKiin9UzwokBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126178; c=relaxed/simple; bh=X2z1f0sAHqGegyT+sOhSfCIw8EwDqHE3HD8Hl7jRbmw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=C7K2BfiH0i4ER8CpXanORiS+zDNVnNgN/rtool1ePm3QXXUbFO6RhqBOluQnzo62cZhwxwM95+2H4p38F/qVswI6G9V/+vZLddSS6maNht8HWQHHluiUHbBfp5YG92pXKS84KgrQRf/RvRt/MimECLqShD66z8GNINqt5ozM74o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zDRqynqi; arc=none smtp.client-ip=209.85.167.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zDRqynqi" Received: by mail-oi1-f202.google.com with SMTP id 5614622812f47-3ea46b9de38so2845956b6e.3 for ; Sun, 01 Dec 2024 23:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733126176; x=1733730976; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hCHuCWl6FQYdAHHoa+W8WoG3+FHC82MhYNcazj5rwRo=; b=zDRqynqiDB2ERCj7A2/x4gMmPwX48xKxGTeY3dcuDKx9QdjQWp5KFVnZoHe5kU5QUG VVlvg1nT5Fhh4U5ErR89RarHxnGEIroTy8i9ESKir+1qQtsQ82dbBgn0MUcxQFruhDU5 0nYbiX1yLf5jBQEXHjRtP1plzg5fnhN5E/14k7raDuTgWxvS0ODHEhb8ju+Cj5AUOI8U S3Q8P5Ra8bC+54XOt5/Yb3fQ172+8Sg+l7SUHISwKqq2m+QA8a0Z7yZHhVAzSjS0pQ5i b8nYpSuYo9IROTXBrWljkHAeKpLhpb61UNMq+J2HqnjYI3XdtY+NyhLgKTgLdksc48rT VG7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733126176; x=1733730976; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hCHuCWl6FQYdAHHoa+W8WoG3+FHC82MhYNcazj5rwRo=; b=LAS1+hvL5YAm/Jyw0/E9YMXVil6xdQGrKn/h0qyY0Bde0QxE41KfTucJQwqLtzDgB6 fhT93i09EYEAOjC/jz1A8WAhY5peti3QdeX6+O9xxsgP7YL2dQvIg+zas0EoKuqbQAO/ 4A2QP/CMqQqrOJMtIMj7wkGIXFnrb8i4KPnEj5HiOgYxVviUlRN3GZM4tKsGjwjcAyVh 2N0kR9vt1VVYo06e/+kJO1ZKNUMS4lt0lZAY2aGJaVi8GA6yTGkifreWGO9swSI9txlQ IX90CYm2HG5ZajfBYXfiP0DW/Qch9LY8y7KReDGpHGTKV6GYnN+EWVJpEF0h4XxOw1S8 RVoQ== X-Forwarded-Encrypted: i=1; AJvYcCWv5cy3smNK4nljRrdVullbvSwP266gW5dL1CUoGgv5uJ4PAmvO6wJrQSqYKirCFs4maaXBsykiGTEF1pU=@vger.kernel.org X-Gm-Message-State: AOJu0YwjDDRM17gKyKm336jIs58xbzScluDwVSqBbwxugs7MNzKGTmo4 xK1jjHtdpzlWCUsXSMh18evKD86kiNYO1RnSZqy0C6NFnqPFb6WiU7VQFl0o+OnoTlewMImtwLa vVZ/FOkjbig== X-Google-Smtp-Source: AGHT+IGZJ1wGhvA1+Yj7lk7qWxVg4KwKq8/ipRlHpGygo6v/PQu1oTbDr4mRHKzQxU+FmbMhWMCAS76oknmg6g== X-Received: from pfbbw14.prod.google.com ([2002:a05:6a00:408e:b0:720:426b:45fb]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:1801:b0:3e6:1a1b:e4dc with SMTP id 5614622812f47-3ea6dbc9d95mr12251176b6e.18.1733126175869; Sun, 01 Dec 2024 23:56:15 -0800 (PST) Date: Mon, 2 Dec 2024 15:55:42 +0800 In-Reply-To: <20241202075545.3648096-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202075545.3648096-1-davidgow@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241202075545.3648096-6-davidgow@google.com> Subject: [PATCH v2 5/6] unicode: kunit: refactor selftest to kunit tests From: David Gow To: Andrew Morton , Shuah Khan , Rae Moar , Kees Cook , Geert Uytterhoeven Cc: Gabriela Bittencourt , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Stephen Rothwell , Andy Shevchenko , Brendan Higgins , Pedro Orlando , Danilo Pereira , David Gow , Gabriel Krisman Bertazi Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gabriela Bittencourt Refactoring 'test' functions into kunit tests, to test utf-8 support in unicode subsystem. This allows the utf8 tests to be run alongside the KUnit test suite using kunit-tool, quickly compiling and running all desired tests as part of the KUnit test suite, instead of compiling the selftest module and loading it. The refactoring kept the original testing logic intact, while adopting a testing pattern across different kernel modules and leveraging KUnit's benefits. Co-developed-by: Pedro Orlando Signed-off-by: Pedro Orlando Co-developed-by: Danilo Pereira Signed-off-by: Danilo Pereira Signed-off-by: Gabriela Bittencourt Reviewed-by: David Gow Acked-by: Gabriel Krisman Bertazi [rebased on top of 6.13-rc1] Signed-off-by: David Gow Reviewed-by: Rae Moar --- fs/unicode/.kunitconfig | 3 + fs/unicode/Kconfig | 5 +- fs/unicode/Makefile | 2 +- fs/unicode/utf8-norm.c | 2 +- fs/unicode/utf8-selftest.c | 149 +++++++++++++++++-------------------- 5 files changed, 77 insertions(+), 84 deletions(-) create mode 100644 fs/unicode/.kunitconfig diff --git a/fs/unicode/.kunitconfig b/fs/unicode/.kunitconfig new file mode 100644 index 000000000000..62dd5c171f9c --- /dev/null +++ b/fs/unicode/.kunitconfig @@ -0,0 +1,3 @@ +CONFIG_KUNIT=3Dy +CONFIG_UNICODE=3Dy +CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST=3Dy diff --git a/fs/unicode/Kconfig b/fs/unicode/Kconfig index da786a687fdc..4ad2c36550f1 100644 --- a/fs/unicode/Kconfig +++ b/fs/unicode/Kconfig @@ -10,6 +10,7 @@ config UNICODE be a separate loadable module that gets requested only when a file system actually use it. =20 -config UNICODE_NORMALIZATION_SELFTEST +config UNICODE_NORMALIZATION_KUNIT_TEST tristate "Test UTF-8 normalization support" - depends on UNICODE + depends on UNICODE && KUNIT + default KUNIT_ALL_TESTS diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile index e309afe2b2bb..37bbcbc628a1 100644 --- a/fs/unicode/Makefile +++ b/fs/unicode/Makefile @@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),) obj-y +=3D unicode.o endif obj-$(CONFIG_UNICODE) +=3D utf8data.o -obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) +=3D utf8-selftest.o +obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) +=3D utf8-selftest.o =20 unicode-y :=3D utf8-norm.o utf8-core.o =20 diff --git a/fs/unicode/utf8-norm.c b/fs/unicode/utf8-norm.c index 768f8ab448b8..7b998c99c88d 100644 --- a/fs/unicode/utf8-norm.c +++ b/fs/unicode/utf8-norm.c @@ -586,7 +586,7 @@ int utf8byte(struct utf8cursor *u8c) } } =20 -#ifdef CONFIG_UNICODE_NORMALIZATION_SELFTEST_MODULE +#if IS_MODULE(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) EXPORT_SYMBOL_GPL(utf8version_is_supported); EXPORT_SYMBOL_GPL(utf8nlen); EXPORT_SYMBOL_GPL(utf8ncursor); diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 5ddaf27b21a6..9476ab012baa 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -1,35 +1,15 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Kernel module for testing utf-8 support. + * KUnit tests for utf-8 support. * * Copyright 2017 Collabora Ltd. */ =20 -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include #include -#include +#include =20 #include "utf8n.h" =20 -static unsigned int failed_tests; -static unsigned int total_tests; - -#define _test(cond, func, line, fmt, ...) do { \ - total_tests++; \ - if (!cond) { \ - failed_tests++; \ - pr_err("test %s:%d Failed: %s%s", \ - func, line, #cond, (fmt?":":".")); \ - if (fmt) \ - pr_err(fmt, ##__VA_ARGS__); \ - } \ - } while (0) -#define test_f(cond, fmt, ...) _test(cond, __func__, __LINE__, fmt, ##__VA= _ARGS__) -#define test(cond) _test(cond, __func__, __LINE__, "") - static const struct { /* UTF-8 strings in this vector _must_ be NULL-terminated. */ unsigned char str[10]; @@ -167,69 +147,74 @@ static int utf8cursor(struct utf8cursor *u8c, const s= truct unicode_map *um, return utf8ncursor(u8c, um, n, s, (unsigned int)-1); } =20 -static void check_utf8_nfdi(struct unicode_map *um) +static void check_utf8_nfdi(struct kunit *test) { int i; struct utf8cursor u8c; + struct unicode_map *um =3D test->priv; =20 for (i =3D 0; i < ARRAY_SIZE(nfdi_test_data); i++) { int len =3D strlen(nfdi_test_data[i].str); int nlen =3D strlen(nfdi_test_data[i].dec); int j =3D 0; unsigned char c; + int ret; + + KUNIT_EXPECT_EQ(test, utf8len(um, UTF8_NFDI, nfdi_test_data[i].str), nle= n); + KUNIT_EXPECT_EQ(test, utf8nlen(um, UTF8_NFDI, nfdi_test_data[i].str, len= ), + nlen); =20 - test((utf8len(um, UTF8_NFDI, nfdi_test_data[i].str) =3D=3D nlen)); - test((utf8nlen(um, UTF8_NFDI, nfdi_test_data[i].str, len) =3D=3D - nlen)); =20 - if (utf8cursor(&u8c, um, UTF8_NFDI, nfdi_test_data[i].str) < 0) - pr_err("can't create cursor\n"); + ret =3D utf8cursor(&u8c, um, UTF8_NFDI, nfdi_test_data[i].str); + KUNIT_EXPECT_TRUE_MSG(test, ret >=3D 0, "Can't create cursor\n"); =20 while ((c =3D utf8byte(&u8c)) > 0) { - test_f((c =3D=3D nfdi_test_data[i].dec[j]), - "Unexpected byte 0x%x should be 0x%x\n", - c, nfdi_test_data[i].dec[j]); + KUNIT_EXPECT_EQ_MSG(test, c, nfdi_test_data[i].dec[j], + "Unexpected byte 0x%x should be 0x%x\n", + c, nfdi_test_data[i].dec[j]); j++; } =20 - test((j =3D=3D nlen)); + KUNIT_EXPECT_EQ(test, j, nlen); } } =20 -static void check_utf8_nfdicf(struct unicode_map *um) +static void check_utf8_nfdicf(struct kunit *test) { int i; struct utf8cursor u8c; + struct unicode_map *um =3D test->priv; =20 for (i =3D 0; i < ARRAY_SIZE(nfdicf_test_data); i++) { int len =3D strlen(nfdicf_test_data[i].str); int nlen =3D strlen(nfdicf_test_data[i].ncf); int j =3D 0; + int ret; unsigned char c; =20 - test((utf8len(um, UTF8_NFDICF, nfdicf_test_data[i].str) =3D=3D - nlen)); - test((utf8nlen(um, UTF8_NFDICF, nfdicf_test_data[i].str, len) =3D=3D - nlen)); + KUNIT_EXPECT_EQ(test, utf8len(um, UTF8_NFDICF, nfdicf_test_data[i].str), + nlen); + KUNIT_EXPECT_EQ(test, utf8nlen(um, UTF8_NFDICF, nfdicf_test_data[i].str,= len), + nlen); =20 - if (utf8cursor(&u8c, um, UTF8_NFDICF, - nfdicf_test_data[i].str) < 0) - pr_err("can't create cursor\n"); + ret =3D utf8cursor(&u8c, um, UTF8_NFDICF, nfdicf_test_data[i].str); + KUNIT_EXPECT_TRUE_MSG(test, ret >=3D 0, "Can't create cursor\n"); =20 while ((c =3D utf8byte(&u8c)) > 0) { - test_f((c =3D=3D nfdicf_test_data[i].ncf[j]), - "Unexpected byte 0x%x should be 0x%x\n", - c, nfdicf_test_data[i].ncf[j]); + KUNIT_EXPECT_EQ_MSG(test, c, nfdicf_test_data[i].ncf[j], + "Unexpected byte 0x%x should be 0x%x\n", + c, nfdicf_test_data[i].ncf[j]); j++; } =20 - test((j =3D=3D nlen)); + KUNIT_EXPECT_EQ(test, j, nlen); } } =20 -static void check_utf8_comparisons(struct unicode_map *table) +static void check_utf8_comparisons(struct kunit *test) { int i; + struct unicode_map *um =3D test->priv; =20 for (i =3D 0; i < ARRAY_SIZE(nfdi_test_data); i++) { const struct qstr s1 =3D {.name =3D nfdi_test_data[i].str, @@ -237,8 +222,9 @@ static void check_utf8_comparisons(struct unicode_map *= table) const struct qstr s2 =3D {.name =3D nfdi_test_data[i].dec, .len =3D sizeof(nfdi_test_data[i].dec)}; =20 - test_f(!utf8_strncmp(table, &s1, &s2), - "%s %s comparison mismatch\n", s1.name, s2.name); + /* strncmp returns 0 when strings are equal */ + KUNIT_EXPECT_TRUE_MSG(test, utf8_strncmp(um, &s1, &s2) =3D=3D 0, + "%s %s comparison mismatch\n", s1.name, s2.name); } =20 for (i =3D 0; i < ARRAY_SIZE(nfdicf_test_data); i++) { @@ -247,62 +233,65 @@ static void check_utf8_comparisons(struct unicode_map= *table) const struct qstr s2 =3D {.name =3D nfdicf_test_data[i].ncf, .len =3D sizeof(nfdicf_test_data[i].ncf)}; =20 - test_f(!utf8_strncasecmp(table, &s1, &s2), - "%s %s comparison mismatch\n", s1.name, s2.name); + /* strncasecmp returns 0 when strings are equal */ + KUNIT_EXPECT_TRUE_MSG(test, utf8_strncasecmp(um, &s1, &s2) =3D=3D 0, + "%s %s comparison mismatch\n", s1.name, s2.name); } } =20 -static void check_supported_versions(struct unicode_map *um) +static void check_supported_versions(struct kunit *test) { + struct unicode_map *um =3D test->priv; /* Unicode 7.0.0 should be supported. */ - test(utf8version_is_supported(um, UNICODE_AGE(7, 0, 0))); + KUNIT_EXPECT_TRUE(test, utf8version_is_supported(um, UNICODE_AGE(7, 0, 0)= )); =20 /* Unicode 9.0.0 should be supported. */ - test(utf8version_is_supported(um, UNICODE_AGE(9, 0, 0))); + KUNIT_EXPECT_TRUE(test, utf8version_is_supported(um, UNICODE_AGE(9, 0, 0)= )); =20 /* Unicode 1x.0.0 (the latest version) should be supported. */ - test(utf8version_is_supported(um, UTF8_LATEST)); + KUNIT_EXPECT_TRUE(test, utf8version_is_supported(um, UTF8_LATEST)); =20 /* Next versions don't exist. */ - test(!utf8version_is_supported(um, UNICODE_AGE(13, 0, 0))); - test(!utf8version_is_supported(um, UNICODE_AGE(0, 0, 0))); - test(!utf8version_is_supported(um, UNICODE_AGE(-1, -1, -1))); + KUNIT_EXPECT_FALSE(test, utf8version_is_supported(um, UNICODE_AGE(13, 0, = 0))); + KUNIT_EXPECT_FALSE(test, utf8version_is_supported(um, UNICODE_AGE(0, 0, 0= ))); + KUNIT_EXPECT_FALSE(test, utf8version_is_supported(um, UNICODE_AGE(-1, -1,= -1))); } =20 -static int __init init_test_ucd(void) +static struct kunit_case unicode_normalization_test_cases[] =3D { + KUNIT_CASE(check_supported_versions), + KUNIT_CASE(check_utf8_comparisons), + KUNIT_CASE(check_utf8_nfdicf), + KUNIT_CASE(check_utf8_nfdi), + {} +}; + +static int init_test_ucd(struct kunit *test) { - struct unicode_map *um; + struct unicode_map *um =3D utf8_load(UTF8_LATEST); =20 - failed_tests =3D 0; - total_tests =3D 0; + test->priv =3D um; =20 - um =3D utf8_load(UTF8_LATEST); - if (IS_ERR(um)) { - pr_err("%s: Unable to load utf8 table.\n", __func__); - return PTR_ERR(um); - } + KUNIT_EXPECT_EQ_MSG(test, IS_ERR(um), 0, + "%s: Unable to load utf8 table.\n", __func__); =20 - check_supported_versions(um); - check_utf8_nfdi(um); - check_utf8_nfdicf(um); - check_utf8_comparisons(um); - - if (!failed_tests) - pr_info("All %u tests passed\n", total_tests); - else - pr_err("%u out of %u tests failed\n", failed_tests, - total_tests); - utf8_unload(um); return 0; } =20 -static void __exit exit_test_ucd(void) +static void exit_test_ucd(struct kunit *test) { + utf8_unload(test->priv); } =20 -module_init(init_test_ucd); -module_exit(exit_test_ucd); +static struct kunit_suite unicode_normalization_test_suite =3D { + .name =3D "unicode_normalization", + .test_cases =3D unicode_normalization_test_cases, + .init =3D init_test_ucd, + .exit =3D exit_test_ucd, +}; + +kunit_test_suite(unicode_normalization_test_suite); + =20 MODULE_AUTHOR("Gabriel Krisman Bertazi "); -MODULE_DESCRIPTION("Kernel module for testing utf-8 support"); +MODULE_DESCRIPTION("KUnit tests for utf-8 support."); MODULE_LICENSE("GPL"); --=20 2.47.0.338.g60cca15819-goog From nobody Sun Feb 8 06:53:49 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 351DA1F9ED0 for ; Mon, 2 Dec 2024 07:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126182; cv=none; b=EYLcE41sx0i3vOs5uWog1kIGN31LZx2Wu79xmh7msU0t0pQOkSMbYqi0Dxqu7OR2OjrJOQ7ycIWn4qjbg6Alco37mE/w0F6F1LCCg3/4tFGr2XPv/ScsSGCe6iC+3g+0hTgOyLEINCX8k+PEjSxhQS7I/BxybfIWCKh+jxCCxGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733126182; c=relaxed/simple; bh=dYBmGjG7TB2Z2VTBpBo4NiT/h3qkUXZhtiO29o0GA0s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hUMcEeyBq7qOvaqv4cTVYMOd/jW6rl7f+EdHSUkRu1G3Yg7egKPHatTfekI814ECPXMjW7VwHB1l+7W97e9IVPjhl54KplUzRtpdZVQAlgmx0t4lwfsFhMf8c8I/EeGJccYMFuf5QbZlYhetiEplqO5ueVHcEW+Y6XE08rIb/6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UYuT5Omx; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UYuT5Omx" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-7fcd2430636so565910a12.2 for ; Sun, 01 Dec 2024 23:56:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733126180; x=1733730980; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=n/Fu3FFqzv02/EfRgjAc3Ov0VLZBVqY8Qq+UC5wZkhA=; b=UYuT5OmxC2n+QOygsL/0E/GCqYrKMtkLoW+3y5EJOdt5PzyhQpOPknh0j3AsLzzgOn fPfGOC6NagPxmbTy9NzDTZ+UIUD+7Lv6ucWP2V+hbAyakkXryZtJL1zwZa8x+N+0ZLfL +ljBAX7MA/Q1VCqCcvSv777jY1wm1oNwUwkFJIF9kMLs4jrEZGScZEL47YEBp5uHdh3g /VjaGBQHYdJmuf2JbJ5LnN88Mda9M7AbylADSJ1IJlcTadaSnoyDR1U4kDVdesut1h19 EA1o2QebRkol/d1THYET7MBg+x5G+QUkkjZhDLYlMwKQqfNVtW+0CMo+DxiB/HX3fA9A WwEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733126180; x=1733730980; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n/Fu3FFqzv02/EfRgjAc3Ov0VLZBVqY8Qq+UC5wZkhA=; b=V8m4e37KygG4RPPqwT/7dpOqL3rHSkAchcIYD+K7YGH7bkXPwudwAiZv8vmdKSB2xP ZJwmNbl9XrEJJ3c7GJyBMBul6K6qQdUIiI0BBJ+2J1qCCHaeAS28UYYGyRXPzaYNgYTg bt9Pb7UIZuiFBBYol5ZfUC8uE6ArCsAwhzOF3XBm93upThCHm3WPeavBqtVhgNAm2mtS HJMXoMN7+dSTXByrKulWLMnh0pjL0oWGA6VGLHk7QeWiwx+xCR/LtdIvCbhdKBR97+af rfnqmFg383n+aOecLHtD0EjQiqPjEJ8XJg9B+MjLI7dZ9VDruRlMlBy3VfiMI76WRwJz EyKA== X-Forwarded-Encrypted: i=1; AJvYcCVivvdfx5bQIEAaRivWMKqpgjUWFr0K/i6G2Rktc2oarqxLJLBjhcjpt7IBa/KoSHOc4TBrs+56JKUFqNA=@vger.kernel.org X-Gm-Message-State: AOJu0YzcHNAx+X1of27BPopcMeP+iD3n08yuG1C80XINRj4Eg55LwBJY kVuSi/6iYjXX3FCDi+I6q+YSEBL5guqpiqZGnvtKSnKScD9I1H2UZUbbZpvW5XDvCiXAQgPTjI6 2I10UvL44JQ== X-Google-Smtp-Source: AGHT+IF1WZ6Fbz8ZiSSZi2gGcjDGpwxFUu7RJNqMBynLmZMg0QQlHpZzp9a7a3eKlZn/KYL6wsr317d6AQNeHw== X-Received: from pjbtb14.prod.google.com ([2002:a17:90b:53ce:b0:2ea:7174:2101]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:7898:b0:1db:e3f6:55f with SMTP id adf61e73a8af0-1e0e0ac4090mr34409102637.18.1733126180307; Sun, 01 Dec 2024 23:56:20 -0800 (PST) Date: Mon, 2 Dec 2024 15:55:43 +0800 In-Reply-To: <20241202075545.3648096-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202075545.3648096-1-davidgow@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241202075545.3648096-7-davidgow@google.com> Subject: [PATCH v2 6/6] unicode: kunit: change tests filename and path From: David Gow To: Andrew Morton , Shuah Khan , Rae Moar , Kees Cook , Geert Uytterhoeven Cc: Gabriela Bittencourt , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Stephen Rothwell , Andy Shevchenko , Brendan Higgins , Pedro Orlando , Danilo Pereira , David Gow , Gabriel Krisman Bertazi Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gabriela Bittencourt Change utf8 kunit test filename and path to follow the style convention on Documentation/dev-tools/kunit/style.rst Co-developed-by: Pedro Orlando Signed-off-by: Pedro Orlando Co-developed-by: Danilo Pereira Signed-off-by: Danilo Pereira Signed-off-by: Gabriela Bittencourt Reviewed-by: David Gow Acked-by: Gabriel Krisman Bertazi [Rebased, fixed module build (Gabriel Krisman Bertazi)] Signed-off-by: David Gow Reviewed-by: Rae Moar --- fs/unicode/Makefile | 2 +- fs/unicode/{ =3D> tests}/.kunitconfig | 0 fs/unicode/{utf8-selftest.c =3D> tests/utf8_kunit.c} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename fs/unicode/{ =3D> tests}/.kunitconfig (100%) rename fs/unicode/{utf8-selftest.c =3D> tests/utf8_kunit.c} (100%) diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile index 37bbcbc628a1..d95be7fb9f6b 100644 --- a/fs/unicode/Makefile +++ b/fs/unicode/Makefile @@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),) obj-y +=3D unicode.o endif obj-$(CONFIG_UNICODE) +=3D utf8data.o -obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) +=3D utf8-selftest.o +obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) +=3D tests/utf8_kunit.o =20 unicode-y :=3D utf8-norm.o utf8-core.o =20 diff --git a/fs/unicode/.kunitconfig b/fs/unicode/tests/.kunitconfig similarity index 100% rename from fs/unicode/.kunitconfig rename to fs/unicode/tests/.kunitconfig diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/tests/utf8_kunit.c similarity index 100% rename from fs/unicode/utf8-selftest.c rename to fs/unicode/tests/utf8_kunit.c --=20 2.47.0.338.g60cca15819-goog