[Kst] extragear/graphics/kst/tests
Adam Treat
treat at kde.org
Fri Oct 13 00:23:02 CEST 2006
SVN commit 594970 by treat:
*Add dirfile testcase to testrvector
*Check an actual dirfile testcase of 15 frames
The skip frames tests currently fail for calculating
the nf and f0 in various scenarios.
It seems my expectations for what skip will do differ
from the current implementation. Consider the given testcase
where we have 15 items indexed from 0 to 14. The RVector is
created with nf = -1 (readToEOF), f0 set to 0 (first frame) and
a skip value of 5. I would expect that the result would be
a vector with 3 items {0, 5, 10}. Item #14 does not fit the
the skip frame, thus the size of the vector is 3 and the number
of frames is 11 (the count of the items between 0 and 10 inclusive).
This does not currently pass in trunk.
CCMAIL: netterfield at astro.utoronto.ca
M +1 -1 dirfile_maker/dirfile_maker.c
A dirfile_testcase (directory)
A dirfile_testcase/15count (directory)
AM dirfile_testcase/15count/cos
AM dirfile_testcase/15count/fcount
A dirfile_testcase/15count/format
AM dirfile_testcase/15count/scount
AM dirfile_testcase/15count/sine
AM dirfile_testcase/15count/ssine
M +1 -1 runregression.sh
M +110 -6 testrvector.cpp
--- trunk/extragear/graphics/kst/tests/dirfile_maker/dirfile_maker.c #594969:594970
@@ -93,10 +93,10 @@
x = cos(2.0*M_PI*x/100.0);
write(df[COS].fp, &x, sizeof(float));
}
- count++;
printf("writing frame %d \r", count);
fflush(stdout);
usleep(200000);
+ count++;
}
return (42);
}
** trunk/extragear/graphics/kst/tests/dirfile_testcase/15count/cos #property svn:mime-type
+ application/octet-stream
** trunk/extragear/graphics/kst/tests/dirfile_testcase/15count/fcount #property svn:mime-type
+ application/octet-stream
** trunk/extragear/graphics/kst/tests/dirfile_testcase/15count/scount #property svn:mime-type
+ application/octet-stream
** trunk/extragear/graphics/kst/tests/dirfile_testcase/15count/sine #property svn:mime-type
+ application/octet-stream
** trunk/extragear/graphics/kst/tests/dirfile_testcase/15count/ssine #property svn:mime-type
+ application/octet-stream
--- trunk/extragear/graphics/kst/tests/runregression.sh #594969:594970
@@ -43,7 +43,7 @@
fi
echo "-----------------------------------------------------------" >> $CONSOLELOG
echo "Running test: $i" >> $CONSOLELOG
- output=`$VALGRIND ./$i 2>&1`
+ output=`$VALGRIND ./$i $* 2>&1`
FAILED=$?
echo "$output" | grep -v QPixmap >>$CONSOLELOG
if [ $FAILED -gt 0 ]; then
--- trunk/extragear/graphics/kst/tests/testrvector.cpp #594969:594970
@@ -13,6 +13,7 @@
#include <kstdataobjectcollection.h>
#include <kstandarddirs.h>
#include <ktempfile.h>
+#include <qdir.h>
#include <qfile.h>
#include "kstrvector.h"
@@ -36,8 +37,8 @@
printf("Test [%s] failed.\n", text.latin1());
}
}
-
+
//////////////////////////////////////////////////////////////////////////////
void testAscii() {
QFile *qf;
@@ -251,7 +252,6 @@
rvp->reload();
doTest(!rvp->isValid());
}
-
}
@@ -261,7 +261,111 @@
//////////////////////////////////////////////////////////////////////////////
-void testDirfile() {
+void testDirfile(const char *srcfile) {
+
+ Q_UNUSED(srcfile);
+ //WARNING! These tests assume that the dirfile was generated with dirfile_maker
+
+ //FIXME handle dirfile passed from commandline...
+
+ {
+ QString fifteen = QDir::currentDirPath() + QDir::separator() + QString("dirfile_testcase") +
+ QDir::separator() + QString("15count");
+ if (!QFile::exists(fifteen + QDir::separator() + "format")) {
+ return;
+ }
+ printf("Opening dirfile = %s for test.\n", fifteen.latin1());
+
+ KstDataSourcePtr dsp = KstDataSource::loadSource(fifteen);
+ dsp->update(0);
+
+ doTest(dsp);
+ doTest(dsp->isValid());
+ doTest(dsp->isValidField("INDEX"));
+ doTest(dsp->frameCount("INDEX") == 15);
+ doTest(dsp->isValidField("cos"));
+ doTest(dsp->isValidField("fcount"));
+ doTest(dsp->isValidField("scount"));
+ doTest(dsp->isValidField("sine"));
+ doTest(dsp->isValidField("ssine"));
+ doTest(!dsp->isValidField("foo"));
+
+ //TODO test samples per frame?
+
+ doTest(dsp->fileName() == fifteen);
+ doTest(dsp->fieldList().count() == 6);
+ doTest(dsp->fieldListIsComplete());
+
+ doTest(!dsp->isEmpty());
+
+ {
+ //Skip FIVE frames...
+ KstRVectorPtr rvp = new KstRVector(dsp, "1", "RVTestDirfile", 0, -1, 5, true, false);
+ rvp->update(0);
+
+ //We should have length equal to three... items {0, 5, 10}
+ //NOTE: The last item, index #14, does not fit in the skip boundary...
+ doTest(rvp->length() == 3);
+
+ //The numFrames should report 11 as it lies on the skip boundary
+ doTest(rvp->numFrames() == 11);
+ //The numFrames should report 0 as it lies on the skip boundary
+ doTest(rvp->startFrame() == 0);
+
+ doTest(rvp->reqNumFrames() == -1);
+ doTest(rvp->reqStartFrame() == 0);
+
+ doTest(rvp->readToEOF() == true);
+ doTest(rvp->countFromEOF() == false);
+ doTest(rvp->doSkip() == true);
+ doTest(rvp->skip() == 5);
+ }
+ {
+ //Skip FIVE frames...
+ KstRVectorPtr rvp = new KstRVector(dsp, "1", "RVTestDirfile", 3, -1, 5, true, false);
+ rvp->update(0);
+
+ //We should have length equal to three... items {3, 8, 13}
+ doTest(rvp->length() == 3);
+
+ //The numFrames should still report 11 as it lies on the skip boundary
+ doTest(rvp->numFrames() == 11);
+ //The numFrames should report 3 as it lies on the skip boundary and was requested
+ doTest(rvp->startFrame() == 3);
+
+ doTest(rvp->reqNumFrames() == -1);
+ doTest(rvp->reqStartFrame() == 3);
+
+ doTest(rvp->readToEOF() == true);
+ doTest(rvp->countFromEOF() == false);
+ doTest(rvp->doSkip() == true);
+ doTest(rvp->skip() == 5);
+ }
+ {
+ //Skip FIVE frames...
+ KstRVectorPtr rvp = new KstRVector(dsp, "1", "RVTestDirfile", 0, 11, 5, true, false);
+ rvp->update(0);
+
+ //We should have length equal to three... items {0, 5, 10}
+ doTest(rvp->length() == 3);
+
+ //The numFrames should still report 11 as it lies on the skip boundary
+ doTest(rvp->numFrames() == 11);
+ //The numFrames should still report 0 as it lies on the skip boundary
+ doTest(rvp->startFrame() == 0);
+
+ doTest(rvp->reqNumFrames() == 11);
+ doTest(rvp->reqStartFrame() == 0);
+
+ doTest(rvp->readToEOF() == false);
+ doTest(rvp->countFromEOF() == false);
+ doTest(rvp->doSkip() == true);
+ doTest(rvp->skip() == 5);
+ }
+
+ //TODO countFromEOF tests
+
+ }
}
@@ -291,7 +395,7 @@
//////////////////////////////////////////////////////////////////////////////
-void doTests() {
+void doTests(const char *srcfile) {
QStringList plugins = KstDataSource::pluginList();
for (QStringList::ConstIterator i = plugins.begin(); i != plugins.end(); ++i) {
printf("Found data source plugin: %s\n", (*i).latin1());
@@ -310,7 +414,7 @@
}
if (plugins.contains("DirFile Reader")) {
- testDirfile();
+ testDirfile(srcfile);
} else {
printf("Not running tests for dirfile - couldn't find plugin.\n");
}
@@ -354,7 +458,7 @@
KConfig *kConfigObject = new KConfig("kstdatarc", false, false);
KstDataSource::setupOnStartup(kConfigObject);
- doTests();
+ doTests(argc ? argv[1] : "");
// Don't put tests in main because we need to ensure that no KstObjects
// remain past the exit handler
More information about the Kst
mailing list