More descriptive errors from AVR test cases
diff --git a/tests/fuzztest/fuzztest.c b/tests/fuzztest/fuzztest.c
index 6652888..fac148c 100644
--- a/tests/fuzztest/fuzztest.c
+++ b/tests/fuzztest/fuzztest.c
@@ -513,10 +513,11 @@
/* Run in stand-alone mode */
random_seed = atol(argv[1]);
iterations = (argc >= 3) ? atol(argv[2]) : 10000;
- fprintf(stderr, "Random seed: %u, iterations: %d\n", (unsigned)random_seed, iterations);
+ fprintf(stderr, "Random seed: %lu, iterations: %d\n", (unsigned long)random_seed, iterations);
for (i = 0; i < iterations; i++)
{
+ fprintf(stderr, "Iteration %d/%d\n", i, iterations);
run_iteration();
}
}
diff --git a/tests/site_scons/platforms/avr/avr.py b/tests/site_scons/platforms/avr/avr.py
index 553339c..4621a32 100644
--- a/tests/site_scons/platforms/avr/avr.py
+++ b/tests/site_scons/platforms/avr/avr.py
@@ -11,7 +11,7 @@
env.Replace(TEST_RUNNER = "build/run_test")
env.Append(CFLAGS = "-mmcu=atmega1284 -Dmain=app_main -Os")
env.Append(CXXFLAGS = "-mmcu=atmega1284 -Dmain=app_main -Os")
- env.Append(CPPDEFINES = {'PB_CONVERT_DOUBLE_FLOAT': 1, 'UNITTESTS_SHORT_MSGS': 1})
+ env.Append(CPPDEFINES = {'PB_CONVERT_DOUBLE_FLOAT': 1, 'UNITTESTS_SHORT_MSGS': 1, '__ASSERT_USE_STDERR': 1})
env.Append(LINKFLAGS = "-mmcu=atmega1284")
env.Append(LINKFLAGS = "build/avr_io.o -Wl,-Map,avr.map")
avr_io = env.Object("build/avr_io.o", "site_scons/platforms/avr/avr_io.c")
diff --git a/tests/site_scons/platforms/avr/avr_io.c b/tests/site_scons/platforms/avr/avr_io.c
index eff00da..581a722 100644
--- a/tests/site_scons/platforms/avr/avr_io.c
+++ b/tests/site_scons/platforms/avr/avr_io.c
@@ -3,6 +3,7 @@
*/
#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
@@ -29,6 +30,15 @@
return UDR0;
}
+void abort(void)
+{
+ fprintf(stderr, "abort() called\n");
+ DDRB = 3;
+ PORTB = 1;
+ cli();
+ while (1) sleep_mode();
+}
+
FILE uart_str = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
int main(void)
@@ -39,6 +49,9 @@
UBRR0 = (8000000 / (16UL * 9600)) - 1; /* 9600 bps with default 8 MHz clock */
UCSR0B = _BV(TXEN0) | _BV(RXEN0);
+ /* This should be enough for the max stack usage in test cases */
+ __malloc_margin = 2048;
+
stdout = stdin = stderr = &uart_str;
fread((char*)&g_args, 1, sizeof(g_args), stdin);
@@ -47,9 +60,14 @@
DDRB = 3;
if (status)
- PORTB = 1;
+ {
+ fprintf(stderr, "Error exit: %d\n", status);
+ PORTB = 1; // PB0 indicates error
+ }
else
- PORTB = 2;
+ {
+ PORTB = 2; // PB1 indicates success
+ }
cli();
sleep_mode();