Skip to content

Commit

Permalink
Fixing failure of unit tests
Browse files Browse the repository at this point in the history
1 - Existing IPv4 tests do not like automatic IPv6 traffic. Disabling ND
in unit test mode

2 - Timer test assumed there were only 3 timers started up by the stack
during initialization. This number has been increased to 4 (since we
added a new timer for router advertisements delivery).
  • Loading branch information
Daniele Lacamera committed Jan 20, 2015
1 parent 5cbb748 commit d742acc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions modules/pico_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,12 +1138,15 @@ int pico_ipv6_link_add(struct pico_device *dev, struct pico_ip6 address, struct
* the solicited-node multicast address corresponding to each of the IP
* addresses assigned to the interface. (RFC 4861 $7.2.1)
*/

#ifndef UNIT_TEST
/* Duplicate Address Detection */
if (!pico_ipv6_is_unspecified(address.addr)) {
new->istentative = 1;
pico_icmp6_neighbor_solicitation(dev, &address, PICO_ICMP6_ND_DAD);
pico_timer_add(pico_rand() % PICO_ICMP6_MAX_RTR_SOL_DELAY, &pico_ipv6_nd_dad, &new->address);
}
#endif

pico_ipv6_to_string(ipstr, new->address.addr);
dbg("Assigned ipv6 %s to device %s\n", ipstr, new->dev->name);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/unit_timer.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#define EXISTING_TIMERS 4

START_TEST (test_timers)
{
Expand All @@ -11,15 +11,15 @@ START_TEST (test_timers)
}
for (i = 0; i < 128; i++) {
fail_if(i + 1 > Timers->n);
fail_unless(Timers->top[i + 3].tmr == T[i]);
fail_unless(Timers->top[i + EXISTING_TIMERS].tmr == T[i]);
fail_unless(T[i]->timer == (0xff00 + i));
fail_unless(T[i]->arg == (0xaa00 + i));
}
for (i = 0; i < 128; i++) {
printf("Deleting timer %d \n", i );
pico_timer_cancel(T[i]);
printf("Deleted timer %d \n", i );
fail_unless(Timers->top[i + 3].tmr == NULL);
fail_unless(Timers->top[i + EXISTING_TIMERS].tmr == NULL);
}
pico_stack_tick();
pico_stack_tick();
Expand Down

0 comments on commit d742acc

Please sign in to comment.