Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82048f400e |
43
src/kunity.c
43
src/kunity.c
@@ -4,21 +4,6 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
|
|
||||||
//}
|
|
||||||
//{ local include region
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
//{ local define region
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
//{ local enum region
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
//{ local typedef region
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//{local struct region
|
//{local struct region
|
||||||
@@ -34,19 +19,19 @@ typedef struct string_builder_sTag {
|
|||||||
|
|
||||||
static void printk_put_char(char /* letter */);
|
static void printk_put_char(char /* letter */);
|
||||||
|
|
||||||
static result_code_e set_test_output(/*in */ const ptr_output_functions_s output);
|
static result_code_e set_test_output(/*in */ const ptr_test_session_control_block_s output);
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//{ local var region
|
//{ local var region
|
||||||
|
|
||||||
static output_functions_s prink_output = { printk_put_char };
|
static test_session_control_block_s prink_output = { printk_put_char, 0, 0 };
|
||||||
|
|
||||||
static ptr_output_functions_s kunity_output = &prink_output;
|
static ptr_test_session_control_block_s kunity_output = &prink_output;
|
||||||
|
|
||||||
static string_builder_s string_builder;
|
static string_builder_s string_builder;
|
||||||
|
|
||||||
static size_t sizeof_output = sizeof(output_functions_s);
|
static size_t sizeof_output = sizeof(test_session_control_block_s);
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@@ -57,9 +42,9 @@ void putchark(/* in */ char a)
|
|||||||
kunity_output->redirect_char(a);
|
kunity_output->redirect_char(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
result_code_e create_default_test_output(/* out*/ ptr_output_functions_s* output_location)
|
result_code_e create_default_test_output(/* out*/ ptr_test_session_control_block_s* output_location)
|
||||||
{
|
{
|
||||||
ptr_output_functions_s tmp_output = NULL;
|
ptr_test_session_control_block_s tmp_output = NULL;
|
||||||
if (output_location == NULL) {
|
if (output_location == NULL) {
|
||||||
return ERROR_NULL_ARGUMENT;
|
return ERROR_NULL_ARGUMENT;
|
||||||
}
|
}
|
||||||
@@ -77,7 +62,7 @@ result_code_e create_default_test_output(/* out*/ ptr_output_functions_s* output
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_code_e run_unity_test(/* in */ const unity_test_function_ptr test_function, /* in */ const char* file_name, /* in */ const char* test_name, /* in */ int line_number, /* in */ const ptr_output_functions_s output)
|
result_code_e run_unity_test(/* in */ const unity_test_function_ptr test_function, /* in */ const char* file_name, /* in */ const char* test_name, /* in */ int line_number, /* in */ const ptr_test_session_control_block_s output)
|
||||||
{
|
{
|
||||||
result_code_e result;
|
result_code_e result;
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
@@ -89,9 +74,17 @@ result_code_e run_unity_test(/* in */ const unity_test_function_ptr test_functio
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnityBegin(file_name);
|
if (output->_skip_start) {
|
||||||
|
Unity.TestFile = file_name;
|
||||||
|
} else {
|
||||||
|
UnityBegin(file_name);
|
||||||
|
}
|
||||||
|
|
||||||
UnityDefaultTestRun(test_function, test_name, line_number);
|
UnityDefaultTestRun(test_function, test_name, line_number);
|
||||||
UNITY_END();
|
if (!output->_skip_end) {
|
||||||
|
UNITY_END();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +114,7 @@ static void printk_put_char(char letter)
|
|||||||
string_builder.write_postion = (string_builder.write_postion + 1) % KUNITY_LINE_SIZE;
|
string_builder.write_postion = (string_builder.write_postion + 1) % KUNITY_LINE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static result_code_e set_test_output(/* in */ const ptr_output_functions_s output)
|
static result_code_e set_test_output(/* in */ const ptr_test_session_control_block_s output)
|
||||||
{
|
{
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
return ERROR_NULL_ARGUMENT;
|
return ERROR_NULL_ARGUMENT;
|
||||||
|
|||||||
15
src/kunity.h
15
src/kunity.h
@@ -3,30 +3,21 @@
|
|||||||
#include "kunity_t.h"
|
#include "kunity_t.h"
|
||||||
|
|
||||||
//{ global include region
|
//{ global include region
|
||||||
|
|
||||||
#include <unity.h>
|
#include <unity.h>
|
||||||
//}
|
|
||||||
//{ local include region
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//{ function region
|
//{ function region
|
||||||
|
|
||||||
extern void putchark(/* in */ char a);
|
extern void putchark(/* in */ char a);
|
||||||
|
|
||||||
extern result_code_e create_default_test_output(/* out*/ ptr_output_functions_s* output_location);
|
extern result_code_e create_default_test_output(/* out*/ ptr_test_session_control_block_s* output_location);
|
||||||
|
|
||||||
extern result_code_e run_unity_test(/* in */ const unity_test_function_ptr test_function, /* in */ const char* file_name, /* in */ const char* test_name, /* in */ int line_number, /* in */ const ptr_output_functions_s output);
|
extern result_code_e run_unity_test(/* in */ const unity_test_function_ptr test_function, /* in */ const char* file_name, /* in */ const char* test_name, /* in */ int line_number, /* in */ const ptr_test_session_control_block_s output);
|
||||||
|
|
||||||
extern result_code_e run_unity_printk_test(/* in */ const kunity_test_function_ptr test_function);
|
extern result_code_e run_unity_printk_test(/* in */ const kunity_test_function_ptr test_function);
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // KUNITY_H
|
#endif // KUNITY_H
|
||||||
|
|||||||
@@ -6,9 +6,6 @@
|
|||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
//}
|
|
||||||
//{ local include region
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//{ define region
|
//{ define region
|
||||||
@@ -34,16 +31,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef KUNITY_TEST
|
#ifndef KUNITY_TEST
|
||||||
#define KUNITY_TEST(function_name) \
|
#define KUNITY_TEST(function_name) \
|
||||||
extern result_code_e KUNITY_CREATE_TEST_NAME(function_name)(const ptr_output_functions_s output); \
|
extern result_code_e KUNITY_CREATE_TEST_NAME(function_name)(const ptr_test_session_control_block_s output); \
|
||||||
static void function_name(void); \
|
static void function_name(void); \
|
||||||
\
|
\
|
||||||
result_code_e KUNITY_CREATE_TEST_NAME(function_name)(const ptr_output_functions_s output) \
|
result_code_e KUNITY_CREATE_TEST_NAME(function_name)(const ptr_test_session_control_block_s output) \
|
||||||
{ \
|
{ \
|
||||||
return run_unity_test(function_name, __FILE__, #function_name, __LINE__, output); \
|
return run_unity_test(function_name, __FILE__, #function_name, __LINE__, output); \
|
||||||
} \
|
} \
|
||||||
EXPORT_SYMBOL(KUNITY_CREATE_TEST_NAME(function_name)); \
|
EXPORT_SYMBOL(KUNITY_CREATE_TEST_NAME(function_name)); \
|
||||||
\
|
\
|
||||||
static void function_name()
|
static void function_name()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -71,16 +68,16 @@ typedef void (*unity_test_function_ptr)(void);
|
|||||||
|
|
||||||
//{ struct region
|
//{ struct region
|
||||||
|
|
||||||
typedef struct output_functions_sTag {
|
typedef struct test_session_control_block_sTag {
|
||||||
redirect_char redirect_char;
|
redirect_char redirect_char;
|
||||||
} output_functions_s, *ptr_output_functions_s;
|
bool _skip_start;
|
||||||
|
bool _skip_end;
|
||||||
|
} test_session_control_block_s, *ptr_test_session_control_block_s;
|
||||||
|
|
||||||
|
typedef result_code_e (*kunity_test_function_ptr)(ptr_test_session_control_block_s);
|
||||||
typedef result_code_e (*kunity_test_function_ptr)(ptr_output_functions_s);
|
|
||||||
|
|
||||||
typedef struct test_sTag {
|
typedef struct test_sTag {
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* modul_name;
|
|
||||||
kunity_test_function_ptr test_function;
|
kunity_test_function_ptr test_function;
|
||||||
} test_s, *ptr_test_s;
|
} test_s, *ptr_test_s;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user