aboutsummaryrefslogtreecommitdiff
path: root/test_harness
diff options
context:
space:
mode:
Diffstat (limited to 'test_harness')
-rw-r--r--test_harness/fake_env.c35
-rw-r--r--test_harness/test_harness.c26
2 files changed, 27 insertions, 34 deletions
diff --git a/test_harness/fake_env.c b/test_harness/fake_env.c
index 6a32c99..7ac0d9b 100644
--- a/test_harness/fake_env.c
+++ b/test_harness/fake_env.c
@@ -1,26 +1,26 @@
#include "fake_env.h"
-#include <stdlib.h>
#include <assert.h>
+#include <stdlib.h>
struct fakeenv_memseg {
const char* name;
void* segment;
};
-#define DEFINE_MEMORY_SEGMENT(seg, start_addr, end_addr) \
- static __attribute((__section__("fakeenv"))) \
- struct fakeenv_memseg fake_##seg = { \
- .name = #seg, \
- .segment = NULL, \
- }; \
- void* load_fake_##seg##__ () \
- { \
- if (fake_##seg .segment == NULL) { \
- fake_##seg .segment = malloc((end_addr) - (start_addr)); \
- assert(fake_##seg .segment != NULL); \
- } \
- return fake_##seg.segment; \
+#define DEFINE_MEMORY_SEGMENT(seg, start_addr, end_addr) \
+ static __attribute( \
+ (__section__("fakeenv"))) struct fakeenv_memseg fake_##seg = { \
+ .name = #seg, \
+ .segment = NULL, \
+ }; \
+ void* load_fake_##seg##__() \
+ { \
+ if (fake_##seg.segment == NULL) { \
+ fake_##seg.segment = malloc((end_addr) - (start_addr)); \
+ assert(fake_##seg.segment != NULL); \
+ } \
+ return fake_##seg.segment; \
}
extern struct fakeenv_memseg __start_fakeenv;
@@ -28,9 +28,8 @@ extern struct fakeenv_memseg __stop_fakeenv;
void wipeout_fake_env()
{
- for (struct fakeenv_memseg* iter = &__start_fakeenv;
- iter < &__stop_fakeenv;
- ++ iter) {
+ for (struct fakeenv_memseg* iter = &__start_fakeenv; iter < &__stop_fakeenv;
+ ++iter) {
free(iter->segment);
iter->segment = NULL;
}
@@ -46,7 +45,7 @@ DEFINE_MEMORY_SEGMENT(ahb1, 0x40020000, 0x40024400)
DEFINE_MEMORY_SEGMENT(ahb2, 0x48000000, 0x50060C00)
/* System Control Block */
-DEFINE_MEMORY_SEGMENT(scb, 0xE000E008, 0xE000EF04)
+DEFINE_MEMORY_SEGMENT(scb, 0xE000E008, 0xE000EF04)
/* Nested Vector Interrupt Controller (NVIC) */
/* Note that this memory space acutally overlaps with the SCB, but
diff --git a/test_harness/test_harness.c b/test_harness/test_harness.c
index bf9249c..fda623f 100644
--- a/test_harness/test_harness.c
+++ b/test_harness/test_harness.c
@@ -1,24 +1,19 @@
#include "test_harness.h"
-#include "fake_env.h"
#include <assert.h>
+#include <setjmp.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <stdlib.h>
-#include <setjmp.h>
+#include "fake_env.h"
static jmp_buf jmpbuf;
-volatile test_t dummy
- __attribute((__section__("tests")))
- __attribute((__used__)) = {
- "dummy",
- "dummy",
- NULL
-};
+volatile test_t dummy __attribute((__section__("tests")))
+__attribute((__used__)) = {"dummy", "dummy", NULL};
extern unsigned char __data_start;
extern unsigned char _end;
@@ -69,28 +64,27 @@ void test_printp(size_t sz, void* v1, void* v2)
{
fprintf(stderr, "%p == %p\n", v1, v2);
}
-void test_printuc(
- size_t sz, unsigned char v1, unsigned char v2)
+void test_printuc(size_t sz, unsigned char v1, unsigned char v2)
{
- fprintf(stderr, "%02x == %02x\n", (int) v1, (int) v2);
+ fprintf(stderr, "%02x == %02x\n", (int)v1, (int)v2);
}
static int do_fork = 1;
static size_t saved_data_size;
static unsigned char* saved_data = NULL;
-int main(int argc, char** argv) {
+int main(int argc, char** argv)
+{
/* Save all initialized data. */
saved_data_size = &_end - &__data_start;
saved_data = malloc(saved_data_size);
memcpy(saved_data, &__data_start, saved_data_size);
-
if (argc > 1 && strcmp(argv[1], "--nofork") == 0) {
do_fork = 0;
}
- for( ; iter < &__stop_tests; ++ iter) {
+ for (; iter < &__stop_tests; ++iter) {
if (iter->fn_ptr != NULL) {
execute_test(iter);
}