Make adding an identical error symbol not fail
A test case was also added which test that adding an error symbol with same error code and message as one added before will not fail
This commit is contained in:
@@ -105,7 +105,12 @@ int errSymbolAdd(long errNum, const char *name)
|
||||
/* search for last node (NULL) of hashnode linked list */
|
||||
while (pNextNode) {
|
||||
if (pNextNode->errNum == errNum) {
|
||||
return S_err_codeExists;
|
||||
if(strcmp(name, pNextNode->message)) {
|
||||
return S_err_codeExists;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
phashnode = &pNextNode->hashnode;
|
||||
pNextNode = *phashnode;
|
||||
|
||||
@@ -238,13 +238,21 @@ static void testAddingExistingErrorSymbol()
|
||||
"Adding an error symbol with an existing error code should fail");
|
||||
}
|
||||
|
||||
static void testAddingExistingErrorSymbolWithSameMessage()
|
||||
{
|
||||
long invented_code = (0x7999 << 16) | 0x9997;
|
||||
errSymbolAdd(invented_code, "Invented Error Message");
|
||||
testOk(!errSymbolAdd(invented_code, "Invented Error Message"),
|
||||
"Adding identical error symbol shouldn't fail");
|
||||
}
|
||||
|
||||
MAIN(epicsErrlogTest)
|
||||
{
|
||||
size_t mlen, i, N;
|
||||
char msg[256];
|
||||
clientPvt pvt, pvt2;
|
||||
|
||||
testPlan(53);
|
||||
testPlan(54);
|
||||
|
||||
testANSIStrip();
|
||||
|
||||
@@ -460,6 +468,7 @@ MAIN(epicsErrlogTest)
|
||||
testAddingErrorSymbol();
|
||||
testAddingInvalidErrorSymbol();
|
||||
testAddingExistingErrorSymbol();
|
||||
testAddingExistingErrorSymbolWithSameMessage();
|
||||
|
||||
return testDone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user