Commit 4b18cb3f authored by David Gow's avatar David Gow Committed by Peter Zijlstra
Browse files

perf/hw_breakpoint: test: Skip the test if dependencies unmet



Running the test currently fails on non-SMP systems, despite being
enabled by default. This means that running the test with:

 ./tools/testing/kunit/kunit.py run --arch x86_64 hw_breakpoint

results in every hw_breakpoint test failing with:

 # test_one_cpu: failed to initialize: -22
 not ok 1 - test_one_cpu

Instead, use kunit_skip(), which will mark the test as skipped, and give
a more comprehensible message:

 ok 1 - test_one_cpu # SKIP not enough cpus

This makes it more obvious that the test is not suited to the test
environment, and so wasn't run, rather than having run and failed.

Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
Acked-by: default avatarMarco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20221026141040.1609203-1-davidgow@google.com
parent 30a0b95b
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -295,11 +295,11 @@ static int test_init(struct kunit *test)
{
{
	/* Most test cases want 2 distinct CPUs. */
	/* Most test cases want 2 distinct CPUs. */
	if (num_online_cpus() < 2)
	if (num_online_cpus() < 2)
		return -EINVAL;
		kunit_skip(test, "not enough cpus");


	/* Want the system to not use breakpoints elsewhere. */
	/* Want the system to not use breakpoints elsewhere. */
	if (hw_breakpoint_is_used())
	if (hw_breakpoint_is_used())
		return -EBUSY;
		kunit_skip(test, "hw breakpoint already in use");


	return 0;
	return 0;
}
}