forked from enlightenment/efl
Add unit tests + coverage support to evas, for Tasn.
unit tests : make check coverage : make coverage SVN revision: 61167
This commit is contained in:
parent
049ee49bc9
commit
e9518f1521
|
@ -47,7 +47,19 @@ evas-direct3d.pc.in \
|
|||
evas-software-16-wince.pc.in \
|
||||
evas-software-sdl.pc.in \
|
||||
evas.spec.in \
|
||||
evas.spec
|
||||
evas.spec \
|
||||
m4/ac_attribute.m4 \
|
||||
m4/efl_coverage.m4 \
|
||||
m4/efl_doxygen.m4 \
|
||||
m4/efl_fnmatch.m4 \
|
||||
m4/efl_path_max.m4 \
|
||||
m4/efl_pthread.m4 \
|
||||
m4/efl_tests.m4 \
|
||||
m4/evas_check_engine.m4 \
|
||||
m4/evas_check_loader.m4 \
|
||||
m4/evas_converter.m4 \
|
||||
m4/evas_dither.m4 \
|
||||
m4/evas_scaler.m4
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = evas.pc
|
||||
|
@ -108,8 +120,57 @@ if BUILD_ENGINE_SOFTWARE_SDL
|
|||
pkgconfig_DATA += evas-software-sdl.pc
|
||||
endif
|
||||
|
||||
.PHONY: doc
|
||||
.PHONY: doc coverage
|
||||
|
||||
doc:
|
||||
@echo "entering doc/"
|
||||
$(MAKE) -C doc doc
|
||||
|
||||
# Unit tests
|
||||
|
||||
if EFL_ENABLE_TESTS
|
||||
|
||||
check-local:
|
||||
@./src/tests/evas_suite
|
||||
|
||||
else
|
||||
|
||||
check-local:
|
||||
@echo "reconfigure with --enable-tests"
|
||||
|
||||
endif
|
||||
|
||||
# Coverage report
|
||||
|
||||
if EFL_ENABLE_COVERAGE
|
||||
lcov-reset:
|
||||
@rm -rf coverage
|
||||
@find . -name "*.gcda" -exec rm {} \;
|
||||
@lcov --directory . --zerocounters
|
||||
|
||||
lcov-report:
|
||||
@mkdir coverage
|
||||
@lcov --compat-libtool --directory $(top_srcdir)/src --capture --output-file coverage/coverage.info
|
||||
@lcov -l coverage/coverage.info |grep "\\.h" |cut -d " " -f 2 > coverage/remove
|
||||
@lcov -r coverage/coverage.info `cat coverage/remove` > coverage/coverage.cleaned.info
|
||||
@rm coverage/remove
|
||||
@mv coverage/coverage.cleaned.info coverage/coverage.info
|
||||
@genhtml -t "$(PACKAGE_STRING)" -o coverage coverage/coverage.info
|
||||
|
||||
coverage:
|
||||
@make lcov-reset
|
||||
@make check
|
||||
@make lcov-report
|
||||
else
|
||||
lcov-reset:
|
||||
@echo "reconfigure with --enable-coverage"
|
||||
|
||||
lcov-report:
|
||||
@echo "reconfigure with --enable-coverage"
|
||||
|
||||
coverage:
|
||||
@echo "reconfigure with --enable-tests --enable-coverage"
|
||||
endif
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -rf coverage
|
||||
|
|
|
@ -1668,6 +1668,19 @@ AC_ARG_ENABLE([build-examples],
|
|||
[build_examples="no"])
|
||||
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x${build_examples}" = "xyes"])
|
||||
|
||||
## Unit tests, coverage
|
||||
|
||||
EFL_CHECK_TESTS([enable_tests="yes"], [enable_tests="no"])
|
||||
|
||||
EFL_CHECK_COVERAGE([${enable_tests}], [enable_coverage="yes"], [enable_coverage="no"])
|
||||
EVAS_CFLAGS="${EVAS_CFLAGS} ${EFL_COVERAGE_CFLAGS}"
|
||||
EVAS_LIBS="${EVAS_LIBS} ${EFL_COVERAGE_LIBS}"
|
||||
if test "x$enable_coverage" = "xyes" ; then
|
||||
EVAS_CFLAGS="${EVAS_CFLAGS} ${EFL_DEBUG_CFLAGS}"
|
||||
fi
|
||||
|
||||
AC_SUBST(EVAS_CFLAGS)
|
||||
AC_SUBST(EVAS_LIBS)
|
||||
|
||||
#####################################################################
|
||||
## Fill in flags
|
||||
|
@ -1765,6 +1778,7 @@ src/static_deps/Makefile
|
|||
src/static_deps/liblinebreak/Makefile
|
||||
src/lib/include/Makefile
|
||||
src/examples/Makefile
|
||||
src/tests/Makefile
|
||||
README
|
||||
evas.spec
|
||||
])
|
||||
|
@ -1940,6 +1954,16 @@ echo " 32bpp Rotation 270......: $conv_32_rgb_rot_270"
|
|||
echo
|
||||
echo "Documentation.............: ${build_doc}"
|
||||
echo "Examples..................: install:${install_examples} build:${build_examples}"
|
||||
if test "x${enable_tests}" = "xyes" ; then
|
||||
echo "Tests.....................: ${enable_tests} (make check)"
|
||||
else
|
||||
echo "Tests.....................: ${enable_tests}"
|
||||
fi
|
||||
if test "x${enable_coverage}" = "xyes" ; then
|
||||
echo "Coverage..................: ${enable_coverage} (make coverage)"
|
||||
else
|
||||
echo "Coverage..................: ${enable_coverage}"
|
||||
fi
|
||||
echo
|
||||
echo "Compilation............: make (or gmake)"
|
||||
echo " CPPFLAGS.............: $CPPFLAGS"
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
|
||||
dnl That code is public domain and can be freely used or copied.
|
||||
|
||||
dnl Macro that check if coverage support is wanted and, if yes, if
|
||||
dnl lcov is available.
|
||||
|
||||
dnl Usage: EFL_CHECK_COVERAGE(tests [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl The parameter 'tests' is used if a dependency is needed. If set to "yes",
|
||||
dnl the dependency is available.
|
||||
dnl Defines EFL_COVERAGE_CFLAGS and EFL_COVERAGE_LIBS variables
|
||||
dnl Defines the automake conditionnal EFL_ENABLE_COVERAGE
|
||||
|
||||
AC_DEFUN([EFL_CHECK_COVERAGE],
|
||||
[
|
||||
|
||||
dnl configure option
|
||||
|
||||
AC_ARG_ENABLE([coverage],
|
||||
[AC_HELP_STRING([--enable-coverage], [enable coverage profiling instrumentation @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
_efl_enable_coverage="yes"
|
||||
else
|
||||
_efl_enable_coverage="no"
|
||||
fi
|
||||
],
|
||||
[_efl_enable_coverage="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether to use profiling instrumentation])
|
||||
AC_MSG_RESULT([$_efl_enable_coverage])
|
||||
|
||||
dnl lcov check
|
||||
|
||||
if test "x$_efl_enable_coverage" = "xyes" && test ! "x$1" = "xyes" ; then
|
||||
AC_MSG_WARN([Coverage report requested but tests not being built, disable profiling instrumentation.])
|
||||
AC_MSG_WARN([Run configure with --enable-tests])
|
||||
_efl_enable_coverage="no"
|
||||
fi
|
||||
|
||||
if test "x$_efl_enable_coverage" = "xyes" ; then
|
||||
AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
|
||||
if test "x$have_lcov" = "xyes" ; then
|
||||
EFL_COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
EFL_COVERAGE_LIBS="-lgcov"
|
||||
# remove any optimisation flag and force debug symbols
|
||||
EFL_DEBUG_CFLAGS="-g -O0 -DDEBUG"
|
||||
else
|
||||
AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
|
||||
_efl_enable_coverage="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Substitution
|
||||
AC_SUBST(EFL_COVERAGE_CFLAGS)
|
||||
AC_SUBST(EFL_COVERAGE_LIBS)
|
||||
|
||||
AM_CONDITIONAL(EFL_ENABLE_COVERAGE, test "x${_efl_enable_coverage}" = "xyes")
|
||||
|
||||
AS_IF([test "x$_efl_enable_coverage" = "xyes"], [$2], [$3])
|
||||
])
|
||||
|
||||
dnl End of efl_coverage.m4
|
|
@ -0,0 +1,43 @@
|
|||
dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
|
||||
dnl That code is public domain and can be freely used or copied.
|
||||
|
||||
dnl Macro that check if tests programs are wanted and if yes, if
|
||||
dnl the Check library is available.
|
||||
|
||||
dnl Usage: EFL_CHECK_TESTS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl Define the automake conditionnal EFL_ENABLE_TESTS
|
||||
|
||||
AC_DEFUN([EFL_CHECK_TESTS],
|
||||
[
|
||||
|
||||
dnl configure option
|
||||
|
||||
AC_ARG_ENABLE([tests],
|
||||
[AC_HELP_STRING([--enable-tests], [enable tests @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
_efl_enable_tests="yes"
|
||||
else
|
||||
_efl_enable_tests="no"
|
||||
fi
|
||||
],
|
||||
[_efl_enable_tests="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether tests are built])
|
||||
AC_MSG_RESULT([${_efl_enable_tests}])
|
||||
|
||||
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
|
||||
if test "x${_efl_enable_tests}" = "xyes" ; then
|
||||
PKG_CHECK_MODULES([CHECK],
|
||||
[check >= 0.9.5],
|
||||
[dummy="yes"],
|
||||
[_efl_enable_tests="no"])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_efl_enable_tests}" = "xyes")
|
||||
|
||||
AS_IF([test "x$_efl_enable_tests" = "xyes"], [$1], [$2])
|
||||
])
|
||||
|
||||
dnl End of efl_tests.m4
|
|
@ -1,3 +1,3 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = static_deps lib bin modules examples
|
||||
SUBDIRS = static_deps lib bin modules tests examples
|
||||
|
|
|
@ -12,6 +12,7 @@ AM_CPPFLAGS = \
|
|||
@FREETYPE_CFLAGS@ \
|
||||
@EET_CFLAGS@ \
|
||||
@FONTCONFIG_CFLAGS@ \
|
||||
@EVAS_CFLAGS@ \
|
||||
@EINA_CFLAGS@ \
|
||||
@EVIL_CFLAGS@ \
|
||||
@PIXMAN_CFLAGS@
|
||||
|
@ -53,9 +54,14 @@ evas_stats.c \
|
|||
evas_map.c \
|
||||
evas_gl.c
|
||||
|
||||
libevas_canvas_la_LIBADD = @EVIL_LIBS@
|
||||
#evas_object_textgrid.c
|
||||
|
||||
libevas_canvas_la_LIBADD = @EVAS_LIBS@ @EVIL_LIBS@
|
||||
|
||||
if EVAS_USE_LINEBREAK
|
||||
AM_CPPFLAGS += @LINEBREAK_CFLAGS@
|
||||
libevas_canvas_la_LIBADD += @LINEBREAK_LIBS@
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
rm -rf *.gcno
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/include \
|
||||
-I$(top_builddir)/src/include \
|
||||
-I$(top_builddir)/src/lib \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
@EINA_CFLAGS@ \
|
||||
@CHECK_CFLAGS@
|
||||
|
||||
if EFL_ENABLE_TESTS
|
||||
|
||||
check_PROGRAMS = evas_suite
|
||||
|
||||
evas_suite_SOURCES = \
|
||||
evas_suite.c \
|
||||
evas_test_init.c \
|
||||
evas_suite.h
|
||||
|
||||
evas_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libevas.la @EINA_LIBS@
|
||||
|
||||
endif
|
|
@ -0,0 +1,101 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Evas.h>
|
||||
|
||||
#include "evas_suite.h"
|
||||
|
||||
typedef struct _Evas_Test_Case Evas_Test_Case;
|
||||
|
||||
struct _Evas_Test_Case
|
||||
{
|
||||
const char *test_case;
|
||||
void (*build)(TCase *tc);
|
||||
};
|
||||
|
||||
static const Evas_Test_Case etc[] = {
|
||||
{ "Evas", evas_test_init },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
_list_tests(void)
|
||||
{
|
||||
const Evas_Test_Case *itr;
|
||||
|
||||
itr = etc;
|
||||
fputs("Available Test Cases:\n", stderr);
|
||||
for (; itr->test_case; itr++)
|
||||
fprintf(stderr, "\t%s\n", itr->test_case);
|
||||
}
|
||||
static Eina_Bool
|
||||
_use_test(int argc, const char **argv, const char *test_case)
|
||||
{
|
||||
if (argc < 1)
|
||||
return 1;
|
||||
|
||||
for (; argc > 0; argc--, argv++)
|
||||
if (strcmp(test_case, *argv) == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Suite *
|
||||
evas_suite_build(int argc, const char **argv)
|
||||
{
|
||||
TCase *tc;
|
||||
Suite *s;
|
||||
int i;
|
||||
|
||||
s = suite_create("Evas");
|
||||
|
||||
for (i = 0; etc[i].test_case; ++i)
|
||||
{
|
||||
if (!_use_test(argc, argv, etc[i].test_case)) continue;
|
||||
tc = tcase_create(etc[i].test_case);
|
||||
|
||||
etc[i].build(tc);
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
tcase_set_timeout(tc, 0);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Suite *s;
|
||||
SRunner *sr;
|
||||
int i, failed_count;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((strcmp(argv[i], "-h") == 0) ||
|
||||
(strcmp(argv[i], "--help") == 0))
|
||||
{
|
||||
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
|
||||
argv[0]);
|
||||
_list_tests();
|
||||
return 0;
|
||||
}
|
||||
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||
(strcmp(argv[i], "--list") == 0))
|
||||
{
|
||||
_list_tests();
|
||||
return 0;
|
||||
}
|
||||
|
||||
s = evas_suite_build(argc - 1, (const char **)argv + 1);
|
||||
sr = srunner_create(s);
|
||||
|
||||
srunner_run_all(sr, CK_ENV);
|
||||
failed_count = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
|
||||
return (failed_count == 0) ? 0 : 255;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _EVAS_SUITE_H
|
||||
#define _EVAS_SUITE_H
|
||||
|
||||
#include <check.h>
|
||||
|
||||
void evas_test_init(TCase *tc);
|
||||
|
||||
|
||||
#endif /* _EVAS_SUITE_H */
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "evas_suite.h"
|
||||
#include "Evas.h"
|
||||
|
||||
START_TEST(evas_simple)
|
||||
{
|
||||
fail_if(evas_init() != 1); /* one init by test suite */
|
||||
fail_if(evas_shutdown() != 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void evas_test_init(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, evas_simple);
|
||||
}
|
Loading…
Reference in New Issue