Testing
Update tests so it uses llfs data and lffs
This commit is contained in:
@@ -23,9 +23,11 @@ const char* TAG = "llfs";
|
|||||||
static size_t file_count = 0; // Cache for the number of files in the filesystem
|
static size_t file_count = 0; // Cache for the number of files in the filesystem
|
||||||
static FILE* file_table[POSIX_MAX_FILES];
|
static FILE* file_table[POSIX_MAX_FILES];
|
||||||
|
|
||||||
|
#ifndef TESTING
|
||||||
static int new_file_table_entry(void);
|
static int new_file_table_entry(void);
|
||||||
static int free_file_table_entry(int file_id);
|
static int free_file_table_entry(int file_id);
|
||||||
static FILE* file_id_to_stream(int file_id);
|
static FILE* file_id_to_stream(int file_id);
|
||||||
|
#endif
|
||||||
static uint8_t file_ext_cmp(const char* filename, const char* ext);
|
static uint8_t file_ext_cmp(const char* filename, const char* ext);
|
||||||
|
|
||||||
int8_t llfs_init(void) {
|
int8_t llfs_init(void) {
|
||||||
@@ -141,6 +143,7 @@ size_t llfs_file_count(void) {
|
|||||||
return file_count;
|
return file_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TESTING
|
||||||
/**
|
/**
|
||||||
* @brief Newlib open implementation
|
* @brief Newlib open implementation
|
||||||
*
|
*
|
||||||
@@ -409,6 +412,7 @@ static FILE* file_id_to_stream(int file_id) {
|
|||||||
}
|
}
|
||||||
return file_table[file_id];
|
return file_table[file_id];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if a filename ends with a given extension
|
* @brief Check if a filename ends with a given extension
|
||||||
@@ -433,3 +437,4 @@ static uint8_t file_ext_cmp(const char* const filename, const char* const ext) {
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
#define LOGGER_LEVEL_ALL
|
#define LOGGER_LEVEL_ALL
|
||||||
#include "tftp.h"
|
#include "tftp.h"
|
||||||
|
#ifdef TESTING
|
||||||
|
#include "mocs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define VIRT_INDEX_TXT 0
|
#define VIRT_INDEX_TXT 0
|
||||||
#define VIRT_IMAGE_BMP 1
|
#define VIRT_IMAGE_BMP 1
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ target_sources(tests
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
${TEST_SOURCES}
|
${TEST_SOURCES}
|
||||||
../project/Core/Src/tftp.c
|
../project/Core/Src/tftp.c
|
||||||
|
../project/Core/Src/llfs_data.c
|
||||||
|
../project/Core/Src/llfs.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(tests PRIVATE $<$<CONFIG:Debug>:
|
target_compile_options(tests PRIVATE $<$<CONFIG:Debug>:
|
||||||
|
|||||||
114
tests/mocs.c
114
tests/mocs.c
@@ -1,14 +1,7 @@
|
|||||||
|
#include "mocs.h"
|
||||||
#include "tftp.h"
|
#include "tftp.h"
|
||||||
|
|
||||||
struct llfs_data_file llfs_root = {
|
|
||||||
.data = NULL,
|
|
||||||
.len = 0,
|
|
||||||
.name = "root",
|
|
||||||
.next = NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
void tftp_cleanup(void) {
|
void tftp_cleanup(void) {
|
||||||
|
|
||||||
}
|
}
|
||||||
uint32_t logger_get_timestamp(void) {
|
uint32_t logger_get_timestamp(void) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -19,28 +12,33 @@ int tftp_init(struct tftp_context* context) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font) {
|
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT* font) {
|
||||||
UNUSED(text);
|
|
||||||
UNUSED(x_pos);
|
|
||||||
UNUSED(y_pos);
|
|
||||||
UNUSED(color);
|
UNUSED(color);
|
||||||
UNUSED(bg_color);
|
UNUSED(bg_color);
|
||||||
UNUSED(font);
|
UNUSED(font);
|
||||||
|
|
||||||
|
printf("lcd_display_text @ %d %d with color 0x%08X bg color 0x%08X\n%s\n", x_pos, y_pos, color, bg_color, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_draw_img_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos) {
|
||||||
|
printf("lcd_draw_img_from_fs\n%s @%d %d\n", filename, x_pos, y_pos);
|
||||||
|
}
|
||||||
|
void lcd_draw_gif_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos) {
|
||||||
|
printf("lcd_draw_gif_from_fs\n%s @%d %d\n", filename, x_pos, y_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_clear_images(void) {
|
void lcd_clear_images(void) {
|
||||||
|
printf("lcd_clear_images\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_clear_text(void) {
|
void lcd_clear_text(void) {
|
||||||
|
printf("lcd_clear_text\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos) {
|
void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos) {
|
||||||
UNUSED(bmp_buff);
|
UNUSED(bmp_buff);
|
||||||
UNUSED(x_pos);
|
|
||||||
UNUSED(y_pos);
|
printf("lcd_draw_bmp_img @ %d %d\n", x_pos, y_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_draw_gif(uint8_t* gif_buff, size_t len, uint32_t x_pos, uint32_t y_pos) {
|
void lcd_draw_gif(uint8_t* gif_buff, size_t len, uint32_t x_pos, uint32_t y_pos) {
|
||||||
@@ -48,10 +46,84 @@ void lcd_draw_gif(uint8_t* gif_buff, size_t len, uint32_t x_pos, uint32_t y_pos)
|
|||||||
UNUSED(len);
|
UNUSED(len);
|
||||||
UNUSED(x_pos);
|
UNUSED(x_pos);
|
||||||
UNUSED(y_pos);
|
UNUSED(y_pos);
|
||||||
|
|
||||||
|
printf("lcd_draw_gif @ %d %d\n", x_pos, y_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
llfs_file_t* llfs_next_file(void** mem, char* filter) {
|
struct tcp_pcb* tcp_new(void) {
|
||||||
UNUSED(mem);
|
|
||||||
UNUSED(filter);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
err_t tcp_bind(void *pcb, void *ipaddr, uint16_t port) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(ipaddr);
|
||||||
|
UNUSED(port);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tcp_pcb* tcp_listen(void *pcb) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_accept(void *pcb, tcp_accept_fn arg) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_arg(void* pcb, void* arg) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(arg);
|
||||||
|
}
|
||||||
|
void tcp_sent(void* pcb, void* arg) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(arg);
|
||||||
|
}
|
||||||
|
void tcp_recv(void* pcb, tcp_recv_fn arg) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_setprio(void* pcb, uint8_t prio) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(prio);
|
||||||
|
}
|
||||||
|
void tcp_err(void* pcb, void* err) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(err);
|
||||||
|
}
|
||||||
|
void tcp_poll(void* pcb, void* poll, uint8_t interval) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(poll);
|
||||||
|
UNUSED(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_close(void* pcb) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_write(void* pcb, const char* data, size_t len, uint8_t apiflags) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(apiflags);
|
||||||
|
UNUSED(len);
|
||||||
|
|
||||||
|
printf("tcp_write:\n%s\n", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_output(void* pcb) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_recved(void* pcb, uint16_t len) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
UNUSED(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t tcp_sndbuf(void* pcb) {
|
||||||
|
UNUSED(pcb);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pbuf_free(struct pbuf* p) {
|
||||||
|
UNUSED(p);
|
||||||
}
|
}
|
||||||
126
tests/mocs.h
Normal file
126
tests/mocs.h
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifndef UNUSED
|
||||||
|
#define UNUSED(x) (void)(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LWIP_UNUSED_ARG(x) UNUSED(x)
|
||||||
|
|
||||||
|
typedef int8_t err_t;
|
||||||
|
/** Definitions for error constants. */
|
||||||
|
typedef enum {
|
||||||
|
/** No error, everything OK. */
|
||||||
|
ERR_OK = 0,
|
||||||
|
/** Out of memory error. */
|
||||||
|
ERR_MEM = -1,
|
||||||
|
/** Buffer error. */
|
||||||
|
ERR_BUF = -2,
|
||||||
|
/** Timeout. */
|
||||||
|
ERR_TIMEOUT = -3,
|
||||||
|
/** Routing problem. */
|
||||||
|
ERR_RTE = -4,
|
||||||
|
/** Operation in progress */
|
||||||
|
ERR_INPROGRESS = -5,
|
||||||
|
/** Illegal value. */
|
||||||
|
ERR_VAL = -6,
|
||||||
|
/** Operation would block. */
|
||||||
|
ERR_WOULDBLOCK = -7,
|
||||||
|
/** Address in use. */
|
||||||
|
ERR_USE = -8,
|
||||||
|
/** Already connecting. */
|
||||||
|
ERR_ALREADY = -9,
|
||||||
|
/** Conn already established.*/
|
||||||
|
ERR_ISCONN = -10,
|
||||||
|
/** Not connected. */
|
||||||
|
ERR_CONN = -11,
|
||||||
|
/** Low-level netif error */
|
||||||
|
ERR_IF = -12,
|
||||||
|
|
||||||
|
/** Connection aborted. */
|
||||||
|
ERR_ABRT = -13,
|
||||||
|
/** Connection reset. */
|
||||||
|
ERR_RST = -14,
|
||||||
|
/** Connection closed. */
|
||||||
|
ERR_CLSD = -15,
|
||||||
|
/** Illegal argument. */
|
||||||
|
ERR_ARG = -16
|
||||||
|
} err_enum_t;
|
||||||
|
|
||||||
|
struct pbuf {
|
||||||
|
struct pbuf *next;
|
||||||
|
void *payload;
|
||||||
|
uint16_t tot_len;
|
||||||
|
uint16_t len;
|
||||||
|
uint8_t type_internal;
|
||||||
|
uint8_t flags;
|
||||||
|
//LWIP_PBUF_REF_T ref;
|
||||||
|
|
||||||
|
uint8_t if_idx;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tcp_pcb {
|
||||||
|
uint8_t state;
|
||||||
|
};
|
||||||
|
typedef void sFONT;
|
||||||
|
|
||||||
|
#define ERR_OK 0
|
||||||
|
#define LCD_COLOR_BLACK 0
|
||||||
|
#define LCD_COLOR_WHITE 1
|
||||||
|
#define LCD_TRANSPARENT 2
|
||||||
|
|
||||||
|
#define LCD_FONT16 0
|
||||||
|
#define LCD_FONT24 (void*)1
|
||||||
|
|
||||||
|
#define TCP_WRITE_FLAG_COPY 0x01
|
||||||
|
#define TCP_WRITE_FLAG_MORE 0x02
|
||||||
|
|
||||||
|
#define TCP_PRIO_MIN 1
|
||||||
|
#define TCP_PRIO_NORMAL 64
|
||||||
|
#define TCP_PRIO_MAX 127
|
||||||
|
#define IP_ADDR_ANY 0
|
||||||
|
|
||||||
|
typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb,
|
||||||
|
struct pbuf *p, err_t err);
|
||||||
|
|
||||||
|
typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err);
|
||||||
|
|
||||||
|
uint32_t logger_get_timestamp(void);
|
||||||
|
|
||||||
|
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font);
|
||||||
|
void lcd_draw_img_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos);
|
||||||
|
void lcd_draw_gif_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos);
|
||||||
|
void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos);
|
||||||
|
void lcd_draw_gif(uint8_t* gif_buff, size_t len, uint32_t x_pos, uint32_t y_pos);
|
||||||
|
|
||||||
|
void lcd_clear_images(void);
|
||||||
|
void lcd_clear_text(void);
|
||||||
|
|
||||||
|
struct tcp_pcb* tcp_new(void);
|
||||||
|
err_t tcp_bind(void *pcb, void *ipaddr, uint16_t port);
|
||||||
|
struct tcp_pcb* tcp_listen(void *pcb);
|
||||||
|
void tcp_accept(void *pcb, tcp_accept_fn arg);
|
||||||
|
void tcp_arg(void *pcb, void *arg);
|
||||||
|
void tcp_sent(void *pcb, void *arg);
|
||||||
|
void tcp_recv(void *pcb, tcp_recv_fn arg);
|
||||||
|
void tcp_setprio(void *pcb, uint8_t prio);
|
||||||
|
void tcp_err(void *pcb, void* err);
|
||||||
|
void tcp_poll(void *pcb, void* poll, uint8_t interval);
|
||||||
|
void tcp_close(void *pcb);
|
||||||
|
|
||||||
|
void tcp_write(void *pcb, const char *data, size_t len, uint8_t apiflags);
|
||||||
|
void tcp_output(void *pcb);
|
||||||
|
void tcp_recved(void *pcb, uint16_t len);
|
||||||
|
void pbuf_free(struct pbuf* p);
|
||||||
|
|
||||||
|
size_t tcp_sndbuf(void *pcb);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "mocs.h"
|
||||||
#include "tftp.h"
|
#include "tftp.h"
|
||||||
|
|
||||||
tftp_custom_file_t file = {
|
tftp_custom_file_t file = {
|
||||||
|
|||||||
@@ -6,26 +6,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "mocs.h"
|
||||||
struct pbuf {
|
|
||||||
struct pbuf *next;
|
|
||||||
void *payload;
|
|
||||||
uint16_t tot_len;
|
|
||||||
uint16_t len;
|
|
||||||
uint8_t type_internal;
|
|
||||||
uint8_t flags;
|
|
||||||
//LWIP_PBUF_REF_T ref;
|
|
||||||
|
|
||||||
uint8_t if_idx;
|
|
||||||
};
|
|
||||||
typedef void sFONT;
|
|
||||||
|
|
||||||
#define ERR_OK 0
|
|
||||||
#define LCD_COLOR_BLACK 0
|
|
||||||
#define LCD_COLOR_WHITE 1
|
|
||||||
#define LCD_TRANSPARENT 2
|
|
||||||
|
|
||||||
#define LCD_FONT16 0
|
|
||||||
|
|
||||||
struct tftp_context {
|
struct tftp_context {
|
||||||
void* (*open)(const char* fname, const char* mode, uint8_t write);
|
void* (*open)(const char* fname, const char* mode, uint8_t write);
|
||||||
@@ -35,14 +16,7 @@ struct tftp_context {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void tftp_cleanup(void);
|
void tftp_cleanup(void);
|
||||||
uint32_t logger_get_timestamp(void);
|
|
||||||
int tftp_init(struct tftp_context* context);
|
int tftp_init(struct tftp_context* context);
|
||||||
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font);
|
|
||||||
void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos);
|
|
||||||
void lcd_draw_gif(uint8_t* gif_buff, size_t len, uint32_t x_pos, uint32_t y_pos);
|
|
||||||
|
|
||||||
void lcd_clear_images(void);
|
|
||||||
void lcd_clear_text(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user