Merged changes from 3.15 branch, to revno 12807

This commit is contained in:
Andrew Johnson
2017-02-01 11:57:04 -06:00
90 changed files with 1401 additions and 959 deletions

View File

@@ -1,4 +1,5 @@
/*************************************************************************\
* Copyright (c) 2016 Michael Davidsaver
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
@@ -11,6 +12,7 @@
#include <stdlib.h>
#include "ellLib.h"
#include "dbDefs.h"
#include "epicsUnitTest.h"
#include "testMain.h"
@@ -20,15 +22,13 @@ struct myItem {
int num;
};
MAIN(epicsEllTest)
static void testList(void)
{
ELLLIST list1;
ELLLIST list2 = ELLLIST_INIT;
int i1 = 1;
struct myItem *pitem, *pfirst, *pick;
testPlan(70);
list1.count = 27;
list1.node.next = (ELLNODE *) 0x01010101;
list1.node.previous = (ELLNODE *) 0x10101010;
@@ -192,6 +192,77 @@ MAIN(epicsEllTest)
ellFree2(&list1, free);
testOk1(ellCount(&list1) == 0);
}
typedef struct { int A, B; } input_t;
static int myItemCmp(const ELLNODE *a, const ELLNODE *b)
{
struct myItem *A = CONTAINER(a, struct myItem, node),
*B = CONTAINER(b, struct myItem, node);
if (A->num < B->num) return -1;
else if(A->num > B->num) return 1;
else if(A->list < B->list) return -1;
else if(A->list > B->list) return 1;
else return 0;
}
static const input_t input[] = {
{-4, 0},
{-5, 0},
{0,0},
{50,0},
{0,1},
{5,0},
{5,1}
};
static
void testSort(const input_t *inp, size_t ninp)
{
unsigned i;
ELLLIST list = ELLLIST_INIT;
struct myItem *alloc = calloc(ninp, sizeof(*alloc));
if(!alloc) testAbort("testSort allocation fails");
for(i=0; i<ninp; i++) {
struct myItem *it = &alloc[i];
it->num = inp[i].A;
it->list= inp[i].B;
ellAdd(&list, &it->node);
}
ellSortStable(&list, &myItemCmp);
testOk(ellCount(&list)==ninp, "output length %u == %u", (unsigned)ellCount(&list), (unsigned)ninp);
if(ellCount(&list)==0) {
testSkip(ninp-1, "all items lost");
}
{
struct myItem *prev = CONTAINER(ellFirst(&list), struct myItem, node),
*next;
for(next = CONTAINER(ellNext(&prev->node), struct myItem, node);
next;
prev = next, next = CONTAINER(ellNext(&next->node), struct myItem, node))
{
int cond = (prev->num<next->num) || (prev->num==next->num && prev->list<next->list);
testOk(cond, "%d:%d < %d:%d", prev->num, prev->list, next->num, next->list);
}
}
}
MAIN(epicsEllTest)
{
testPlan(77);
testList();
testSort(input, NELEMENTS(input));
return testDone();
}

View File

@@ -250,5 +250,12 @@ MAIN(epicsEventTest)
eventWaitTest();
eventWakeupTest();
free(name);
free(id);
epicsRingPointerDelete(pinfo->ring);
epicsMutexDestroy(pinfo->lockRing);
epicsEventDestroy(event);
free(pinfo);
return testDone();
}

View File

@@ -279,5 +279,11 @@ MAIN(epicsMutexTest)
epicsMutexPerformance ();
free(pinfo);
free(arg);
free(name);
free(id);
epicsMutexDestroy(mutex);
return testDone();
}

View File

@@ -37,7 +37,14 @@ static void testEpicsSnprintf(void) {
const char *expected = exbuffer;
int size;
int rtn, rlen;
#ifdef _WIN32
#if (defined(_MSC_VER) && _MSC_VER < 1900) || \
(defined(_MINGW) && defined(_TWO_DIGIT_EXPONENT))
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
#endif
sprintf(exbuffer, format, ivalue, fvalue, svalue);
rlen = strlen(expected)+1;
@@ -121,11 +128,7 @@ void testStdoutRedir (const char *report)
MAIN(epicsStdioTest)
{
#ifdef _WIN32
testPlan(166);
#else
testPlan(163);
#endif
testEpicsSnprintf();
#ifdef __rtems__
/* ensure there is a writeable area */

View File

@@ -87,7 +87,7 @@ MAIN(epicsStringTest)
char *s;
int status;
testPlan(402);
testPlan(406);
testChars();
@@ -122,6 +122,11 @@ MAIN(epicsStringTest)
testOk1(epicsStrHash(abcd, 0) == epicsMemHash(abcde, 4, 0));
testOk1(epicsStrHash(abcd, 0) != epicsMemHash("abcd\0", 5, 0));
testOk1(epicsStrnLen("abcd", 5)==4);
testOk1(epicsStrnLen("abcd", 4)==4);
testOk1(epicsStrnLen("abcd", 3)==3);
testOk1(epicsStrnLen("abcd", 0)==0);
testGlob();
memset(result, 'x', sizeof(result));

View File

@@ -43,7 +43,7 @@ MAIN(epicsTimeTest)
const int wasteTime = 100000;
const int nTimes = 10;
testPlan(15 + nTimes * 18);
testPlan(15 + nTimes * 19);
try {
const epicsTimeStamp epochTS = {0, 0};
@@ -200,6 +200,11 @@ MAIN(epicsTimeTest)
epicsTime beginANSI = ansiDate;
testOk1(beginANSI + diff == now);
// test struct gmtm round-trip conversion
gm_tm_nano_sec ansiGmDate = begin;
epicsTime beginGMANSI = ansiGmDate;
testOk1(beginGMANSI + diff == now);
// test struct timespec round-trip conversion
struct timespec ts = begin;
epicsTime beginTS = ts;

View File

@@ -115,5 +115,9 @@ MAIN(ringBytesTest)
testOk(n==1, "ring get %d", 1);
check(ring, RINGSIZE);
epicsRingBytesDelete(ring);
epicsEventDestroy(consumerEvent);
free(pinfo);
return testDone();
}