Commit 116998c6 authored by Daniel Leung's avatar Daniel Leung Committed by Anas Nashif
Browse files

tests: kernel: print FAILED when wrong faults caught



For some kernel tests, faults and exceptions are expected.
They are caught and the test would continue if the reasons
for faults are as expected. However, when the unexpected
reasons are encountered, the code simply prints a message
and calls k_fatal_halt(). When running under twister,
these messages are not the expected failed messages so
twister will spin till timeout although the execution
has already been halted. This adds another printk() before
halt to signal twister that the test has failed and bails
early.

Signed-off-by: default avatarDaniel Leung <daniel.leung@intel.com>
parent d650d76d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,17 +52,20 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf)

	if (expected_reason == -1) {
		printk("Was not expecting a crash\n");
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}

	if (k_current_get() != &alt_thread) {
		printk("Wrong thread crashed\n");
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}

	if (reason != expected_reason) {
		printk("Wrong crash type got %d expected %d\n", reason,
		       expected_reason);
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}

+2 −0
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf)

	if (expected_reason == -1) {
		printk("Was not expecting a crash\n");
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}

	if (reason != expected_reason) {
		printk("Wrong crash type got %d expected %d\n", reason,
		       expected_reason);
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}

+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf)
		ztest_test_pass();
	} else {
		printk("Unexpected fault during test");
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}
}
+2 −1
Original line number Diff line number Diff line
@@ -38,7 +38,8 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf)
		expect_fault = false;
		ztest_test_pass();
	} else {
		printk("Unexpected fault during test");
		printk("Unexpected fault during test\n");
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}
}
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf)
		post_fatal_error_handler(reason, pEsf);
	} else {
		printk("fatal error was unexpected, aborting\n");
		printk("PROJECT EXECUTION FAILED\n");
		k_fatal_halt(reason);
	}
}
Loading