initial commit
This commit is contained in:
42
source/test/firmware/kernel/ringbuffer/Makefile
Executable file
42
source/test/firmware/kernel/ringbuffer/Makefile
Executable file
@@ -0,0 +1,42 @@
|
||||
include ../../../../../config/make/rules.mk
|
||||
|
||||
TEST_MAINFILE = $(TEST_EXE_DIR)cunit_ringbuffer
|
||||
TEST_INCLUDES = \
|
||||
-I . \
|
||||
-I /usr/include \
|
||||
-I $(ROOT_DIR)/source/firmware/kernel
|
||||
|
||||
TEST_SOURCES = \
|
||||
$(ROOT_DIR)/source/firmware/kernel/ringbuffer.c \
|
||||
$(ROOT_DIR)/source/test/firmware/kernel/ringbuffer/cunit_ringbuffer.c
|
||||
|
||||
TEST_OBJECTS = $(TEST_SOURCES:$(SRC_DIR)/%.c=$(TEST_OBJ_DIR)/%.o)
|
||||
TEST_DEPS = $(TEST_SOURCES:$(SRC_DIR)/%.c=$(TEST_OBJ_DIR)/%.d)
|
||||
|
||||
TEST_CFLAGS = \
|
||||
$(CFLAGS) \
|
||||
$(TEST_INCLUDES)
|
||||
|
||||
TEST_LDFLAGS = \
|
||||
$(LDFLAGS) \
|
||||
-lcunit
|
||||
|
||||
all: $(TEST_MAINFILE)
|
||||
|
||||
clean:
|
||||
-rm -f $(TEST_OBJECTS) \
|
||||
$(TEST_DEPS) \
|
||||
$(TEST_MAINFILE)
|
||||
|
||||
$(TEST_MAINFILE): $(TEST_OBJECTS)
|
||||
@$(MKDIR) $(TEST_EXE_DIR)
|
||||
$(NATIVE_CC) $(TEST_CFLAGS) $(TEST_LDFLAGS) $(TEST_OBJECTS) -o $(TEST_MAINFILE)
|
||||
|
||||
$(TEST_OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@$(MKDIR) $(dir $@)
|
||||
$(call maketestdep,$<,$@,$(subst .o,.d,$@))
|
||||
$(NATIVE_CC) $(TEST_CFLAGS) -c $< -o $@
|
||||
|
||||
ifneq "$(MAKECMDGOALS)" "clean"
|
||||
-include $(TEST_DEPS)
|
||||
endif
|
14
source/test/firmware/kernel/ringbuffer/cpu.h
Executable file
14
source/test/firmware/kernel/ringbuffer/cpu.h
Executable file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* cpu.h
|
||||
*
|
||||
* Created on: Nov 3, 2013
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef CPU_H_
|
||||
#define CPU_H_
|
||||
|
||||
#define disable_irq()
|
||||
#define enable_irq()
|
||||
|
||||
#endif /* CPU_H_ */
|
67
source/test/firmware/kernel/ringbuffer/cunit_ringbuffer.c
Executable file
67
source/test/firmware/kernel/ringbuffer/cunit_ringbuffer.c
Executable file
@@ -0,0 +1,67 @@
|
||||
#include <CUnit/CUnit.h>
|
||||
#include <CUnit/Basic.h>
|
||||
|
||||
#if 0
|
||||
#include <CUnit/Automated.h>
|
||||
#endif
|
||||
|
||||
#include "ringbuffer.h"
|
||||
|
||||
static int init_suite(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int clean_suite(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* DUT */
|
||||
static char mem[10];
|
||||
static struct ringbuffer rb = {
|
||||
mem,
|
||||
mem,
|
||||
mem,
|
||||
sizeof(mem),
|
||||
0
|
||||
};
|
||||
|
||||
static void test_ringbuffer_size(void)
|
||||
{
|
||||
char str[] = "0123456789ABCDEFGHI";
|
||||
CU_ASSERT(sizeof(mem) == ringbuffer_write(&rb, str, sizeof(str)));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* test suite section */
|
||||
CU_pSuite suite = NULL;
|
||||
if(CUE_SUCCESS != CU_initialize_registry())
|
||||
goto exit_2;
|
||||
suite = CU_add_suite("list test suite", init_suite, clean_suite);
|
||||
if(NULL == suite)
|
||||
goto exit_1;
|
||||
|
||||
/* test case section */
|
||||
if(
|
||||
NULL == CU_add_test(suite, "ringbuffer size", test_ringbuffer_size)
|
||||
)
|
||||
goto exit_1;
|
||||
|
||||
/* basic interface using tests */
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
CU_basic_show_failures(CU_get_failure_list());
|
||||
|
||||
#if 0
|
||||
/* automated interface using tests */
|
||||
CU_automated_run_tests();
|
||||
CU_list_tests_to_file();
|
||||
#endif
|
||||
|
||||
exit_1:
|
||||
CU_cleanup_registry();
|
||||
exit_2:
|
||||
return CU_get_error();
|
||||
}
|
Reference in New Issue
Block a user