Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to integrate unit test provided by glib and gtk-doc.
- Loading branch information
Showing
10 changed files
with
308 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# GLIB - Library of useful C routines | ||
|
||
#GTESTER = gtester # for non-GLIB packages | ||
GTESTER = gtester # for the GLIB package | ||
GTESTER_REPORT = gtester-report # for the GLIB package | ||
|
||
# initialize variables for unconditional += appending | ||
EXTRA_DIST = | ||
TEST_PROGS = | ||
|
||
### testing rules | ||
|
||
# test: run all tests in cwd and subdirs | ||
test: test-nonrecursive | ||
# if OS_UNIX | ||
@ for subdir in $(SUBDIRS) . ; do \ | ||
test "$$subdir" = "." -o "$$subdir" = "po" || \ | ||
( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \ | ||
done | ||
# endif | ||
|
||
# test-nonrecursive: run tests only in cwd | ||
test-nonrecursive: ${TEST_PROGS} | ||
# if OS_UNIX | ||
@test -z "${TEST_PROGS}" || MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) ${GTESTER} --verbose ${TEST_PROGS} | ||
# endif | ||
|
||
# test-report: run tests in subdirs and generate report | ||
# perf-report: run tests in subdirs with -m perf and generate report | ||
# full-report: like test-report: with -m perf and -m slow | ||
test-report perf-report full-report: ${TEST_PROGS} | ||
@test -z "${TEST_PROGS}" || { \ | ||
case $@ in \ | ||
test-report) test_options="-k";; \ | ||
perf-report) test_options="-k -m=perf";; \ | ||
full-report) test_options="-k -m=perf -m=slow";; \ | ||
esac ; \ | ||
if test -z "$$GTESTER_LOGDIR" ; then \ | ||
${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \ | ||
elif test -n "${TEST_PROGS}" ; then \ | ||
${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \ | ||
fi ; \ | ||
} | ||
@ ignore_logdir=true ; \ | ||
if test -z "$$GTESTER_LOGDIR" ; then \ | ||
GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \ | ||
ignore_logdir=false ; \ | ||
fi ; \ | ||
for subdir in $(SUBDIRS) . ; do \ | ||
test "$$subdir" = "." -o "$$subdir" = "po" || \ | ||
( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \ | ||
done ; \ | ||
$$ignore_logdir || { \ | ||
echo '<?xml version="1.0"?>' > $@.xml ; \ | ||
echo '<report-collection>' >> $@.xml ; \ | ||
echo '<info>' >> $@.xml ; \ | ||
echo ' <package>$(PACKAGE)</package>' >> $@.xml ; \ | ||
echo ' <version>$(VERSION)</version>' >> $@.xml ; \ | ||
echo '</info>' >> $@.xml ; \ | ||
for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \ | ||
sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \ | ||
done ; \ | ||
echo >> $@.xml ; \ | ||
echo '</report-collection>' >> $@.xml ; \ | ||
rm -rf "$$GTESTER_LOGDIR"/ ; \ | ||
${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \ | ||
} | ||
.PHONY: test test-report perf-report full-report test-nonrecursive | ||
|
||
.PHONY: lcov genlcov lcov-clean | ||
# use recursive makes in order to ignore errors during check | ||
lcov: | ||
-$(MAKE) $(AM_MAKEFLAGS) -k check | ||
$(MAKE) $(AM_MAKEFLAGS) genlcov | ||
|
||
# we have to massage the lcov.info file slightly to hide the effect of libtool | ||
# placing the objects files in the .libs/ directory separate from the *.c | ||
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda | ||
genlcov: | ||
rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda | ||
$(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool | ||
LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --show-details glib-lcov.info | ||
|
||
lcov-clean: | ||
-$(LTP) --directory $(top_builddir) -z | ||
-rm -rf glib-lcov.info glib-lcov | ||
-find -name '*.gcda' -print | xargs rm | ||
|
||
# run tests in cwd as part of make check | ||
check-local: test-nonrecursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include $(top_srcdir)/Makefile.decl | ||
|
||
SUBDIRS = reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include $(top_srcdir)/Makefile.decl | ||
|
||
SUBDIRS = libfm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
## Process this file with automake to produce Makefile.in | ||
|
||
NULL= | ||
|
||
# We require automake 1.6 at least. | ||
AUTOMAKE_OPTIONS = 1.6 | ||
|
||
# This is a blank Makefile.am for using gtk-doc. | ||
# Copy this to your project's API docs directory and modify the variables to | ||
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples | ||
# of using the various options. | ||
|
||
# The name of the module, e.g. 'glib'. | ||
DOC_MODULE=libfm | ||
|
||
# Uncomment for versioned docs and specify the version of the module, e.g. '2'. | ||
#DOC_MODULE_VERSION=2 | ||
|
||
|
||
# The top-level SGML file. You can change this if you want to. | ||
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml | ||
|
||
# The directory containing the source code. Relative to $(srcdir). | ||
# gtk-doc will search all .c & .h files beneath here for inline comments | ||
# documenting the functions and macros. | ||
# e.g. DOC_SOURCE_DIR=../../../gtk | ||
DOC_SOURCE_DIR= $(top_srcdir)/src | ||
|
||
# Extra options to pass to gtkdoc-scangobj. Not normally needed. | ||
SCANGOBJ_OPTIONS= | ||
|
||
# Extra options to supply to gtkdoc-scan. | ||
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" | ||
SCAN_OPTIONS= | ||
|
||
# Extra options to supply to gtkdoc-mkdb. | ||
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml | ||
MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=fm | ||
|
||
# Extra options to supply to gtkdoc-mktmpl | ||
# e.g. MKTMPL_OPTIONS=--only-section-tmpl | ||
MKTMPL_OPTIONS= | ||
|
||
# Extra options to supply to gtkdoc-mkhtml | ||
MKHTML_OPTIONS= | ||
|
||
# Extra options to supply to gtkdoc-fixref. Not normally needed. | ||
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html | ||
FIXXREF_OPTIONS= | ||
|
||
# Used for dependencies. The docs will be rebuilt if any of these change. | ||
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h | ||
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c | ||
HFILE_GLOB= \ | ||
$(top_srcdir)/src/*.h \ | ||
$(top_srcdir)/src/base/*.h \ | ||
$(top_srcdir)/src/job/*.h \ | ||
$(top_srcdir)/src/gtk/*.h \ | ||
$(NULL) | ||
|
||
CFILE_GLOB=$(top_srcdir)/src/*.c \ | ||
$(top_srcdir)/src/base/*.c \ | ||
$(top_srcdir)/src/job/*.c \ | ||
$(top_srcdir)/src/gtk/*.c \ | ||
$(NULL) | ||
|
||
# Extra header to include when scanning, which are not under DOC_SOURCE_DIR | ||
# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h | ||
EXTRA_HFILES= | ||
|
||
# Header files to ignore when scanning. Use base file name, no paths | ||
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h | ||
IGNORE_HFILES= \ | ||
fm-marshal.h \ | ||
fm-gtk-marshal.h \ | ||
main-win.h \ | ||
dbus-utils.h \ | ||
fm-udisks.h \ | ||
g-udisks-device.h \ | ||
g-udisks-drive.h \ | ||
g-udisks-mount.h \ | ||
g-udisks-volume.h \ | ||
g-udisks-volume-monitor.h \ | ||
udisks-device.h \ | ||
udisks.h \ | ||
fm-app-lookup.h \ | ||
exo-icon-view.h \ | ||
exo-marshal.h \ | ||
exo-private.h \ | ||
exo-string.h \ | ||
exo-tree-view.h \ | ||
$(NULL) | ||
|
||
# Images to copy into HTML directory. | ||
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png | ||
HTML_IMAGES= | ||
|
||
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). | ||
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml | ||
content_files= | ||
|
||
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded | ||
# These files must be listed here *and* in content_files | ||
# e.g. expand_content_files=running.sgml | ||
expand_content_files= | ||
|
||
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. | ||
# Only needed if you are using gtkdoc-scangobj to dynamically query widget | ||
# signals and properties. | ||
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) | ||
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) | ||
GTKDOC_CFLAGS= \ | ||
-I$(top_srcdir) \ | ||
-I$(top_builddir) \ | ||
$(GTK_CFLAGS) | ||
GTKDOC_LIBS= \ | ||
$(top_builddir)/src/libfm.la \ | ||
$(top_builddir)/src/libfm-gtk.la \ | ||
$(NULL) | ||
|
||
# This includes the standard gtk-doc make rules, copied by gtkdocize. | ||
include $(top_srcdir)/gtk-doc.make | ||
|
||
# Other files to distribute | ||
# e.g. EXTRA_DIST += version.xml.in | ||
EXTRA_DIST += | ||
|
||
# Files not to distribute | ||
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types | ||
# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt | ||
#DISTCLEANFILES += | ||
|
||
# Comment this out if you want your docs-status tested during 'make check' | ||
if ENABLE_GTK_DOC | ||
#TESTS_ENVIRONMENT = cd $(srcsrc) && | ||
#TESTS = $(GTKDOC_CHECK) | ||
endif | ||
|
||
-include $(top_srcdir)/git.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
include $(top_srcdir)/Makefile.decl | ||
|
||
NULL= | ||
|
||
AM_CPPFLAGS = \ | ||
-I../ \ | ||
-I../base \ | ||
-I../job \ | ||
-I../gtk \ | ||
$(GIO_CFLAGS) \ | ||
$(MENU_CACHE_CFLAGS) \ | ||
$(DBUS_CFLAGS) \ | ||
-Werror-implicit-function-declaration \ | ||
$(NULL) | ||
|
||
noinst_PROGRAMS = $(TEST_PROGS) | ||
|
||
TEST_PROGS += fm-path | ||
fm_path_SOURCES = test-fm-path.c | ||
fm_path_LDADD= \ | ||
$(GLIB_LIBS) \ | ||
$(top_builddir)/src/libfm.la \ | ||
$(NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <fm.h> | ||
|
||
//ignore for test disabled asserts | ||
#ifdef G_DISABLE_ASSERT | ||
#undef G_DISABLE_ASSERT | ||
#endif | ||
|
||
static void double_slash_test_case(void) | ||
{ | ||
FmPath* path = fm_path_new("//tmp/lest"); | ||
g_assert(path); | ||
fm_path_unref(path); | ||
} | ||
|
||
int | ||
main (int argc, char *argv[]) | ||
{ | ||
g_type_init(); | ||
g_test_init (&argc, &argv, NULL); // initialize test program | ||
g_test_add_func ("/BasePath/Base Path New with Double Slash at beggining", | ||
double_slash_test_case); | ||
fm_init(NULL); | ||
return g_test_run(); | ||
} | ||
|