hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/testing/selftests/breakpoints/breakpoint_test.c
....@@ -1,7 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2011 Red Hat, Inc., Frederic Weisbecker <fweisbec@redhat.com>
3
- *
4
- * Licensed under the terms of the GNU GPL License version 2
54 *
65 * Selftests for breakpoints (and more generally the do_debug() path) in x86.
76 */
....@@ -21,6 +20,8 @@
2120
2221 #include "../kselftest.h"
2322
23
+#define COUNT_ISN_BPS 4
24
+#define COUNT_WPS 4
2425
2526 /* Breakpoint access modes */
2627 enum {
....@@ -220,7 +221,7 @@
220221 if (!local && !global)
221222 continue;
222223
223
- for (i = 0; i < 4; i++) {
224
+ for (i = 0; i < COUNT_ISN_BPS; i++) {
224225 dummy_funcs[i]();
225226 check_trapped();
226227 }
....@@ -292,7 +293,7 @@
292293 {
293294 int i;
294295
295
- for (i = 0; i < 4; i++) {
296
+ for (i = 0; i < COUNT_ISN_BPS; i++) {
296297 set_breakpoint_addr(dummy_funcs[i], i);
297298 toggle_breakpoint(i, BP_X, 1, local, global, 1);
298299 ptrace(PTRACE_CONT, child_pid, NULL, 0);
....@@ -314,7 +315,7 @@
314315 else
315316 mode_str = "read";
316317
317
- for (i = 0; i < 4; i++) {
318
+ for (i = 0; i < COUNT_WPS; i++) {
318319 set_breakpoint_addr(&dummy_var[i], i);
319320 toggle_breakpoint(i, mode, len, local, global, 1);
320321 ptrace(PTRACE_CONT, child_pid, NULL, 0);
....@@ -330,8 +331,15 @@
330331 static void launch_tests(void)
331332 {
332333 char buf[1024];
334
+ unsigned int tests = 0;
333335 int len, local, global, i;
334336
337
+ tests += 3 * COUNT_ISN_BPS;
338
+ tests += sizeof(long) / 2 * 3 * COUNT_WPS;
339
+ tests += sizeof(long) / 2 * 3 * COUNT_WPS;
340
+ tests += 2;
341
+ ksft_set_plan(tests);
342
+
335343 /* Instruction breakpoints */
336344 for (local = 0; local < 2; local++) {
337345 for (global = 0; global < 2; global++) {