-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: [#1478] Initial demo of self registration of tests for ut_assert. #1479
Conversation
@@ -230,6 +230,10 @@ | |||
UtTest_Run(); | |||
} | |||
|
|||
/* Defined in linker script */ | |||
extern UtTestRecord __start_utest_records; |
Check warning
Code scanning / CppCheck
Comparing pointers that point to different objects Warning
@@ -230,6 +230,10 @@ | |||
UtTest_Run(); | |||
} | |||
|
|||
/* Defined in linker script */ | |||
extern UtTestRecord __start_utest_records; | |||
extern UtTestRecord __stop_utest_records; |
Check warning
Code scanning / CppCheck
Subtracting pointers that point to different objects Warning
@@ -117,4 +117,32 @@ | |||
*/ | |||
void UtTest_Setup(void); | |||
|
|||
|
|||
typedef void (*UTTestFunction)(void); |
Check notice
Code scanning / CodeQL
Hidden pointer indirection Note
#define UTEST(suiteName, uTtestName) \ | ||
static void suiteName##_##uTtestName(void); \ | ||
static UtTestRecord Record_##suiteName##_##uTtestName \ | ||
__attribute__((section(".utest_records"), used)) = { \ | ||
.marker = 0xDeadBeaf, \ | ||
.testSuite = #suiteName, \ | ||
.functionName = #uTtestName, \ | ||
.testName = #suiteName #uTtestName, \ | ||
.fileName = __FILE__, \ | ||
.lineNumber = __LINE__, \ | ||
.functionPointer = suiteName##_##uTtestName \ | ||
}; \ | ||
static void suiteName##_##uTtestName(void) |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
@@ -230,6 +230,10 @@ | |||
UtTest_Run(); | |||
} | |||
|
|||
/* Defined in linker script */ | |||
extern UtTestRecord __start_utest_records; |
Check notice
Code scanning / CodeQL
Variable scope too large Note
OS_Application_Startup
The variable __start_utest_records is only accessed in
OS_Application_Startup
@@ -230,6 +230,10 @@ | |||
UtTest_Run(); | |||
} | |||
|
|||
/* Defined in linker script */ | |||
extern UtTestRecord __start_utest_records; |
Check warning
Code scanning / CodeQL
"extern" declaration in source file Warning
@@ -230,6 +230,10 @@ | |||
UtTest_Run(); | |||
} | |||
|
|||
/* Defined in linker script */ | |||
extern UtTestRecord __start_utest_records; | |||
extern UtTestRecord __stop_utest_records; |
Check notice
Code scanning / CodeQL
Variable scope too large Note
OS_Application_Startup
The variable __stop_utest_records is only accessed in
OS_Application_Startup
@@ -230,6 +230,10 @@ | |||
UtTest_Run(); | |||
} | |||
|
|||
/* Defined in linker script */ | |||
extern UtTestRecord __start_utest_records; | |||
extern UtTestRecord __stop_utest_records; |
Check warning
Code scanning / CodeQL
"extern" declaration in source file Warning
while (test < &__stop_utest_records) { | ||
// printf(" Adding test %s\n", test->functionName); | ||
UtTest_Add(test->functionPointer, NULL, NULL, test->functionName); | ||
test++; | ||
} |
Check warning
Code scanning / CodeQL
Unbounded loop Warning
|
||
/* TODO PROBALBY a better spot for this */ | ||
UtTestRecord *test = &__start_utest_records; | ||
// printf("Size of record is %d\n", sizeof(*test)); |
Check notice
Code scanning / CodeQL
Commented-out code Note
/* TODO PROBALBY a better spot for this */ | ||
UtTestRecord *test = &__start_utest_records; | ||
// printf("Size of record is %d\n", sizeof(*test)); | ||
int num_records = (&__stop_utest_records - &__start_utest_records)/ sizeof(*test); |
Check notice
Code scanning / CodeQL
Unused local variable Note
UtTestRecord *test = &__start_utest_records; | ||
// printf("Size of record is %d\n", sizeof(*test)); | ||
int num_records = (&__stop_utest_records - &__start_utest_records)/ sizeof(*test); | ||
// printf("Num records is %d \n",num_records); |
Check notice
Code scanning / CodeQL
Commented-out code Note
int num_records = (&__stop_utest_records - &__start_utest_records)/ sizeof(*test); | ||
// printf("Num records is %d \n",num_records); | ||
while (test < &__stop_utest_records) { | ||
// printf(" Adding test %s\n", test->functionName); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Debugging included dumping the section, and looking at the marker to determine that it was padding out memory.
|
Closing MR, this is probably not portable with linker scripts. |
Still needs cleaned up, but wanted to demo the possibility
More concerned if i could, than if i should.
Only got this working for 1 test, would need more cleanup.
mkdir build_osal_test cd build_osal_test cmake -DENABLE_UNIT_TESTS=true -DOSAL_SYSTEM_BSPTYPE=generic-linux -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=TRUE .. make bin-sem-test ./tests/bin-sem-test
Checklist (Please check before submitting)
Describe the contribution
A clear and concise description of what the contribution is.
Testing performed
Steps taken to test the contribution:
Expected behavior changes
A clear and concise description of how this contribution will change behavior and level of impact.
System(s) tested on
Additional context
Add any other context about the contribution here.
Third party code
If included, identify any third party code and provide text file of license
Contributor Info - All information REQUIRED for consideration of pull request
Full name and company/organization/center of all contributors ("Personal" if individual work)