Generalities
test and benchmark programs are built if the build process is configured to create the "test"
build target. Two ways to do this :
- add the option
"--test"
when configuring Smil with the script config-smil
;
- use
ccmake
to enable the option "BUILD_TEST"
.
- Note
- test and benchmark programs follow the naming convention :
test_XXXX.cpp
and bench_XXXX.cpp
.
test programs
See below an example of test program (this example is in the dev-tools
directory in the source tree : dev-tools/test_template.cpp
).
Note the call to the function pathTestImage()
. This function is defined in the header Smil-build.h
. When you call this function, it will search for an image in the images
directory of the source tree. If it doesn't find it there, it will try to get it in the images
directory of Smil web server.
#include "DMorphoMeasures.hpp"
#include "Smil-build.h"
using namespace smil;
class TestErode : public TestCase
{
virtual void run()
{
char *path;
path = pathTestImage("gray/lena.png");
path = pathTestImage("gray/lena-erode.png");
erode(imIn, imOut);
TEST_ASSERT(imOut == imTruth);
if (retVal != RES_OK)
}
};
class TestDilate : public TestCase
{
virtual void run()
{
char *path;
path = pathTestImage("gray/lena.png");
path = pathTestImage("gray/lena-dilate.png");
dilate(imIn, imOut);
TEST_ASSERT(imOut == imTruth);
if (retVal != RES_OK)
}
};
int main()
{
TestSuite ts;
ADD_TEST(ts, TestErode);
ADD_TEST(ts, TestDilate);
return ts.run();
}
virtual void printSelf(ostream &os=std::cout, string s="") const
printSelf() -
Definition DGraph.hpp:578
Main Image class.
Definition DImage.hpp:57
There are two ways to launch the built test programs (in the build tree).
- launch all tests :
- launch a single test (as an example) :
bench programs
See below an example of benchmark program (this example is in the dev-tools
directory in the source tree : dev-tools/bench_template.cpp
).
#include "Core/include/DCore.h"
#include "DMorpho.h"
using namespace smil;
int main()
{
UINT BENCH_NRUNS = 1E2;
BENCH_IMG_STR(dilate, "hSE", im1, im2, hSE());
BENCH_IMG_STR(dilate, "sSE", im1, im2, sSE());
BENCH_IMG_STR(dilate,
"CrossSE", im1, im2,
CrossSE());
BENCH_IMG_STR(open, "hSE", im1, im2, hSE());
BENCH_IMG_STR(open, "sSE", im1, im2, sSE());
BENCH_IMG_STR(open,
"CrossSE", im1, im2,
CrossSE());
}
Cross structuring element.
Definition DStructuringElement.h:470
There are two ways to launch the built benchmark programs (in the build tree).
- launch all benchmarks :
for b in bin/bench*
do
printf "====== %-24s ======\n" $(basename $b)
$b
done
- launch a single benchmark (as an example) :