Thank you for the patch.
Acked-by: Ping Cheng <pingli...@gmail.com>
Ping
On Mon, Mar 21, 2011 at 7:02 PM, Peter Hutterer <peter.hutte...@who-t.net>wrote:
> We weren't really using any of the glib-specific stuff anyway, so just
> replace g_assert with normal assert and drop the dependency.
>
> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
> ---
> configure.ac | 11 +----
> test/Makefile.am | 4 +-
> test/wacom-tests.c | 122
> +++++++++++++++++++++++++--------------------------
> tools/Makefile.am | 3 +-
> tools/xsetwacom.c | 79 +++++++++++++++++-----------------
> 5 files changed, 103 insertions(+), 116 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index b543bdf..85ec1a9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -100,7 +100,6 @@ AC_ARG_WITH([xorg-conf-dir],
> AC_SUBST(configdir)
> AM_CONDITIONAL(HAS_XORG_CONF_DIR, [test "x$sysconfigdir" != "x"])
>
> -# enalbe unit-tests if glib-devel is available
> AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
> [Enable unit-tests (default: auto)]),
> [UNITTESTS=$enableval],
> @@ -108,9 +107,6 @@ AC_ARG_ENABLE(unit-tests,
> AS_HELP_STRING([--enable-unit-tests],
>
> # If unittests aren't explicitly disabled, check for required support
> if test "x$UNITTESTS" != xno ; then
> - PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16],
> - [HAVE_GLIB=yes], [HAVE_GLIB=no])
> -
> # Check if linker supports -wrap, passed via compiler flags
> # When cross-compiling, reports no, since unit tests run from
> # "make check", so would be running on build machine, not target
> @@ -131,22 +127,17 @@ if test "x$UNITTESTS" != xno ; then
> fi
>
> if test "x$UNITTESTS" = xauto; then
> - if test "x$HAVE_GLIB" = xyes && test "x$linker_can_wrap" = xyes;
> then
> + if test "x$linker_can_wrap" = xyes; then
> UNITTESTS=yes
> else
> UNITTESTS=no
> fi
> fi
> if test "x$UNITTESTS" = xyes; then
> - if test "x$HAVE_GLIB" = xno; then
> - AC_MSG_ERROR([glib required to build unit tests])
> - fi
> if test "x$linker_can_wrap" = xno; then
> AC_MSG_ERROR([ld -wrap support required to build unit tests])
> fi
> AC_DEFINE(UNITTESTS, 1, [Enable unit tests])
> - AC_SUBST([GLIB_LIBS])
> - AC_SUBST([GLIB_CFLAGS])
> fi
> AM_CONDITIONAL(UNITTESTS, [test "x$UNITTESTS" = xyes])
>
> diff --git a/test/Makefile.am b/test/Makefile.am
> index 820ff07..ba91b7e 100644
> --- a/test/Makefile.am
> +++ b/test/Makefile.am
> @@ -9,8 +9,8 @@ libwacom_test_la_CFLAGS = -DDISABLE_STATIC
> -I$(top_srcdir)/src $(XORG_CFLAGS) $(
> TESTS=$(noinst_PROGRAMS)
>
> INCLUDES = -I$(top_srcdir)/src
> -AM_CFLAGS = $(GLIB_CFLAGS) $(XORG_CFLAGS) $(CWARNFLAGS)
> -TEST_LDADD=$(GLIB_LIBS) libwacom-test.la
> +AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
> +TEST_LDADD= libwacom-test.la
> COMMON_SOURCES=fake-symbols.c fake-symbols.h
>
> wacom_tests_LDADD=$(TEST_LDADD)
> diff --git a/test/wacom-tests.c b/test/wacom-tests.c
> index 8444bf3..1eec90e 100644
> --- a/test/wacom-tests.c
> +++ b/test/wacom-tests.c
> @@ -20,7 +20,6 @@
> #include <config.h>
> #endif
>
> -#include <glib.h>
> #include "fake-symbols.h"
> #include <xf86Wacom.h>
>
> @@ -40,27 +39,27 @@ test_common_ref(void)
> WacomCommonPtr second;
>
> common = wcmNewCommon();
> - g_assert(common);
> - g_assert(common->refcnt == 1);
> + assert(common);
> + assert(common->refcnt == 1);
>
> second = wcmRefCommon(common);
>
> - g_assert(second == common);
> - g_assert(second->refcnt == 2);
> + assert(second == common);
> + assert(second->refcnt == 2);
>
> wcmFreeCommon(&second);
> - g_assert(common);
> - g_assert(!second);
> - g_assert(common->refcnt == 1);
> + assert(common);
> + assert(!second);
> + assert(common->refcnt == 1);
>
> second = wcmRefCommon(NULL);
> - g_assert(common != second);
> - g_assert(second->refcnt == 1);
> - g_assert(common->refcnt == 1);
> + assert(common != second);
> + assert(second->refcnt == 1);
> + assert(common->refcnt == 1);
>
> wcmFreeCommon(&second);
> wcmFreeCommon(&common);
> - g_assert(!second && !common);
> + assert(!second && !common);
> }
>
>
> @@ -83,9 +82,9 @@ test_rebase_pressure(void)
> base = priv;
>
> pressure = rebasePressure(&priv, &ds);
> - g_assert(pressure == ds.pressure);
> + assert(pressure == ds.pressure);
>
> - g_assert(memcmp(&priv, &base, sizeof(priv)) == 0);
> + assert(memcmp(&priv, &base, sizeof(priv)) == 0);
>
> /* Pressure in-proximity means rebase to new minimum */
> priv.oldProximity = 1;
> @@ -93,8 +92,8 @@ test_rebase_pressure(void)
> base = priv;
>
> pressure = rebasePressure(&priv, &ds);
> - g_assert(pressure == priv.minPressure);
> - g_assert(memcmp(&priv, &base, sizeof(priv)) == 0);
> + assert(pressure == priv.minPressure);
> + assert(memcmp(&priv, &base, sizeof(priv)) == 0);
> }
>
> static void
> @@ -125,15 +124,15 @@ test_normalize_pressure(void)
> ds.pressure = i;
>
> pressure = normalizePressure(&priv, &ds);
> - g_assert(pressure >= 0);
> - g_assert(pressure <= FILTER_PRESSURE_RES);
> + assert(pressure >= 0);
> + assert(pressure <= FILTER_PRESSURE_RES);
>
> /* we count up, so assume normalised pressure goes
> up too */
> - g_assert(prev_pressure < pressure);
> + assert(prev_pressure < pressure);
> prev_pressure = pressure;
> }
>
> - g_assert(pressure == FILTER_PRESSURE_RES);
> + assert(pressure == FILTER_PRESSURE_RES);
> }
>
> /* If minPressure is higher than ds->pressure, normalizePressure
> takes
> @@ -149,11 +148,11 @@ test_normalize_pressure(void)
>
> pressure = normalizePressure(&priv, &ds);
>
> - g_assert(pressure >= 0);
> - g_assert(pressure < FILTER_PRESSURE_RES);
> + assert(pressure >= 0);
> + assert(pressure < FILTER_PRESSURE_RES);
>
> /* we count up, so assume normalised pressure goes up too */
> - g_assert(prev_pressure == pressure);
> + assert(prev_pressure == pressure);
> }
> }
>
> @@ -187,18 +186,18 @@ test_initial_size(void)
>
> wcmInitialToolSize(&info);
>
> - g_assert(priv.topX == minx);
> - g_assert(priv.topY == minx);
> - g_assert(priv.bottomX == maxx);
> - g_assert(priv.bottomY == maxy);
> - g_assert(priv.resolX == xres);
> - g_assert(priv.resolY == yres);
> + assert(priv.topX == minx);
> + assert(priv.topY == minx);
> + assert(priv.bottomX == maxx);
> + assert(priv.bottomY == maxy);
> + assert(priv.resolX == xres);
> + assert(priv.resolY == yres);
>
> /* Same thing for a touch-enabled device */
> memset(&common, 0, sizeof(common));
>
> priv.flags = TOUCH_ID;
> - g_assert(IsTouch(&priv));
> + assert(IsTouch(&priv));
>
> common.wcmMaxTouchX = maxx;
> common.wcmMaxTouchY = maxy;
> @@ -207,12 +206,12 @@ test_initial_size(void)
>
> wcmInitialToolSize(&info);
>
> - g_assert(priv.topX == minx);
> - g_assert(priv.topY == minx);
> - g_assert(priv.bottomX == maxx);
> - g_assert(priv.bottomY == maxy);
> - g_assert(priv.resolX == xres);
> - g_assert(priv.resolY == yres);
> + assert(priv.topX == minx);
> + assert(priv.topY == minx);
> + assert(priv.bottomX == maxx);
> + assert(priv.bottomY == maxy);
> + assert(priv.resolX == xres);
> + assert(priv.resolY == yres);
>
> }
>
> @@ -227,14 +226,14 @@ test_suppress(void)
> common.wcmSuppress = 2;
>
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_ALL);
> + assert(rc == SUPPRESS_ALL);
>
> /* proximity, buttons and strip send for any change */
>
> #define test_any_suppress(field) \
> old.field = 1; \
> rc = wcmCheckSuppress(&common, &old, &new); \
> - g_assert(rc == SUPPRESS_NONE); \
> + assert(rc == SUPPRESS_NONE); \
> new.field = old.field;
>
> test_any_suppress(proximity);
> @@ -251,16 +250,16 @@ test_suppress(void)
> #define test_above_suppress(field) \
> old.field = common.wcmSuppress; \
> rc = wcmCheckSuppress(&common, &old, &new); \
> - g_assert(rc == SUPPRESS_ALL); \
> + assert(rc == SUPPRESS_ALL); \
> old.field = common.wcmSuppress + 1; \
> rc = wcmCheckSuppress(&common, &old, &new); \
> - g_assert(rc == SUPPRESS_NONE); \
> + assert(rc == SUPPRESS_NONE); \
> old.field = -common.wcmSuppress; \
> rc = wcmCheckSuppress(&common, &old, &new); \
> - g_assert(rc == SUPPRESS_ALL); \
> + assert(rc == SUPPRESS_ALL); \
> old.field = -common.wcmSuppress - 1; \
> rc = wcmCheckSuppress(&common, &old, &new); \
> - g_assert(rc == SUPPRESS_NONE); \
> + assert(rc == SUPPRESS_NONE); \
> new.field = old.field;
>
> test_above_suppress(pressure);
> @@ -274,7 +273,7 @@ test_suppress(void)
> /* any movement on relwheel counts */
> new.relwheel = 1;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_NONE);
> + assert(rc == SUPPRESS_NONE);
> new.relwheel = 0;
>
> /* x axis movement */
> @@ -282,19 +281,19 @@ test_suppress(void)
> /* not enough movement */
> new.x = common.wcmSuppress;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_ALL);
> - g_assert(old.x == new.x);
> - g_assert(old.y == new.y);
> + assert(rc == SUPPRESS_ALL);
> + assert(old.x == new.x);
> + assert(old.y == new.y);
>
> /* only x axis above thresh */
> new.x = common.wcmSuppress + 1;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_NON_MOTION);
> + assert(rc == SUPPRESS_NON_MOTION);
>
> /* x and other field above thres */
> new.pressure = ~old.pressure;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_NONE);
> + assert(rc == SUPPRESS_NONE);
>
> new.pressure = old.pressure;
> new.x = old.x;
> @@ -302,17 +301,17 @@ test_suppress(void)
> /* y axis movement */
> new.y = common.wcmSuppress;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_ALL);
> - g_assert(old.x == new.x);
> - g_assert(old.y == new.y);
> + assert(rc == SUPPRESS_ALL);
> + assert(old.x == new.x);
> + assert(old.y == new.y);
>
> new.y = common.wcmSuppress + 1;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_NON_MOTION);
> + assert(rc == SUPPRESS_NON_MOTION);
>
> new.pressure = ~old.pressure;
> rc = wcmCheckSuppress(&common, &old, &new);
> - g_assert(rc == SUPPRESS_NONE);
> + assert(rc == SUPPRESS_NONE);
> new.pressure = old.pressure;
> }
>
> @@ -424,21 +423,20 @@ test_tilt_to_rotation(void)
> x = rotation_table[i][0];
> y = rotation_table[i][1];
> rotation = wcmTilt2R(x, y, INTUOS4_CURSOR_ROTATION_OFFSET);
> - g_assert(rotation == rotation_table[i][2]);
> + assert(rotation == rotation_table[i][2]);
> }
> }
>
>
> int main(int argc, char** argv)
> {
> - g_test_init(&argc, &argv, NULL);
> - g_test_add_func("/common/refcounting", test_common_ref);
> - g_test_add_func("/common/rebase_pressure", test_rebase_pressure);
> - g_test_add_func("/common/normalize_pressure",
> test_normalize_pressure);
> - g_test_add_func("/common/test_suppress", test_suppress);
> - g_test_add_func("/xfree86/initial_size", test_initial_size);
> - g_test_add_func("/filter/tilt_to_rotation", test_tilt_to_rotation);
> - return g_test_run();
> + test_common_ref();
> + test_rebase_pressure();
> + test_normalize_pressure();
> + test_suppress();
> + test_initial_size();
> + test_tilt_to_rotation();
> + return 0;
> }
>
> /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> index 44fb690..5cd40e2 100644
> --- a/tools/Makefile.am
> +++ b/tools/Makefile.am
> @@ -28,8 +28,7 @@ AM_LDFLAGS = $(X11_LIBS)
> if UNITTESTS
> check_PROGRAMS = xsetwacom-test
> xsetwacom_test_SOURCES=xsetwacom.c
> -xsetwacom_test_LDADD=$(GLIB_LIBS)
> -xsetwacom_test_CFLAGS=-DBUILD_TEST $(GLIB_CFLAGS) $(X11_CFLAGS)
> +xsetwacom_test_CFLAGS=-DBUILD_TEST $(X11_CFLAGS)
>
> TESTS=$(check_PROGRAMS)
> endif
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index f3387bc..130abb5 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -2157,7 +2157,7 @@ int main (int argc, char **argv)
> #endif
>
> #ifdef BUILD_TEST
> -#include <glib.h>
> +#include <assert.h>
> /**
> * Below are unit-tests to ensure xsetwacom continues to work as expected.
> */
> @@ -2168,27 +2168,27 @@ static void test_is_modifier(void)
> char buff[5];
>
>
> - g_assert(is_modifier("Control_L"));
> - g_assert(is_modifier("Control_R"));
> - g_assert(is_modifier("Alt_L"));
> - g_assert(is_modifier("Alt_R"));
> - g_assert(is_modifier("Shift_L"));
> - g_assert(is_modifier("Shift_R"));
> - g_assert(is_modifier("Meta_L"));
> - g_assert(is_modifier("Meta_R"));
> - g_assert(is_modifier("Super_L"));
> - g_assert(is_modifier("Super_R"));
> - g_assert(is_modifier("Hyper_L"));
> - g_assert(is_modifier("Hyper_R"));
> + assert(is_modifier("Control_L"));
> + assert(is_modifier("Control_R"));
> + assert(is_modifier("Alt_L"));
> + assert(is_modifier("Alt_R"));
> + assert(is_modifier("Shift_L"));
> + assert(is_modifier("Shift_R"));
> + assert(is_modifier("Meta_L"));
> + assert(is_modifier("Meta_R"));
> + assert(is_modifier("Super_L"));
> + assert(is_modifier("Super_R"));
> + assert(is_modifier("Hyper_L"));
> + assert(is_modifier("Hyper_R"));
>
> - g_assert(!is_modifier(""));
> + assert(!is_modifier(""));
>
> /* make sure at least the default keys (ascii 33 - 126) aren't
> * modifiers */
> for (i = '!'; i <= '~'; i++)
> {
> sprintf(buff, "%c", i);
> - g_assert(!is_modifier(buff));
> + assert(!is_modifier(buff));
> }
> }
>
> @@ -2205,13 +2205,13 @@ static void test_convert_specialkey(void)
> {
> sprintf(buff, "%c", i);
> converted = convert_specialkey(buff);
> - g_assert(strcmp(converted, buff) == 0);
> + assert(strcmp(converted, buff) == 0);
> }
>
> for (m = specialkeys; m->name; m++)
> {
> converted = convert_specialkey(m->name);
> - g_assert(strcmp(converted, m->converted) == 0);
> + assert(strcmp(converted, m->converted) == 0);
> }
> }
>
> @@ -2222,8 +2222,8 @@ static void test_parameter_number(void)
> * deprecated them.
> * Numbers include trailing NULL entry.
> */
> - g_assert(ArrayLength(parameters) == 33);
> - g_assert(ArrayLength(deprecated_parameters) == 16);
> + assert(ArrayLength(parameters) == 33);
> + assert(ArrayLength(deprecated_parameters) == 16);
> }
>
> static void test_convert_value_from_user(void)
> @@ -2244,32 +2244,31 @@ static void test_convert_value_from_user(void)
>
> int val;
>
> - g_assert(convert_value_from_user(&test_nonbool, "1", &val) ==
> True);
> - g_assert(convert_value_from_user(&test_nonbool, "-8", &val) ==
> True);
> - g_assert(convert_value_from_user(&test_nonbool, "+314", &val) ==
> True);
> - g_assert(convert_value_from_user(&test_nonbool,
> "36893488147419103232", &val) == False); //2^65 > MAX_INT
> - g_assert(convert_value_from_user(&test_nonbool, "123abc", &val) ==
> False);
> - g_assert(convert_value_from_user(&test_nonbool, "123 abc", &val) ==
> False);
> -
> - g_assert(convert_value_from_user(&test_bool, "true", &val) ==
> True);
> - g_assert(convert_value_from_user(&test_bool, "On", &val) == True);
> - g_assert(convert_value_from_user(&test_bool, "oFf", &val) == True);
> - g_assert(convert_value_from_user(&test_bool, "FALSE", &val) ==
> True);
> - g_assert(convert_value_from_user(&test_bool, "0", &val) == False);
> - g_assert(convert_value_from_user(&test_bool, "1", &val) == False);
> - g_assert(convert_value_from_user(&test_bool, " on", &val) ==
> False);
> - g_assert(convert_value_from_user(&test_bool, "off ", &val) ==
> False);
> + assert(convert_value_from_user(&test_nonbool, "1", &val) == True);
> + assert(convert_value_from_user(&test_nonbool, "-8", &val) == True);
> + assert(convert_value_from_user(&test_nonbool, "+314", &val) ==
> True);
> + assert(convert_value_from_user(&test_nonbool,
> "36893488147419103232", &val) == False); //2^65 > MAX_INT
> + assert(convert_value_from_user(&test_nonbool, "123abc", &val) ==
> False);
> + assert(convert_value_from_user(&test_nonbool, "123 abc", &val) ==
> False);
> +
> + assert(convert_value_from_user(&test_bool, "true", &val) == True);
> + assert(convert_value_from_user(&test_bool, "On", &val) == True);
> + assert(convert_value_from_user(&test_bool, "oFf", &val) == True);
> + assert(convert_value_from_user(&test_bool, "FALSE", &val) == True);
> + assert(convert_value_from_user(&test_bool, "0", &val) == False);
> + assert(convert_value_from_user(&test_bool, "1", &val) == False);
> + assert(convert_value_from_user(&test_bool, " on", &val) == False);
> + assert(convert_value_from_user(&test_bool, "off ", &val) == False);
> }
>
>
> int main(int argc, char** argv)
> {
> - g_test_init(&argc, &argv, NULL);
> - g_test_add_func("/xsetwacom/parameter_number",
> test_parameter_number);
> - g_test_add_func("/xsetwacom/is_modifier", test_is_modifier);
> - g_test_add_func("/xsetwacom/convert_specialkey",
> test_convert_specialkey);
> - g_test_add_func("/xsetwacom/convert_value_from_user",
> test_convert_value_from_user);
> - return g_test_run();
> + test_parameter_number();
> + test_is_modifier();
> + test_convert_specialkey();
> + test_convert_value_from_user();
> + return 0;
> }
>
> #endif
> --
> 1.7.4
>
>
>
> ------------------------------------------------------------------------------
> Enable your software for Intel(R) Active Management Technology to meet the
> growing manageability and security demands of your customers. Businesses
> are taking advantage of Intel(R) vPro (TM) technology - will your software
> be a part of the solution? Download the Intel(R) Manageability Checker
> today! http://p.sf.net/sfu/intel-dev2devmar
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel