From 4dc31b6c94399f90cd9093a16b527e1d5aefc668 Mon Sep 17 00:00:00 2001 From: Robert Roth Date: Sat, 7 Dec 2013 00:05:36 +0200 Subject: Added not-working basic test --- Makefile.am | 2 +- configure.ac | 1 + m4/glibtests.m4 | 14 +++++++------- tests/Makefile.am | 22 ++++++++++++++++++++++ tests/cpuinfo-tests.c | 11 +++++++++++ 5 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/cpuinfo-tests.c diff --git a/Makefile.am b/Makefile.am index eca41ffd..5238b446 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ else EXAMPLES_DIR = endif -SUBDIRS = po misc include sysdeps lib src $(EXAMPLES_DIR) doc +SUBDIRS = po misc include sysdeps lib src $(EXAMPLES_DIR) doc tests libgtopinclude_HEADERS = glibtop.h libgtopconfig.h libgtopincludedir = $(includedir)/libgtop-2.0 diff --git a/configure.ac b/configure.ac index dc4e6543..26bfe0e9 100644 --- a/configure.ac +++ b/configure.ac @@ -89,6 +89,7 @@ AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes) GNOME_LIBGTOP_SYSDEPS GNOME_LIBGTOP_TYPES +GLIB_TESTS GLIB_REQUIRED=2.6.0 diff --git a/m4/glibtests.m4 b/m4/glibtests.m4 index 1bffb703..e03fa469 100644 --- a/m4/glibtests.m4 +++ b/m4/glibtests.m4 @@ -184,21 +184,21 @@ AC_DEFUN([GLIB_TESTS], AS_HELP_STRING([--enable-installed-tests], [Enable installation of some test cases]), [case ${enableval} in - yes) ENABLE_INSTALLED_TESTS="1" ;; - no) ENABLE_INSTALLED_TESTS="" ;; + yes) ENABLE_INSTALLED_TESTS='1' ;; + no) ENABLE_INSTALLED_TESTS='' ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-installed-tests]) ;; esac]) - AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test "$ENABLE_INSTALLED_TESTS" = "1") + AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test '$ENABLE_INSTALLED_TESTS' = '1') AC_ARG_ENABLE(always-build-tests, AS_HELP_STRING([--enable-always-build-tests], [Enable always building tests during 'make all']), [case ${enableval} in - yes) ENABLE_ALWAYS_BUILD_TESTS="1" ;; - no) ENABLE_ALWAYS_BUILD_TESTS="" ;; + yes) ENABLE_ALWAYS_BUILD_TESTS='1' ;; + no) ENABLE_ALWAYS_BUILD_TESTS='' ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-always-build-tests]) ;; esac]) - AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test "$ENABLE_ALWAYS_BUILD_TESTS" = "1") - if test "$ENABLE_INSTALLED_TESTS" = "1"; then + AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test '$ENABLE_ALWAYS_BUILD_TESTS' = '1') + if test '$ENABLE_INSTALLED_TESTS' = '1'; then AC_SUBST(installed_test_metadir, [${datadir}/installed-tests/]AC_PACKAGE_NAME) AC_SUBST(installed_testdir, [${libexecdir}/installed-tests/]AC_PACKAGE_NAME) fi diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 00000000..d864ce8e --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,22 @@ +include $top_srcdir/glib-tap.mk + +noinst_PROGRAMS = test + +TESTS = test + +test_LDADD = $(top_builddir)/lib/libgtop-2.0.la \ + $(top_builddir)/sysdeps/common/libgtop_common-2.0.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps-2.0.la \ + @sysdeps_suid_lib@ \ + $(suid_sysdeps) $(suid_common) \ + $(LIBGTOP_LIBS) \ + @libs_xauth@ + +test_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include/glibtop \ + $(NULL) + +test_SOURCES = \ + cpuinfo-tests.c diff --git a/tests/cpuinfo-tests.c b/tests/cpuinfo-tests.c new file mode 100644 index 00000000..0466d473 --- /dev/null +++ b/tests/cpuinfo-tests.c @@ -0,0 +1,11 @@ +#include +#include + +static void +test_simple_cpuinfo (void) +{ + glibtop_sysinfo *infos = glibtop_get_sysinfo (); + + g_assert_cmpint (infos->ncpu, ==, 4); + +} -- cgit v1.2.1