-
Notifications
You must be signed in to change notification settings - Fork 27
Reccaster exclusion pattern for record filtering #112
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5f43a89
add new iocsh function addReccasterExcludePattern
madelinespark f93c0cf
naming change
madelinespark 925515d
fixed strdup memory leak
madelinespark 5836a6d
fixed loop to be compatible with C89
madelinespark 31d290b
Combine memory allocation for exclude_pattern items, simplify loops
tynanford File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
#include <string.h> | ||
|
||
#include <epicsUnitTest.h> | ||
#include <testMain.h> | ||
|
||
#include "caster.h" | ||
|
||
void* epicsRtemsFSImage; | ||
|
||
static void testLog(void* arg, struct _caster_t* self) | ||
{ | ||
testDiag("ERR %s", self->lastmsg); | ||
} | ||
|
||
static void testAddExcludePatternX(void) | ||
{ | ||
int i = 0; | ||
caster_t caster; | ||
casterInit(&caster); | ||
caster.onmsg = &testLog; | ||
|
||
int argc; | ||
char *argvlist[5]; | ||
argvlist[0] = "addReccasterExcludePattern"; | ||
|
||
char *expectedPatterns[] = | ||
{ | ||
"*_", | ||
"*__", | ||
"*:Intrnl:*", | ||
"*_internal", | ||
"*exclude_me" | ||
}; | ||
int expectedNumPatterns = 0; | ||
|
||
testDiag("Testing addReccasterExcludePattern with one good env"); | ||
argvlist[1] = "*_"; | ||
argc = 2; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
expectedNumPatterns++; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
ELLNODE *cur; | ||
cur = ellFirst(&caster.exclude_patterns); | ||
while (cur != NULL) { | ||
string_list_t *temp = (string_list_t *)cur; | ||
testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); | ||
i++; | ||
cur = ellNext(cur); | ||
} | ||
|
||
testDiag("Testing addReccasterExcludePattern with two more patterns"); | ||
argvlist[1] = "*__"; | ||
argvlist[2] = "*:Intrnl:*"; | ||
argc = 3; | ||
i = 0; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
expectedNumPatterns += 2; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
cur = ellFirst(&caster.exclude_patterns); | ||
while (cur != NULL) { | ||
string_list_t *temp = (string_list_t *)cur; | ||
testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); | ||
i++; | ||
cur = ellNext(cur); | ||
} | ||
|
||
testDiag("Testing addReccasterExcludePattern with a duplicate pattern"); | ||
argvlist[1] = "*_"; | ||
argc = 2; | ||
i = 0; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
cur = ellFirst(&caster.exclude_patterns); | ||
while (cur != NULL) { | ||
string_list_t *temp = (string_list_t *)cur; | ||
testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); | ||
i++; | ||
cur = ellNext(cur); | ||
} | ||
|
||
testDiag("Testing addReccasterExcludePattern with a new and a duplicate"); | ||
argvlist[1] = "*_internal"; | ||
argvlist[2] = "*__"; | ||
argc = 3; | ||
i = 0; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
expectedNumPatterns++; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
cur = ellFirst(&caster.exclude_patterns); | ||
while (cur != NULL) { | ||
string_list_t *temp = (string_list_t *)cur; | ||
testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); | ||
i++; | ||
cur = ellNext(cur); | ||
} | ||
|
||
testDiag("Testing addReccasterExcludePattern with two of the same pattern"); | ||
argvlist[1] = "*exclude_me"; | ||
argvlist[2] = "*exclude_me"; | ||
argc = 3; | ||
i = 0; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
expectedNumPatterns++; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
cur = ellFirst(&caster.exclude_patterns); | ||
while (cur != NULL) { | ||
string_list_t *temp = (string_list_t *)cur; | ||
testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); | ||
i++; | ||
cur = ellNext(cur); | ||
} | ||
|
||
testDiag("Testing addReccasterExcludePattern with duplicates in argv and exclude pattern list"); | ||
argvlist[1] = "*__"; | ||
argvlist[2] = "*__"; | ||
argc = 3; | ||
i = 0; | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
testOk1(caster.exclude_patterns.count==expectedNumPatterns); | ||
cur = ellFirst(&caster.exclude_patterns); | ||
while (cur != NULL) { | ||
string_list_t *temp = (string_list_t *)cur; | ||
testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); | ||
i++; | ||
cur = ellNext(cur); | ||
} | ||
|
||
epicsEventSignal(caster.shutdownEvent); | ||
casterShutdown(&caster); | ||
} | ||
|
||
static void testAddExcludePatternBadInput() | ||
{ | ||
caster_t caster; | ||
casterInit(&caster); | ||
caster.onmsg = &testLog; | ||
|
||
int argc; | ||
char *argvlist[2]; | ||
argvlist[0] = "addReccasterExcludePattern"; | ||
|
||
testDiag("Testing addReccasterExcludePattern with no arguments"); | ||
argc = 1; | ||
testOk1(caster.exclude_patterns.count==0); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
testOk1(caster.exclude_patterns.count==0); | ||
|
||
testDiag("Testing addReccasterExcludePattern with empty string argument"); | ||
argvlist[1] = ""; | ||
argc = 2; | ||
testOk1(caster.exclude_patterns.count==0); | ||
addReccasterExcludePattern(&caster, argc, argvlist); | ||
testOk1(caster.exclude_patterns.count==0); | ||
|
||
epicsEventSignal(caster.shutdownEvent); | ||
casterShutdown(&caster); | ||
} | ||
|
||
MAIN(testAddExcludePattern) | ||
{ | ||
testPlan(37); | ||
osiSockAttach(); | ||
testAddExcludePatternX(); | ||
testAddExcludePatternBadInput(); | ||
osiSockRelease(); | ||
return testDone(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.