lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230719-nolibc-ktap-tmp-v1-1-930bd0c52ff1@weissschuh.net>
Date:   Wed, 19 Jul 2023 00:00:39 +0200
From:   Thomas Weißschuh <linux@...ssschuh.net>
To:     Willy Tarreau <w@....eu>
Cc:     Zhangjin Wu <falcon@...ylab.org>, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org,
        Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH RFC 1/7] selftests/nolibc: statically calculate number of
 testsuites

This makes it slightly nicer to report the number of suites.

Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
 tools/testing/selftests/nolibc/nolibc-test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 03b1d30f5507..698af242d3e4 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -45,6 +45,8 @@
 #define SINT_MAX_OF_TYPE(type) (((type)1 << (sizeof(type) * 8 - 2)) - (type)1 + ((type)1 << (sizeof(type) * 8 - 2)))
 #define SINT_MIN_OF_TYPE(type) (-SINT_MAX_OF_TYPE(type) - 1)
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
 /* will be used to test initialization of environ */
 static char **test_envp;
 
@@ -1184,7 +1186,6 @@ static const struct test test_names[] = {
 	{ .name = "stdlib",     .func = run_stdlib     },
 	{ .name = "vfprintf",   .func = run_vfprintf   },
 	{ .name = "protection", .func = run_protection },
-	{ 0 }
 };
 
 int is_setting_valid(char *test)
@@ -1259,7 +1260,7 @@ int main(int argc, char **argv, char **envp)
 			if (colon)
 				*(colon++) = '\0';
 
-			for (idx = 0; test_names[idx].name; idx++) {
+			for (idx = 0; idx < ARRAY_SIZE(test_names); idx++) {
 				if (strcmp(test, test_names[idx].name) == 0)
 					break;
 			}
@@ -1305,7 +1306,7 @@ int main(int argc, char **argv, char **envp)
 		} while (test && *test);
 	} else {
 		/* no test mentioned, run everything */
-		for (idx = 0; test_names[idx].name; idx++) {
+		for (idx = 0; idx < ARRAY_SIZE(test_names); idx++) {
 			printf("Running test '%s'\n", test_names[idx].name);
 			err = test_names[idx].func(min, max);
 			ret += err;

-- 
2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ