Fix issue with compress record
The handling of N-to-M array compression was broken with the addition
of the partial buffer option, which broke the bounds check that was
being used.
Note that this also makes the partial buffer option more consistent;
if, for example, you have
```
record(compress, foo) {
field(ALG, "N to 1 Average")
field(INP, "bar NPP")
field(NSAM, 2)
field(N, 2)
field(PBUF, YES)
}
```
(with `bar` having, e.g. length 3), then this will now behave as
expected on both of the samples.
This commit is contained in:
committed by
Andrew Johnson
parent
4966baf423
commit
beec00b403
@@ -469,6 +469,38 @@ testNto1Average(void) {
|
||||
testdbCleanup();
|
||||
}
|
||||
|
||||
void testNto2Average(void) {
|
||||
DBADDR wfaddr, caddr;
|
||||
|
||||
testDiag("Test N to 1 Average, NSAM=2, N=2");
|
||||
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("recTestIoc.dbd", NULL, NULL);
|
||||
|
||||
recTestIoc_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
testdbReadDatabase("compressTest.db", NULL, "INP=wf,ALG=N to 1 Average,BALG=FIFO Buffer,NSAM=2,N=2");
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
fetchRecordOrDie("wf", wfaddr);
|
||||
fetchRecordOrDie("comp", caddr);
|
||||
|
||||
writeToWaveform(&wfaddr, 4, 1., 2., 3., 4.);
|
||||
|
||||
dbScanLock(caddr.precord);
|
||||
dbProcess(caddr.precord);
|
||||
|
||||
checkArrD("comp", 2, 1.5, 3.5, 0, 0);
|
||||
dbScanUnlock(caddr.precord);
|
||||
|
||||
testIocShutdownOk();
|
||||
testdbCleanup();
|
||||
}
|
||||
|
||||
void
|
||||
testNto1AveragePartial(void) {
|
||||
double buf = 0.0;
|
||||
@@ -517,6 +549,36 @@ testNto1AveragePartial(void) {
|
||||
testdbCleanup();
|
||||
}
|
||||
|
||||
void
|
||||
testNtoMPartial(void) {
|
||||
DBADDR wfaddr, caddr;
|
||||
|
||||
testDiag("Test Average, N to M, Partial");
|
||||
|
||||
testdbPrepare();
|
||||
testdbReadDatabase("recTestIoc.dbd", NULL, NULL);
|
||||
recTestIoc_registerRecordDeviceDriver(pdbbase);
|
||||
testdbReadDatabase("compressTest.db", NULL, "INP=wf,ALG=N to 1 Average,BALG=FIFO Buffer,NSAM=2,N=3,PBUF=YES");
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
fetchRecordOrDie("wf", wfaddr);
|
||||
fetchRecordOrDie("comp", caddr);
|
||||
|
||||
writeToWaveform(&wfaddr, 4, 1., 2., 3., 4.);
|
||||
|
||||
dbScanLock(caddr.precord);
|
||||
dbProcess(caddr.precord);
|
||||
|
||||
checkArrD("comp", 2, 2.0, 4.0, 0, 0);
|
||||
dbScanUnlock(caddr.precord);
|
||||
|
||||
testIocShutdownOk();
|
||||
testdbCleanup();
|
||||
}
|
||||
|
||||
void
|
||||
testNto1LowValue(void) {
|
||||
double buf = 0.0;
|
||||
@@ -634,12 +696,14 @@ testAIAveragePartial(void) {
|
||||
|
||||
MAIN(compressTest)
|
||||
{
|
||||
testPlan(132);
|
||||
testPlan(134);
|
||||
testFIFOCirc();
|
||||
testLIFOCirc();
|
||||
testArrayAverage();
|
||||
testNto1Average();
|
||||
testNto2Average();
|
||||
testNto1AveragePartial();
|
||||
testNtoMPartial();
|
||||
testAIAveragePartial();
|
||||
testNto1LowValue();
|
||||
return testDone();
|
||||
|
||||
Reference in New Issue
Block a user