Skip to content

Commit

Permalink
Added a make test command (#12)
Browse files Browse the repository at this point in the history
* Added value type

* Updated to include some unit tests
  • Loading branch information
djthorpe authored Oct 25, 2023
1 parent 43b2923 commit be55d2a
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 105 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build
Testing
doc
opts.h
.vscode

16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,26 @@ endif()

# Define project
project(fuse CXX C ASM)
add_compile_definitions(DEBUG=1)

# Libraries
add_subdirectory(src/fuse)
# TODO!!!
add_compile_definitions(DEBUG)

# Pico libraries
if(${TARGET} STREQUAL "pico")
pico_sdk_init()
endif()

# Libraries
add_subdirectory(src/fuse)
if(${TARGET} STREQUAL "pico")
add_subdirectory(src/picofuse)
endif()

# Tests
include(CTest)

# Tests - fuse
add_subdirectory(tests/fuseapp)
add_subdirectory(tests/app)
add_subdirectory(tests/list)
add_subdirectory(tests/map)
add_subdirectory(tests/panic)
Expand All @@ -59,4 +66,3 @@ if(${TARGET} STREQUAL "pico")
add_subdirectory(tests/temperature)
endif()


5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ PICO_PLATFORM ?= rp2040
PICO_BOARD ?= pico_w

# Targets
all: config picotool src tests examples
all: config picotool test examples

test: config
@make -C ${BUILD_DIR} all test

config: dependencies mkdir
@echo git submodule update pico-sdk
Expand Down
22 changes: 18 additions & 4 deletions include/fuse/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@
#ifndef FUSE_FLAG_H
#define FUSE_FLAG_H

/** @brief Flags for the fuse application
/** @brief Flags for the fuse application or memory pool
*/
typedef enum
{
FUSE_FLAG_NONE = 0, ///< No flags
FUSE_FLAG_DEBUG = 1 << 0, ///< Debug mode - prints out more verbose output

FUSE_NONE = 0x000, ///< No flags
FUSE_FLAG_DEBUG = 0x100, ///< Debug mode - prints out more verbose output
FUSE_CLASS_MASK = 0x0FF, ///< Mask for the class value
FUSE_CLASS_PTR = 0x001, ///< Pointer class
FUSE_CLASS_CSTR = 0x002, ///< Immutable UTF-8 string class
FUSE_CLASS_USTR = 0x002, ///< Mutable UTF-8 string class
FUSE_CLASS_U8 = 0x003, ///< uint8_t class
FUSE_CLASS_U16 = 0x004, ///< uint16_t class
FUSE_CLASS_U32 = 0x005, ///< uint32_t class
FUSE_CLASS_U64 = 0x006, ///< uint64_t class
FUSE_CLASS_S8 = 0x007, ///< int8_t class
FUSE_CLASS_S16 = 0x008, ///< int16_t class
FUSE_CLASS_S32 = 0x009, ///< int32_t class
FUSE_CLASS_S64 = 0x00A, ///< int64_t class
FUSE_CLASS_F32 = 0x00B, ///< float32_t class
FUSE_CLASS_MAP = 0x00C, ///< fuse_map_t class
FUSE_CLASS_LIST = 0x00D ///< fuse_list_t class
} fuse_flag_t;

/** @brief Check for existence of fuse flags
Expand Down
14 changes: 14 additions & 0 deletions tests/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set(NAME "app")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
endif()
File renamed without changes.
16 changes: 6 additions & 10 deletions tests/blink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
set(NAME "blink")
if(${TARGET} STREQUAL "pico")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})
endif()

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
picofuse
)

target_compile_definitions(${NAME} PRIVATE DEBUG=1 PICO_DEBUG_MALLOC=1)

target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
Expand Down
23 changes: 0 additions & 23 deletions tests/fuseapp/CMakeLists.txt

This file was deleted.

16 changes: 9 additions & 7 deletions tests/list/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ set(NAME "list")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
fuse
)
target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
endif()
16 changes: 9 additions & 7 deletions tests/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ set(NAME "map")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
fuse
)
target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
endif()
17 changes: 4 additions & 13 deletions tests/panic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@ set(NAME "panic")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
fuse
)

target_compile_definitions(${NAME} PRIVATE DEBUG=1 PICO_DEBUG_MALLOC=1)

target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME}
picofuse
)
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
Expand Down
13 changes: 4 additions & 9 deletions tests/pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ set(NAME "pool")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)
target_link_libraries(${NAME}
picofuse
)

target_compile_definitions(${NAME} PRIVATE DEBUG=1 PICO_DEBUG_MALLOC=1)

target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
Expand Down
16 changes: 9 additions & 7 deletions tests/random/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ set(NAME "random")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
fuse
)
target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
endif()
14 changes: 4 additions & 10 deletions tests/temperature/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ set(NAME "temperature")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
picofuse
)

target_compile_definitions(${NAME} PRIVATE DEBUG=1 PICO_DEBUG_MALLOC=1)

target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
Expand Down
16 changes: 9 additions & 7 deletions tests/value/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ set(NAME "value")
add_executable(${NAME}
main.c
)
add_test(NAME ${NAME} COMMAND ${NAME})

target_include_directories(${NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/../../include
)

target_link_libraries(${NAME}
fuse
)
target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../include)
target_link_libraries(${NAME} fuse)
if(${TARGET} STREQUAL "pico")
target_link_libraries(${NAME} picofuse)
pico_enable_stdio_usb(${NAME} 1)
pico_enable_stdio_uart(${NAME} 0)
pico_add_extra_outputs(${NAME})
endif()

0 comments on commit be55d2a

Please sign in to comment.