clangformat everything
This commit is contained in:
13
tests/mocs.c
13
tests/mocs.c
@@ -12,7 +12,12 @@ int tftp_init(struct tftp_context* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lcd_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT* font) {
|
||||
void lcd_display_text(const char* text,
|
||||
uint16_t x_pos,
|
||||
uint16_t y_pos,
|
||||
uint32_t color,
|
||||
uint32_t bg_color,
|
||||
sFONT* font) {
|
||||
UNUSED(color);
|
||||
UNUSED(bg_color);
|
||||
UNUSED(font);
|
||||
@@ -54,19 +59,19 @@ struct tcp_pcb* tcp_new(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err_t tcp_bind(void *pcb, void *ipaddr, uint16_t port) {
|
||||
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) {
|
||||
struct tcp_pcb* tcp_listen(void* pcb) {
|
||||
UNUSED(pcb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void tcp_accept(void *pcb, tcp_accept_fn arg) {
|
||||
void tcp_accept(void* pcb, tcp_accept_fn arg) {
|
||||
UNUSED(pcb);
|
||||
UNUSED(arg);
|
||||
}
|
||||
|
||||
127
tests/mocs.h
127
tests/mocs.h
@@ -4,8 +4,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) (void)(x)
|
||||
@@ -16,53 +16,53 @@ extern "C" {
|
||||
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,
|
||||
/** 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
|
||||
/** 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;
|
||||
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;
|
||||
uint8_t if_idx;
|
||||
};
|
||||
|
||||
struct tcp_pcb {
|
||||
@@ -70,10 +70,10 @@ struct tcp_pcb {
|
||||
};
|
||||
typedef void sFONT;
|
||||
|
||||
#define ERR_OK 0
|
||||
#define ERR_OK 0
|
||||
#define LCD_COLOR_BLACK 0
|
||||
#define LCD_COLOR_WHITE 1
|
||||
#define LCD_TRANSPARENT 2
|
||||
#define LCD_TRANSPARENT 2
|
||||
|
||||
#define LCD_FONT16 0
|
||||
#define LCD_FONT24 (void*)1
|
||||
@@ -86,14 +86,13 @@ typedef void sFONT;
|
||||
#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);
|
||||
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(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font);
|
||||
void lcd_display_text(const char* 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);
|
||||
@@ -103,23 +102,23 @@ 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);
|
||||
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 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);
|
||||
size_t tcp_sndbuf(void* pcb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,35 +1,23 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mocs.h"
|
||||
#include "tftp.h"
|
||||
|
||||
tftp_custom_file_t file = {
|
||||
.data = (char*)"1234567890",
|
||||
.len = 11,
|
||||
.name = (char*)"test.txt",
|
||||
.offset = 0
|
||||
};
|
||||
tftp_custom_file_t write_file = {
|
||||
.data = NULL,
|
||||
.len = 0,
|
||||
.name = (char*)"test.txt",
|
||||
.offset = 0
|
||||
};
|
||||
tftp_custom_file_t file = {.data = (char*)"1234567890", .len = 11, .name = (char*)"test.txt", .offset = 0};
|
||||
tftp_custom_file_t write_file = {.data = NULL, .len = 0, .name = (char*)"test.txt", .offset = 0};
|
||||
|
||||
TEST(TFTP, custom_fseek)
|
||||
{
|
||||
TEST(TFTP, custom_fseek) {
|
||||
tftp_custom_fseek(&file, 5, SEEK_SET);
|
||||
EXPECT_EQ(file.offset, 5);
|
||||
tftp_custom_fseek(&file, 5, SEEK_CUR);
|
||||
EXPECT_EQ(file.offset, 10);
|
||||
}
|
||||
|
||||
TEST(TFTP, custom_fread)
|
||||
{
|
||||
TEST(TFTP, custom_fread) {
|
||||
char buf[11];
|
||||
tftp_custom_fseek(&file, 0, SEEK_SET);
|
||||
size_t bytes = tftp_custom_fread(buf, 11, &file);
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "mocs.h"
|
||||
|
||||
struct tftp_context {
|
||||
void* (*open)(const char* fname, const char* mode, uint8_t write);
|
||||
void (*close)(void* handle);
|
||||
int (*read)(void* handle, void* buf, int bytes);
|
||||
int (*write)(void* handle, struct pbuf* p);
|
||||
void* (*open)(const char* fname, const char* mode, uint8_t write);
|
||||
void (*close)(void* handle);
|
||||
int (*read)(void* handle, void* buf, int bytes);
|
||||
int (*write)(void* handle, struct pbuf* p);
|
||||
};
|
||||
|
||||
void tftp_cleanup(void);
|
||||
|
||||
Reference in New Issue
Block a user