Skip to content

Commit 3b924ed

Browse files
aescolarAnas Nashif
authored andcommitted
native: coverage exclusions
Just some exclusions to coverage in code which cannot be reached, or can only be reached in error conditions Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 8674471 commit 3b924ed

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

arch/posix/core/swap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void _arch_switch_to_main_thread(struct k_thread *main_thread,
9999
_kernel.current = _kernel.ready_q.cache;
100100

101101
posix_main_thread_start(ready_thread_ptr->thread_idx);
102-
}
102+
} /* LCOV_EXCL_LINE */
103103
#endif
104104

105105
#ifdef CONFIG_SYS_POWER_MANAGEMENT

boards/posix/native_posix/hw_models_top.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "irq_ctrl.h"
1818
#include "posix_board_if.h"
1919
#include "posix_soc_if.h"
20+
#include "posix_arch_internal.h"
2021

2122

2223
static u64_t device_time; /* The actual time as known by the device */
@@ -66,37 +67,29 @@ void hwm_signal_end_handler(int sig)
6667
void hwm_set_sig_handler(void)
6768
{
6869
struct sigaction act;
69-
int e;
7070

7171
act.sa_handler = hwm_signal_end_handler;
72-
e = sigemptyset(&act.sa_mask);
73-
if (e) {
74-
posix_print_error_and_exit("Error on sigemptyset()\n");
75-
}
72+
_SAFE_CALL(sigemptyset(&act.sa_mask));
7673

7774
act.sa_flags = SA_RESETHAND;
7875

79-
e = sigaction(SIGTERM, &act, NULL);
80-
if (e) {
81-
posix_print_error_and_exit("Error on sigaction()\n");
82-
}
83-
e = sigaction(SIGINT, &act, NULL);
84-
if (e) {
85-
posix_print_error_and_exit("Error on sigaction()\n");
86-
}
76+
_SAFE_CALL(sigaction(SIGTERM, &act, NULL));
77+
_SAFE_CALL(sigaction(SIGINT, &act, NULL));
8778
}
8879

8980

9081
static void hwm_sleep_until_next_timer(void)
9182
{
92-
if (next_timer_time >= device_time) {
83+
if (next_timer_time >= device_time) { /* LCOV_EXCL_BR_LINE */
9384
device_time = next_timer_time;
9485
} else {
86+
/* LCOV_EXCL_START */
9587
posix_print_warning("next_timer_time corrupted (%"PRIu64"<= %"
9688
PRIu64", timer idx=%i)\n",
9789
next_timer_time,
9890
device_time,
9991
next_timer_index);
92+
/* LCOV_EXCL_STOP */
10093
}
10194

10295
if (signaled_end || (device_time >= end_of_time)) {
@@ -134,17 +127,19 @@ void hwm_main_loop(void)
134127
while (1) {
135128
hwm_sleep_until_next_timer();
136129

137-
switch (next_timer_index) {
130+
switch (next_timer_index) { /* LCOV_EXCL_BR_LINE */
138131
case HWTIMER:
139132
hwtimer_timer_reached();
140133
break;
141134
case IRQCNT:
142135
hw_irq_ctrl_timer_triggered();
143136
break;
144137
default:
138+
/* LCOV_EXCL_START */
145139
posix_print_error_and_exit(
146140
"next_timer_index corrupted\n");
147141
break;
142+
/* LCOV_EXCL_STOP */
148143
}
149144

150145
hwm_find_next_timer();

boards/posix/native_posix/irq_handler.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ static inline void vector_to_irq(int irq_nbr, int *may_swap)
3636
/* _int_latency_start(); */
3737
_sys_k_event_logger_interrupt();
3838

39-
if (irq_vector_table[irq_nbr].func == NULL) {
39+
if (irq_vector_table[irq_nbr].func == NULL) { /* LCOV_EXCL_BR_LINE */
40+
/* LCOV_EXCL_START */
4041
posix_print_error_and_exit("Received irq %i without a "
4142
"registered handler\n",
4243
irq_nbr);
44+
/* LCOV_EXCL_STOP */
4345
} else {
4446
if (irq_vector_table[irq_nbr].flags & ISR_FLAG_DIRECT) {
4547
*may_swap |= ((direct_irq_f_ptr)
@@ -129,10 +131,12 @@ void posix_irq_handler_im_from_sw(void)
129131
* handler
130132
*/
131133
if (hw_irq_ctrl_get_highest_prio_irq() != -1) {
132-
if (!posix_is_cpu_running()) {
133-
posix_print_error_and_exit("programming error: "
134-
"nrf_irq_cont_handler_irq_im_from_sw() "
135-
"called from a HW model thread\n");
134+
if (!posix_is_cpu_running()) { /* LCOV_EXCL_BR_LINE */
135+
/* LCOV_EXCL_START */
136+
posix_print_error_and_exit("programming error: %s "
137+
"called from a HW model thread\n",
138+
__func__);
139+
/* LCOV_EXCL_STOP */
136140
}
137141
posix_irq_handler();
138142
}
@@ -223,11 +227,6 @@ int _arch_irq_is_enabled(unsigned int irq)
223227
return hw_irq_ctrl_is_irq_enabled(irq);
224228
}
225229

226-
void _arch_isr_direct_header(void)
227-
{
228-
/* Nothing to be done */
229-
}
230-
231230
int posix_get_current_irq(void)
232231
{
233232
return currently_running_irq;

0 commit comments

Comments
 (0)