*.stamp
*.typelib
*.tar.*
+*.gcno
+*.gcda
build-aux
*dbus*gen*
src/common/gum.conf
lcov: check
@rm -rf lcov-report
- @lcov -c --directory src/ --output-file lcov.output
+ @lcov --no-external -c --directory src/ --output-file cov.output
+ @lcov -r cov.output common/dbus/\* daemon/dbus/\*.c --output-file lcov.output
@genhtml lcov.output --output-directory lcov-report
- @rm lcov.output
+ @rm lcov.output cov.output
@echo "Coverage report is in file://$(abs_srcdir)/lcov-report/index.html"
lcov: check
@rm -rf lcov-report
- @lcov -c --directory src/ --output-file lcov.output
+ @lcov --no-external -c --directory src/ --output-file cov.output
+ @lcov -r cov.output common/dbus/\* daemon/dbus/\*.c --output-file lcov.output
@genhtml lcov.output --output-directory lcov-report
- @rm lcov.output
+ @rm lcov.output cov.output
@echo "Coverage report is in file://$(abs_srcdir)/lcov-report/index.html"
# Tell versions [3.59,3.63) of GNU make to not export all variables.
with_gnu_ld
with_sysroot
enable_libtool_lock
-enable_gcov
+enable_cov
enable_distcheck
enable_dbus_type
enable_tests
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
- --enable-gcov build to be used for coverage analysis
+ --enable-cov build to be used for coverage analysis
--enable-distcheck build for distcheck target
--enable-dbus-type=dbus-type specify daemon dbus type:
p2p: uses peer to peer dbus
as_fn_error $? "\"CRYPT Library is required\"" "$LINENO" 5
fi
-# Enable gcov
-# Check whether --enable-gcov was given.
-if test "${enable_gcov+set}" = set; then :
- enableval=$enable_gcov; enable_gcov=yes
+# Enable cov
+# Check whether --enable-cov was given.
+if test "${enable_cov+set}" = set; then :
+ enableval=$enable_cov; enable_cov=yes
else
- enable_gcov=no
+ enable_cov=no
fi
-if test "x$enable_gcov" = "xyes" ; then
+if test "x$enable_cov" = "xyes" ; then
GCOV_CFLAGS="-ftest-coverage -fprofile-arcs"
GCOV_LIBS="-lgcov"
fi
enable_tests=no
fi
+if test "x$enable_cov" = "xyes" ; then
+ # Enable tests automatically when code coverage is enabled
+ enable_tests="yes"
+fi
echo "--------------------------------"
echo "Enable tests features: '$enable_tests'"
if test "x$enable_tests" = "xyes" ; then
AC_MSG_ERROR("CRYPT Library is required")
fi
-# Enable gcov
-AC_ARG_ENABLE(gcov, [ --enable-gcov build to be used for coverage analysis ],
- [enable_gcov=yes], [enable_gcov=no])
-if test "x$enable_gcov" = "xyes" ; then
+# Enable cov
+AC_ARG_ENABLE(cov, [ --enable-cov build to be used for coverage analysis ],
+ [enable_cov=yes], [enable_cov=no])
+if test "x$enable_cov" = "xyes" ; then
GCOV_CFLAGS="-ftest-coverage -fprofile-arcs"
GCOV_LIBS="-lgcov"
fi
# Enable tests
AC_ARG_ENABLE(tests, [ --enable-tests enable tests features],
[enable_tests=yes], [enable_tests=no])
+if test "x$enable_cov" = "xyes" ; then
+ # Enable tests automatically when code coverage is enabled
+ enable_tests="yes"
+fi
echo "--------------------------------"
echo "Enable tests features: '$enable_tests'"
if test "x$enable_tests" = "xyes" ; then
%changelog
+* Mon Dec 23 2013 Imran Zaman <imran.zaman@intel.com>
+- added test cases for error and dictionary objects
+- utilized dictionary functions for get/set key-value pairs
+- clean up generated coverage files on make clean
+- enable tests by default if coverage is enabled
+- exclude external and generated dbus files from code coverage calculation
+
* Fri Dec 20 2013 Imran Zaman <imran.zaman@intel.com>
- Corrected spec and changes file names
+* Mon Dec 23 2013 Imran Zaman <imran.zaman@intel.com>
+- added test cases for error and dictionary objects
+- utilized dictionary functions for get/set key-value pairs
+- clean up generated coverage files on make clean
+- enable tests by default if coverage is enabled
+- exclude external and generated dbus files from code coverage calculation
+
* Fri Dec 20 2013 Imran Zaman <imran.zaman@intel.com>
- Corrected spec and changes file names
<p>
</p>
<div class="refsect1">
-<a name="idp7772064"></a><h2>Usage</h2>
+<a name="idp10298048"></a><h2>Usage</h2>
</div>
<p>
Following code snippet demonstrates how to create and use config object:
<p>
</p>
<div class="refsect1">
-<a name="idp6490208"></a><h2>Where the configuration file is searched for</h2>
+<a name="idp6443376"></a><h2>Where the configuration file is searched for</h2>
</div>
<p>
</p>
<p>
</p>
<div class="refsect1">
-<a name="idp2053520"></a><h2>Example configuration file</h2>
+<a name="idp7297552"></a><h2>Example configuration file</h2>
</div>
<p>
</p>
<p>
</p>
<div class="refsect1">
-<a name="idp8989072"></a><h2>Usage</h2>
+<a name="idp9673808"></a><h2>Usage</h2>
</div>
<p>
Following code snippet demonstrates how to derive and use <a class="link" href="GumDisposable.html" title="GumDisposable"><span class="type">GumDisposable</span></a>:
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
-<a name="idp3960928"></a>Daemon (gumd) configuration</h2></div></div></div>
+<a name="idp3002784"></a>Daemon (gumd) configuration</h2></div></div></div>
<div class="toc"><dl>
<dt>
<span class="refentrytitle"><a href="GumConfig.html">GumConfig</a></span><span class="refpurpose"> — gum configuration information</span>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
-<a name="idp3451296"></a>Common</h2></div></div></div>
+<a name="idp4620992"></a>Common</h2></div></div></div>
<div class="toc"><dl>
<dt>
<span class="refentrytitle"><a href="gumd-GumDictionary.html">GumDictionary</a></span><span class="refpurpose"> — a dictionary container holding string keys and variant
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
-<a name="idp3578176"></a>Client library (libgum) interface</h2></div></div></div>
+<a name="idp2676240"></a>Client library (libgum) interface</h2></div></div></div>
<div class="toc"><dl>
<dt>
<span class="refentrytitle"><a href="GumUser.html">GumUser</a></span><span class="refpurpose"> — provides interface for managing user's account</span>
</table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
-<a name="idp3871680"></a>Appendices</h2></div></div></div>
+<a name="idp2117968"></a>Appendices</h2></div></div></div>
<a name="idx"></a><a name="idxC"></a><h3 class="title">C</h3>
<dt>
<a class="link" href="GumConfig.html#GumConfig-struct" title="struct GumConfig">GumConfig</a>, struct in <a class="link" href="GumConfig.html" title="GumConfig">GumConfig</a>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
-<a name="idp127328"></a>Deprecated APIs</h2></div></div></div>
+<a name="idp4013616"></a>Deprecated APIs</h2></div></div></div>
<a name="idx"></a>
</div>
<div class="footer">
</p>
</div>
<div class="refsect1">
-<a name="idp7688560"></a><h2>Add User</h2>
+<a name="idp8945280"></a><h2>Add User</h2>
<p>
User can be added with flag <strong class="userinput"><code>--add-user</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp10589744"></a><h2>Delete User</h2>
+<a name="idp8613200"></a><h2>Delete User</h2>
<p>
User can be deleted with flag <strong class="userinput"><code>--delete-user</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp9659056"></a><h2>Update User</h2>
+<a name="idp12556272"></a><h2>Update User</h2>
<p>
User can be update with flag <strong class="userinput"><code>--update-user</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp13327120"></a><h2>Get User</h2>
+<a name="idp12561184"></a><h2>Get User</h2>
<p>
User data can be retrieved with flag <strong class="userinput"><code>--get-user</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp13217984"></a><h2>Get User By Name</h2>
+<a name="idp12379840"></a><h2>Get User By Name</h2>
<p>
User data can be retrieved with flag <strong class="userinput"><code>--get-user-by-name</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp13222496"></a><h2>Add Group</h2>
+<a name="idp13033520"></a><h2>Add Group</h2>
<p>
Group can be added with flag <strong class="userinput"><code>--add-group</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp14360928"></a><h2>Delete Group</h2>
+<a name="idp13038256"></a><h2>Delete Group</h2>
<p>
Group can be deleted with flag <strong class="userinput"><code>--delete-group</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp14365440"></a><h2>Update Group</h2>
+<a name="idp13042768"></a><h2>Update Group</h2>
<p>
Group can be updated with flag <strong class="userinput"><code>--udpate-group</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp14370032"></a><h2>Get Group</h2>
+<a name="idp13047360"></a><h2>Get Group</h2>
<p>
Group data can be retrieved with flag <strong class="userinput"><code>--get-group</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp14374544"></a><h2>Get Group By Name</h2>
+<a name="idp14206848"></a><h2>Get Group By Name</h2>
<p>
Group data can be retrieved with flag <strong class="userinput"><code>--get-group-by-name</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp12684400"></a><h2>Add member To Group</h2>
+<a name="idp14211360"></a><h2>Add member To Group</h2>
<p>
New member can be added to a group with flag <strong class="userinput"><code>--add-member</code></strong>:
</p>
</p>
</div>
<div class="refsect1">
-<a name="idp12688960"></a><h2>Delete member From Group</h2>
+<a name="idp14215920"></a><h2>Delete member From Group</h2>
<p>
A member can be removed from the group with flag <strong class="userinput"><code>--delete-member</code></strong>:
</p>
<div class="refentry">
<a name="um-intro"></a><div class="titlepage"></div>
<div class="refsect1">
-<a name="idp8603856"></a><h2>What is gumd/libgum?</h2>
+<a name="idp10426944"></a><h2>What is gumd/libgum?</h2>
<p>
gumd and libgum together provides a framework for creating, deleting
and modifying user and groups in the system. gumd is a daemon that
if HAVE_LIBTLM_NFC
gum_example_CPPFLAGS += $(LIBTLM_NFC_CFLAGS)
gum_example_LDADD += $(LIBTLM_NFC_LIBS)
-endif
\ No newline at end of file
+endif
+
+CLEANFILES = *.gcno *.gcda
\ No newline at end of file
$(am__append_1)
gum_example_LDADD = $(DEPS_LIBS) $(top_builddir)/src/lib/libgum.la \
$(LIBGUM_LIBS) $(am__append_2)
+CLEANFILES = *.gcno *.gcda
all: all-am
.SUFFIXES:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
sysconf_DATA = gum.conf
-CLEANFILES =
+CLEANFILES = *.gcno *.gcda
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgum-common.pc
sysconf_DATA = gum.conf
-CLEANFILES =
+CLEANFILES = *.gcno *.gcda
all: all-recursive
.SUFFIXES:
DBG ("found config : '%s/%s' - '%s'", groups[i], keys[j], value);
- gum_config_set_string (self, key, value);
+ if (g_strcmp0 (GUM_CONFIG_DBUS_DAEMON_TIMEOUT, key) == 0 ||
+ g_strcmp0 (GUM_CONFIG_DBUS_USER_TIMEOUT, key) == 0 ||
+ g_strcmp0 (GUM_CONFIG_DBUS_GROUP_TIMEOUT, key) == 0) {
+ gum_config_set_int (self, key, atoi (value));
+ } else {
+ gum_config_set_string (self, key, value);
+ }
g_free (key);
g_free (value);
GumConfig *self)
{
const gchar *e_val = 0;
- guint timeout = 0;
+ gint timeout = 0;
e_val = g_getenv ("UM_DAEMON_TIMEOUT");
if (e_val && (timeout = atoi(e_val)))
- gum_config_set_string (self, GUM_CONFIG_DBUS_DAEMON_TIMEOUT, e_val);
+ gum_config_set_int (self, GUM_CONFIG_DBUS_DAEMON_TIMEOUT, timeout);
e_val = g_getenv ("UM_USER_TIMEOUT");
if (e_val && (timeout = atoi(e_val)))
- gum_config_set_string (self, GUM_CONFIG_DBUS_USER_TIMEOUT, e_val);
+ gum_config_set_int (self, GUM_CONFIG_DBUS_USER_TIMEOUT, timeout);
e_val = g_getenv ("UM_GROUP_TIMEOUT");
if (e_val && (timeout = atoi(e_val)))
- gum_config_set_string (self, GUM_CONFIG_DBUS_GROUP_TIMEOUT, e_val);
+ gum_config_set_int (self, GUM_CONFIG_DBUS_GROUP_TIMEOUT, timeout);
e_val = g_getenv ("UM_PASSWD_FILE");
if (e_val)
const gchar *key,
gint retval)
{
- const gchar *str_value = gum_config_get_string (self, key);
- return (gint) (str_value ? atoi (str_value) : retval);
+ gint32 value = retval;
+ gum_dictionary_get_int32 (self->priv->config_table, key, &value);
+ return value;
}
/**
const gchar *key,
gint value)
{
- gchar *s_value = 0;
g_return_if_fail (self && GUM_IS_CONFIG (self));
- s_value = g_strdup_printf ("%d", value);
- if (!s_value) return;
-
- gum_config_set_string (self, (gpointer) key, s_value);
-
- g_free (s_value);
+ gum_dictionary_set_int32 (self->priv->config_table, key, value);
}
/**
const gchar *key,
guint retval)
{
- guint value;
- const gchar *str_value = gum_config_get_string (self, key);
- if (!str_value || sscanf (str_value,"%u",&value) <= 0) value = retval;
+ guint32 value = retval;
+ gum_dictionary_get_uint32 (self->priv->config_table, key, &value);
return value;
}
const gchar *key,
guint value)
{
- gchar *s_value = 0;
g_return_if_fail (self && GUM_IS_CONFIG (self));
- s_value = g_strdup_printf ("%u", value);
- if (!s_value) return;
-
- gum_config_set_string (self, (gpointer) key, s_value);
- g_free (s_value);
+ gum_dictionary_set_uint32 (self->priv->config_table, key, value);
}
/**
{
g_return_val_if_fail (self && GUM_IS_CONFIG (self), NULL);
- GVariant* value = gum_dictionary_get (self->priv->config_table,
- (gpointer) key);
- if (!value) return NULL;
-
- return g_variant_get_string (value, NULL);
+ return gum_dictionary_get_string (self->priv->config_table, key);
}
/**
{
g_return_if_fail (self && GUM_IS_CONFIG (self));
- gum_dictionary_set (self->priv->config_table,
- (gpointer) key,
- g_variant_new_string (value));
-
+ gum_dictionary_set_string (self->priv->config_table, key, value);
}
static void
chown root $(DESTDIR)$(bindir)/gumd || true
chmod u+s $(DESTDIR)$(bindir)/gumd || true
endif
+
+CLEANFILES = *.gcno *.gcda
\ No newline at end of file
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gumd.pc
+CLEANFILES = *.gcno *.gcda
all: all-recursive
.SUFFIXES:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgum.pc
-CLEANFILES =
+CLEANFILES = *.gcno *.gcda
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgum.pc
-CLEANFILES =
+CLEANFILES = *.gcno *.gcda
all: all-recursive
.SUFFIXES:
EXTRA_DIST += \
valgrind.supp \
valgrind_common.mk
+
\ No newline at end of file
commontest_LDADD = \
$(top_builddir)/src/common/libgum-common.la \
$(GUMD_LIBS) \
- $(CHECK_LIBS)
\ No newline at end of file
+ $(CHECK_LIBS)
+
+CLEANFILES = *.gcno *.gcda
\ No newline at end of file
$(GUMD_LIBS) \
$(CHECK_LIBS)
+CLEANFILES = *.gcno *.gcda
all: all-am
.SUFFIXES:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
#include "common/gum-lock.h"
#include "common/gum-string-utils.h"
#include "common/gum-defines.h"
+#include "common/gum-dictionary.h"
gboolean
_create_file (
}
END_TEST
+START_TEST (test_error)
+{
+ DBG("");
+
+ GVariant *var = NULL;
+ GError *err = GUM_GET_ERROR_FOR_ID (GUM_ERROR_INVALID_INPUT, "testerror");
+ fail_if (err == NULL);
+
+ var = gum_error_to_variant (err);
+ fail_if (var == NULL);
+
+ g_error_free (err); err = NULL;
+ err = gum_error_new_from_variant (var);
+
+ fail_if (err == NULL);
+ fail_if (err->code != GUM_ERROR_INVALID_INPUT);
+ fail_if (g_strcmp0 (err->message, "testerror") != 0);
+
+ g_error_free (err);
+ g_variant_unref (var);
+}
+END_TEST
+
+START_TEST (test_dictionary)
+{
+ DBG("");
+ gboolean data1 = FALSE;
+ GVariant *var = NULL;
+ gint64 data2 = 123;
+ guint64 data3 = 789;
+
+ GumDictionary* dict = gum_dictionary_new ();
+ fail_if (dict == NULL);
+ fail_if (gum_dictionary_get_boolean (dict,
+ "key1", &data1) == TRUE);
+
+ fail_if (gum_dictionary_set_boolean (dict,
+ "key1", data1) == FALSE);
+ data1 = TRUE;
+ fail_if (gum_dictionary_get_boolean (dict,
+ "key1", &data1) == FALSE);
+ fail_if (data1 == TRUE);
+ fail_if (gum_dictionary_get_boolean (dict,
+ "key1", &data1) == FALSE);
+
+ fail_if (gum_dictionary_set_int64 (dict,
+ "key2", data2) == FALSE);
+ data2 = 456;
+ fail_if (gum_dictionary_set_uint64 (dict,
+ "key3", data3) == FALSE);
+
+ var = gum_dictionary_to_variant (dict);
+ fail_if (var == NULL);
+ g_hash_table_unref (dict);
+
+ dict = gum_dictionary_new_from_variant (var);
+ fail_if (dict == NULL);
+
+ fail_if (gum_dictionary_get_int64 (dict,
+ "key2", &data2) == FALSE);
+ fail_if (data2 != 123);
+ fail_if (gum_dictionary_get_uint64 (dict,
+ "key3", &data3) == FALSE);
+
+ g_variant_unref (var);
+ g_hash_table_unref (dict);
+}
+END_TEST
+
Suite* common_suite (void)
{
Suite *s = suite_create ("Common library");
tcase_add_test (tc_core, test_file);
tcase_add_test (tc_core, test_validate);
tcase_add_test (tc_core, test_crypt);
+ tcase_add_test (tc_core, test_error);
+ tcase_add_test (tc_core, test_dictionary);
suite_add_tcase (s, tc_core);
return s;
}
$(GUMD_LIBS) \
$(CHECK_LIBS)
+CLEANFILES = *.gcno *.gcda
\ No newline at end of file
$(GUMD_LIBS) \
$(CHECK_LIBS)
+CLEANFILES = *.gcno *.gcda
all: all-am
.SUFFIXES:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
$(top_builddir)/src/lib/libgum.la \
$(GUMD_LIBS) \
$(CHECK_LIBS)
+
+CLEANFILES = *.gcno *.gcda
\ No newline at end of file
$(GUMD_LIBS) \
$(CHECK_LIBS)
+CLEANFILES = *.gcno *.gcda
all: all-am
.SUFFIXES:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)