forked from espressif/arduino-esp32
Update IDF and Tools
This commit is contained in:
@ -47,6 +47,10 @@ uint32_t unity_exec_time_get_ms(void);
|
||||
|
||||
#endif //CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER
|
||||
|
||||
#ifdef CONFIG_UNITY_ENABLE_FIXTURE
|
||||
#include "unity_fixture_extras.h"
|
||||
#endif // CONFIG_UNITY_ENABLE_FIXTURE
|
||||
|
||||
// shorthand to check esp_err_t return code
|
||||
#define TEST_ESP_OK(rc) TEST_ASSERT_EQUAL_HEX32(ESP_OK, rc)
|
||||
#define TEST_ESP_ERR(err, rc) TEST_ASSERT_EQUAL_HEX32(err, rc)
|
||||
|
25
tools/sdk/esp32/include/unity/include/unity_fixture_extras.h
Normal file
25
tools/sdk/esp32/include/unity/include/unity_fixture_extras.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* IDF-specific additions to "Unity Fixture" */
|
||||
#pragma once
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET
|
||||
|
||||
/* A shorthand for running one test group from the main function */
|
||||
#define UNITY_MAIN(group_) do { \
|
||||
const char* argv[] = { "test", "-v" }; \
|
||||
const int argc = sizeof(argv)/sizeof(argv[0]); \
|
||||
int rc = UnityMain(argc, argv, TEST_ ## group_ ## _GROUP_RUNNER); \
|
||||
printf("\nTests finished, rc=%d\n", rc); \
|
||||
exit(rc); \
|
||||
} while(0)
|
||||
|
||||
#else // CONFIG_IDF_TARGET
|
||||
|
||||
/* A shorthand for running one test group from the main function */
|
||||
#define UNITY_MAIN(group_) do { \
|
||||
const char* argv[] = { "test", "-v" }; \
|
||||
const int argc = sizeof(argv)/sizeof(argv[0]); \
|
||||
int rc = UnityMain(argc, argv, TEST_ ## group_ ## _GROUP_RUNNER); \
|
||||
printf("\nTests finished, rc=%d\n", rc); \
|
||||
} while(0)
|
||||
|
||||
#endif // CONFIG_IDF_TARGET
|
@ -0,0 +1,83 @@
|
||||
/* Copyright (c) 2010 James Grenning and Contributed to Unity Project
|
||||
* ==========================================
|
||||
* Unity Project - A Test Framework for C
|
||||
* Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
* [Released under MIT License. Please refer to license.txt for details]
|
||||
* ========================================== */
|
||||
|
||||
#ifndef UNITY_FIXTURE_H_
|
||||
#define UNITY_FIXTURE_H_
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_internals.h"
|
||||
#include "unity_fixture_malloc_overrides.h"
|
||||
#include "unity_fixture_internals.h"
|
||||
|
||||
int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
|
||||
|
||||
|
||||
#define TEST_GROUP(group)\
|
||||
static const char* TEST_GROUP_##group = #group
|
||||
|
||||
#define TEST_SETUP(group) void TEST_##group##_SETUP(void);\
|
||||
void TEST_##group##_SETUP(void)
|
||||
|
||||
#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\
|
||||
void TEST_##group##_TEAR_DOWN(void)
|
||||
|
||||
|
||||
#define TEST(group, name) \
|
||||
void TEST_##group##_##name##_(void);\
|
||||
void TEST_##group##_##name##_run(void);\
|
||||
void TEST_##group##_##name##_run(void)\
|
||||
{\
|
||||
UnityTestRunner(TEST_##group##_SETUP,\
|
||||
TEST_##group##_##name##_,\
|
||||
TEST_##group##_TEAR_DOWN,\
|
||||
"TEST(" #group ", " #name ")",\
|
||||
TEST_GROUP_##group, #name,\
|
||||
__FILE__, __LINE__);\
|
||||
}\
|
||||
void TEST_##group##_##name##_(void)
|
||||
|
||||
#define IGNORE_TEST(group, name) \
|
||||
void TEST_##group##_##name##_(void);\
|
||||
void TEST_##group##_##name##_run(void);\
|
||||
void TEST_##group##_##name##_run(void)\
|
||||
{\
|
||||
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")", TEST_GROUP_##group, #name);\
|
||||
}\
|
||||
void TEST_##group##_##name##_(void)
|
||||
|
||||
/* Call this for each test, insider the group runner */
|
||||
#define RUN_TEST_CASE(group, name) \
|
||||
{ void TEST_##group##_##name##_run(void);\
|
||||
TEST_##group##_##name##_run(); }
|
||||
|
||||
/* This goes at the bottom of each test file or in a separate c file */
|
||||
#define TEST_GROUP_RUNNER(group)\
|
||||
void TEST_##group##_GROUP_RUNNER(void);\
|
||||
void TEST_##group##_GROUP_RUNNER(void)
|
||||
|
||||
/* Call this from main */
|
||||
#define RUN_TEST_GROUP(group)\
|
||||
{ void TEST_##group##_GROUP_RUNNER(void);\
|
||||
TEST_##group##_GROUP_RUNNER(); }
|
||||
|
||||
/* CppUTest Compatibility Macros */
|
||||
#ifndef UNITY_EXCLUDE_CPPUTEST_ASSERTS
|
||||
/* Sets a pointer and automatically restores it to its old value after teardown */
|
||||
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__)
|
||||
#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
|
||||
#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
|
||||
#define FAIL(message) TEST_FAIL_MESSAGE((message))
|
||||
#define CHECK(condition) TEST_ASSERT_TRUE((condition))
|
||||
#define LONGS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_INT((expected), (actual))
|
||||
#define STRCMP_EQUAL(expected, actual) TEST_ASSERT_EQUAL_STRING((expected), (actual))
|
||||
#define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual))
|
||||
#endif
|
||||
|
||||
/* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */
|
||||
void UnityMalloc_MakeMallocFailAfterCount(int countdown);
|
||||
|
||||
#endif /* UNITY_FIXTURE_H_ */
|
@ -0,0 +1,51 @@
|
||||
/* Copyright (c) 2010 James Grenning and Contributed to Unity Project
|
||||
* ==========================================
|
||||
* Unity Project - A Test Framework for C
|
||||
* Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
* [Released under MIT License. Please refer to license.txt for details]
|
||||
* ========================================== */
|
||||
|
||||
#ifndef UNITY_FIXTURE_INTERNALS_H_
|
||||
#define UNITY_FIXTURE_INTERNALS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct UNITY_FIXTURE_T
|
||||
{
|
||||
int Verbose;
|
||||
unsigned int RepeatCount;
|
||||
const char* NameFilter;
|
||||
const char* GroupFilter;
|
||||
};
|
||||
extern struct UNITY_FIXTURE_T UnityFixture;
|
||||
|
||||
typedef void unityfunction(void);
|
||||
void UnityTestRunner(unityfunction* setup,
|
||||
unityfunction* testBody,
|
||||
unityfunction* teardown,
|
||||
const char* printableName,
|
||||
const char* group,
|
||||
const char* name,
|
||||
const char* file, unsigned int line);
|
||||
|
||||
void UnityIgnoreTest(const char* printableName, const char* group, const char* name);
|
||||
void UnityMalloc_StartTest(void);
|
||||
void UnityMalloc_EndTest(void);
|
||||
int UnityGetCommandLineOptions(int argc, const char* argv[]);
|
||||
void UnityConcludeFixtureTest(void);
|
||||
|
||||
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line);
|
||||
void UnityPointer_UndoAllSets(void);
|
||||
void UnityPointer_Init(void);
|
||||
#ifndef UNITY_MAX_POINTERS
|
||||
#define UNITY_MAX_POINTERS 5
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UNITY_FIXTURE_INTERNALS_H_ */
|
@ -0,0 +1,47 @@
|
||||
/* Copyright (c) 2010 James Grenning and Contributed to Unity Project
|
||||
* ==========================================
|
||||
* Unity Project - A Test Framework for C
|
||||
* Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
* [Released under MIT License. Please refer to license.txt for details]
|
||||
* ========================================== */
|
||||
|
||||
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
|
||||
#define UNITY_FIXTURE_MALLOC_OVERRIDES_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
|
||||
/* Define this macro to remove the use of stdlib.h, malloc, and free.
|
||||
* Many embedded systems do not have a heap or malloc/free by default.
|
||||
* This internal unity_malloc() provides allocated memory deterministically from
|
||||
* the end of an array only, unity_free() only releases from end-of-array,
|
||||
* blocks are not coalesced, and memory not freed in LIFO order is stranded. */
|
||||
#ifndef UNITY_INTERNAL_HEAP_SIZE_BYTES
|
||||
#define UNITY_INTERNAL_HEAP_SIZE_BYTES 256
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* These functions are used by the Unity Fixture to allocate and release memory
|
||||
* on the heap and can be overridden with platform-specific implementations.
|
||||
* For example, when using FreeRTOS UNITY_FIXTURE_MALLOC becomes pvPortMalloc()
|
||||
* and UNITY_FIXTURE_FREE becomes vPortFree(). */
|
||||
#if !defined(UNITY_FIXTURE_MALLOC) || !defined(UNITY_FIXTURE_FREE)
|
||||
#include <stdlib.h>
|
||||
#define UNITY_FIXTURE_MALLOC(size) malloc(size)
|
||||
#define UNITY_FIXTURE_FREE(ptr) free(ptr)
|
||||
#else
|
||||
extern void* UNITY_FIXTURE_MALLOC(size_t size);
|
||||
extern void UNITY_FIXTURE_FREE(void* ptr);
|
||||
#endif
|
||||
|
||||
#define malloc unity_malloc
|
||||
#define calloc unity_calloc
|
||||
#define realloc unity_realloc
|
||||
#define free unity_free
|
||||
|
||||
void* unity_malloc(size_t size);
|
||||
void* unity_calloc(size_t num, size_t size);
|
||||
void* unity_realloc(void * oldMem, size_t size);
|
||||
void unity_free(void * mem);
|
||||
|
||||
#endif /* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */
|
Reference in New Issue
Block a user