https://svn.lrde.epita.fr/svn/oln/trunk/milena
I'll extend this to other tests, and I ask everybody to stop using
hard-coded paths to images in tests as of now. Thanks in advance!
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Have morpho tests using input images be independent of the
location of the build tree w.r.t. the source tree by removing
hard-coded paths.
* tests/data.hh.in: New.
* tests/morpho/contrast.cc,
* tests/morpho/dilation.cc,
* tests/morpho/dilation_max_h.cc,
* tests/morpho/erosion.cc,
* tests/morpho/erosion_min_h.cc,
* tests/morpho/gradient.cc,
* tests/morpho/hit_or_miss.cc,
* tests/morpho/laplacian.cc,
* tests/morpho/opening_area.cc,
* tests/morpho/thinning.cc: Use tests/data.hh to get the path to
the img/ directory.
* tests/tests.mk (AM_CPPFLAGS): Add -I$(top_builddir)/milena.
data.hh.in | 39 +++++++++++++++++++++++++++++++++++++++
morpho/contrast.cc | 4 +++-
morpho/dilation.cc | 4 +++-
morpho/dilation_max_h.cc | 4 +++-
morpho/erosion.cc | 4 +++-
morpho/erosion_min_h.cc | 4 +++-
morpho/gradient.cc | 3 ++-
morpho/hit_or_miss.cc | 9 ++++++++-
morpho/laplacian.cc | 4 +++-
morpho/opening_area.cc | 4 +++-
morpho/thinning.cc | 10 ++++++----
tests.mk | 6 ++++--
12 files changed, 80 insertions(+), 15 deletions(-)
Index: tests/tests.mk
--- tests/tests.mk (revision 1637)
+++ tests/tests.mk (working copy)
@@ -1,12 +1,14 @@
## FIXME: Revamp (see Olena 0.11's test suite).
-AM_CPPFLAGS = -I$(top_srcdir)/milena
+# Look for Milena header in srcdir and for (generated) test headers
+# (like data.hh) in builddir.
+AM_CPPFLAGS = -I$(top_srcdir)/milena -I$(top_builddir)/milena
# FIXME: Add
#
# AM_CXXFLAGS = $(CXXFLAGS_STRICT) $(CXXFLAGS_DEBUG)
#
# when oln.m4 is available in the distribution, instead of using the
-# set-by-hand TESTS_CXXFLAGS.
+# hand-made TESTS_CXXFLAGS.
TESTS_CXXFLAGS = @TESTS_CXXFLAGS@
AM_CXXFLAGS = $(TESTS_CXXFLAGS)
Index: tests/data.hh.in
--- tests/data.hh.in (revision 0)
+++ tests/data.hh.in (revision 0)
@@ -0,0 +1,39 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef TESTS_DATA_HH
+# define TESTS_DATA_HH
+
+# include <string>
+
+/** \brief The absolute path to the img directory of Milena.
+
+ Macros are evil, but they save us an extra compilation unit here
+ (as well as additional burden in Makefiles, too.). */
+# define MLN_IMG_DIR "@abs_top_srcdir@/milena/img"
+
+#endif // ! TESTS_DATA_HH
Index: tests/morpho/contrast.cc
--- tests/morpho/contrast.cc (revision 1637)
+++ tests/morpho/contrast.cc (working copy)
@@ -41,6 +41,8 @@
#include <mln/morpho/contrast.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -51,7 +53,7 @@
border::thickness = 1;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/tiny.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out = morpho::contrast(lena, rect);
io::pgm::save(out, "out.pgm");
Index: tests/morpho/gradient.cc
--- tests/morpho/gradient.cc (revision 1637)
+++ tests/morpho/gradient.cc (working copy)
@@ -39,6 +39,7 @@
#include <mln/value/int_u8.hh>
#include <mln/morpho/gradient.hh>
+#include "tests/data.hh"
int main()
@@ -50,7 +51,7 @@
border::thickness = 2;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/tiny.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save( morpho::gradient(lena, rect),
"out.pgm" );
Index: tests/morpho/erosion.cc
--- tests/morpho/erosion.cc (revision 1637)
+++ tests/morpho/erosion.cc (working copy)
@@ -51,6 +51,8 @@
#include <mln/convert/to_p_array.hh>
#include <mln/convert/to_window.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -75,7 +77,7 @@
// 25 66 15
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
// trace::quiet = false;
Index: tests/morpho/thinning.cc
--- tests/morpho/thinning.cc (revision 1637)
+++ tests/morpho/thinning.cc (working copy)
@@ -43,6 +43,8 @@
#include <mln/morpho/thinning.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -63,12 +65,12 @@
{
image2d<bool> pic;
- io::pbm::load(pic, "../../img/picasso.pbm");
+ io::pbm::load(pic, MLN_IMG_DIR "/picasso.pbm");
io::pbm::save(morpho::thinning(pic, win_fg, win_bg), "out.pbm" );
}
+ // FIXME: Dead code?
// {
-// image2d<int_u8> pic = io::pgm::load("../img/picasso.pgm");
-// io::pgm::save( morpho::thinning(pic, win_fg, win_bg),
-// "out.pgm" );
+// image2d<int_u8> pic = io::pgm::load(MLN_IMG_DIR "/picasso.pgm");
+// io::pgm::save( morpho::thinning(pic, win_fg, win_bg), "out.pgm" );
// }
}
Index: tests/morpho/dilation_max_h.cc
--- tests/morpho/dilation_max_h.cc (revision 1637)
+++ tests/morpho/dilation_max_h.cc (working copy)
@@ -43,6 +43,8 @@
#include <mln/convert/to_p_array.hh>
#include <mln/convert/to_window.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -53,7 +55,7 @@
border::thickness = 66;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
{
p_array<point2d> vec = convert::to_p_array(rec, point2d::origin);
Index: tests/morpho/hit_or_miss.cc
--- tests/morpho/hit_or_miss.cc (revision 1637)
+++ tests/morpho/hit_or_miss.cc (working copy)
@@ -45,6 +45,8 @@
#include <mln/morpho/hit_or_miss.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -76,8 +78,13 @@
border::thickness = 2;
image2d<bool> pic;
- io::pbm::load(pic, "../../img/picasso.pbm");
+ io::pbm::load(pic, MLN_IMG_DIR "/picasso.pbm");
image2d<bool> out = morpho::hit_or_miss(pic, win_hit, win_miss);
+ // FIXME: We shall handle out images as well as input images.
+ // Currently, output images are named `out.*', and each test
+ // overwrites the product(s) of the previous one. Moreover, nothing
+ // is cleaned upon `make clean', which will probably bother `make
+ // distcheck'.
io::pbm::save(out, "out.pbm");
mln_postcondition(morpho::hit_or_miss(morpho::complementation(pic),
Index: tests/morpho/dilation.cc
--- tests/morpho/dilation.cc (revision 1637)
+++ tests/morpho/dilation.cc (working copy)
@@ -51,6 +51,8 @@
#include <mln/convert/to_p_array.hh>
#include <mln/convert/to_window.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -61,7 +63,7 @@
border::thickness = 66;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
// {
// image2d<int_u8> out(lena.domain());
Index: tests/morpho/laplacian.cc
--- tests/morpho/laplacian.cc (revision 1637)
+++ tests/morpho/laplacian.cc (working copy)
@@ -43,6 +43,8 @@
#include <mln/morpho/laplacian.hh>
+#include "tests/data.hh"
+
int main()
@@ -54,7 +56,7 @@
border::thickness = 2;
image2d<int_u8> tiny;
- io::pgm::load(tiny, "../../img/tiny.pgm");
+ io::pgm::load(tiny, MLN_IMG_DIR "/tiny.pgm");
image2d<int> lap(tiny.domain());
morpho::laplacian(tiny, rect, lap);
Index: tests/morpho/opening_area.cc
--- tests/morpho/opening_area.cc (revision 1637)
+++ tests/morpho/opening_area.cc (working copy)
@@ -39,6 +39,8 @@
#include <mln/morpho/opening_area.hh>
+#include "tests/data.hh"
+
int main()
@@ -47,7 +49,7 @@
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
image2d<int_u8> out(lena.domain());
morpho::opening_area(lena, c4(), 510, out);
Index: tests/morpho/erosion_min_h.cc
--- tests/morpho/erosion_min_h.cc (revision 1637)
+++ tests/morpho/erosion_min_h.cc (working copy)
@@ -43,6 +43,8 @@
#include <mln/convert/to_p_array.hh>
#include <mln/convert/to_window.hh>
+#include "tests/data.hh"
+
int main()
{
@@ -53,7 +55,7 @@
border::thickness = 66;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
{
p_array<point2d> vec = convert::to_p_array(rec, point2d::origin);