[systemd-commits] 2 commits - configure.ac .gitignore Makefile.am src/.gitignore src/shared src/test
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Sat Jul 13 19:04:23 PDT 2013
.gitignore | 1 +
Makefile.am | 38 ++++++++++++++++++++++++++++++++++++++
configure.ac | 24 ++++++++++++++++++++++++
src/.gitignore | 2 ++
src/shared/test-tables.h | 8 +++++---
src/test/test-tables.c | 3 +++
6 files changed, 73 insertions(+), 3 deletions(-)
New commits:
commit bf502e636be8f76e05b0334b4e78ea7a398ba241
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Jul 13 17:36:03 2013 -0400
test: add trivial test for syscall table and extend table tests to error paths
diff --git a/src/shared/test-tables.h b/src/shared/test-tables.h
index ac7deda..deebec2 100644
--- a/src/shared/test-tables.h
+++ b/src/shared/test-tables.h
@@ -29,15 +29,17 @@ static inline void _test_table(const char *name,
int size) {
int i;
- for (i = 0; i < size; i++) {
+ for (i = 0; i < size + 1; i++) {
const char* val = lookup(i);
- int rev = -1;
+ int rev;
if (val)
rev = reverse(val);
+ else
+ rev = reverse("--no-such--value----");
printf("%s: %d â %s â %d\n", name, i, val, rev);
- if (!val || rev != i)
+ if (i < size ? val == NULL || rev != i : val != NULL || rev != -1)
exit(EXIT_FAILURE);
}
}
diff --git a/src/test/test-tables.c b/src/test/test-tables.c
index dff6431..9a3d3e8 100644
--- a/src/test/test-tables.c
+++ b/src/test/test-tables.c
@@ -43,6 +43,7 @@
#include "unit-name.h"
#include "unit.h"
#include "util.h"
+#include "syscall-list.h"
#include "test-tables.h"
@@ -98,5 +99,7 @@ int main(int argc, char **argv) {
test_table(unit_load_state, UNIT_LOAD_STATE);
test_table(unit_type, UNIT_TYPE);
+ _test_table("syscall", syscall_to_name, syscall_from_name, syscall_max());
+
return EXIT_SUCCESS;
}
commit 6aea6d10f460853111ca8744201ec8dade97de3c
Author: Thomas H.P. Andersen <phomes at gmail.com>
Date: Thu Mar 28 14:54:06 2013 +0100
Add test coverage and generate report with lcov
Enable coverage with --enable-coverage.
"make coverage" will create the report locally,
"make coverage-sync" will upload the report to
http://www.freedesktop.org/software/systemd/coverage/.
Requires lcov version 1.10 to handle naming in systemd and to
use the --no-external option.
[zj: make the coverage at least generate something with
separate build dir, simplify rules a bit: all errors
are mine. ]
diff --git a/.gitignore b/.gitignore
index 5f9ba90..f4f1e45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
/busctl
/cdrom_id
/collect
+/coverage/
/gtk-doc.make
/hostnamectl
/install-tree
diff --git a/Makefile.am b/Makefile.am
index 2283d05..9105274 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1390,6 +1390,44 @@ test_sched_prio_LDADD = \
libsystemd-daemon.la
# ------------------------------------------------------------------------------
+## .PHONY so it always rebuilds it
+.PHONY: coverage lcov-run lcov-report
+
+# run lcov from scratch, always
+coverage:
+ $(MAKE) lcov-run
+ $(MAKE) lcov-report
+
+coverage_dir = coverage
+coverage_opts = --base-directory $(srcdir) --directory $(builddir) --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))'
+
+if ENABLE_COVERAGE
+# reset run coverage tests
+lcov-run:
+ @rm -rf $(coverage_dir)
+ lcov $(coverage_opts) --zerocounters
+ -$(MAKE) check
+
+# generate report based on current coverage data
+lcov-report:
+ $(MKDIR_P) $(coverage_dir)
+ lcov $(coverage_opts) --compat-libtool --capture --no-external \
+ | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info
+ genhtml -t "systemd test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov.info
+ @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html"
+
+# lcov doesn't work properly with vpath builds, make sure that bad
+# output is not uploaded by mistake.
+coverage-sync: coverage
+ test "$(builddir)" = "$(srcdir)"
+ rsync -rlv --delete --omit-dir-times coverage/ $(www_target)/coverage
+
+else
+lcov-run lcov-report:
+ echo "Need to reconfigure with --enable-coverage"
+endif
+
+# ------------------------------------------------------------------------------
systemd_initctl_SOURCES = \
src/initctl/initctl.c
diff --git a/configure.ac b/configure.ac
index 1e196f7..afbe8e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -215,6 +215,29 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-conf
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2])
# ------------------------------------------------------------------------------
+have_coverage=no
+AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
+if test "x$enable_coverage" = "xyes" ; then
+ AC_CHECK_PROG(lcov_found, [lcov], [yes], [no])
+ if test "x$lcov_found" = xno ; then
+ AC_MSG_ERROR([*** lcov support requested but the program was not found])
+ else
+ lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
+ lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
+ if test "$lcov_version_major" -eq 1 -a "$lcov_version_minor" -lt 10; then
+ AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
+ else
+ have_coverage=yes
+ CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
+ -fprofile-arcs \
+ -ftest-coverage])
+ AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
+ fi
+ fi
+fi
+AM_CONDITIONAL(ENABLE_COVERAGE, [test "$have_coverage" = "yes"])
+
+# ------------------------------------------------------------------------------
have_kmod=no
AC_ARG_ENABLE(kmod, AS_HELP_STRING([--disable-kmod], [disable loadable modules support]))
if test "x$enable_kmod" != "xno"; then
@@ -1000,6 +1023,7 @@ AC_MSG_RESULT([
Python Headers: ${have_python_devel}
man pages: ${have_manpages}
gtk-doc: ${enable_gtk_doc}
+ test coverage: ${have_coverage}
Split /usr: ${enable_split_usr}
SysV compatibility: ${SYSTEM_SYSV_COMPAT}
diff --git a/src/.gitignore b/src/.gitignore
index afabb6a..e6ac2d7 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -4,3 +4,5 @@ load-fragment-gperf.gperf
org.freedesktop.systemd1.policy.in
org.freedesktop.systemd1.policy
99-systemd.rules
+*.gcno
+*.gcda
More information about the systemd-commits
mailing list