Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unit tests: initial commit
Relates NEMO#701

[tests] Unit tests: initial commit
  • Loading branch information
martyone committed Oct 4, 2013
1 parent 510038b commit 021d8c6
Show file tree
Hide file tree
Showing 10 changed files with 4,059 additions and 3 deletions.
188 changes: 188 additions & 0 deletions .depend
Expand Up @@ -682,6 +682,194 @@ powerkey.pic.o:\
mce.h\
powerkey.h\

tests/ut/ut_display.o:\
tests/ut/ut_display.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display.pic.o:\
tests/ut/ut_display.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_blanking_inhibit.o:\
tests/ut/ut_display_blanking_inhibit.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_blanking_inhibit.pic.o:\
tests/ut/ut_display_blanking_inhibit.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_conf.o:\
tests/ut/ut_display_conf.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_conf.pic.o:\
tests/ut/ut_display_conf.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_filter.o:\
tests/ut/ut_display_filter.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_filter.pic.o:\
tests/ut/ut_display_filter.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_stm.o:\
tests/ut/ut_display_stm.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tests/ut/ut_display_stm.pic.o:\
tests/ut/ut_display_stm.c\
datapipe.h\
datapipe.h\
mce-conf.h\
mce-dbus.h\
mce-gconf.h\
mce-io.h\
mce-lib.h\
mce-log.h\
mce.h\
mce-log.h\
filewatcher.h\
libwakelock.h\
mce-hybris.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\

tklock.o:\
tklock.c\
datapipe.h\
Expand Down
73 changes: 70 additions & 3 deletions Makefile
Expand Up @@ -20,20 +20,22 @@
# TOP LEVEL TARGETS
# ----------------------------------------------------------------------------

.PHONY: build modules tools doc install clean distclean mostlyclean
.PHONY: build modules tools check doc install clean distclean mostlyclean

build::

modules::

tools::

check::

doc::

install::

mostlyclean::
$(RM) *.o *.bak *~ */*.o */*.bak */*~
$(RM) *.o *.bak *~ */*.o */*.bak */*~ */*/*.o */*/*.bak */*/*~

clean:: mostlyclean

Expand Down Expand Up @@ -103,6 +105,9 @@ ENABLE_BACKUP_SUPPORT ?= n
# Whether to enable double-click == double-tap emulation
ENABLE_DOUBLETAP_EMULATION ?= y

# Whether to install unit tests
ENABLE_UNITTESTS_INSTALL ?= y

# Install destination
DESTDIR ?= /tmp/test-mce-install

Expand All @@ -121,6 +126,7 @@ _INFODIR ?= $(_DATADIR)/info# # /usr/share/info
_DEFAULTDOCDIR ?= $(_DATADIR)/doc# # /usr/share/doc
_LOCALSTATEDIR ?= /var# # /var
_UNITDIR ?= /lib/systemd/system#
_TESTSDIR ?= /opt/tests# # /opt/tests

# Install directories within DESTDIR
VARDIR := $(_LOCALSTATEDIR)/lib/mce
Expand All @@ -136,11 +142,13 @@ BACKUPCONFDIR := $(_DATADIR)/backup-framework/applications
HELPERSCRIPTDIR := $(_DATADIR)/mce
DEVICECLEARSCRIPTDIR := $(_SYSCONFDIR)/osso-cud-scripts
FACTORYRESETSCRIPTDIR := $(_SYSCONFDIR)/osso-rfs-scripts
TESTSDESTDIR := $(_TESTSDIR)/mce

# Source directories
DOCDIR := doc
TOOLDIR := tools
TESTSDIR := tests
UTESTDIR := tests/ut
MODULE_DIR := modules

# Binaries to build
Expand Down Expand Up @@ -171,6 +179,13 @@ TOOLS += $(TOOLDIR)/evdev_trace
# Testapps to build
TESTS += $(TESTSDIR)/mcetorture

# Unit tests to build
UTESTS += $(UTESTDIR)/ut_display_conf
UTESTS += $(UTESTDIR)/ut_display_stm
UTESTS += $(UTESTDIR)/ut_display_filter
UTESTS += $(UTESTDIR)/ut_display_blanking_inhibit
UTESTS += $(UTESTDIR)/ut_display

# MCE configuration files
CONFFILE := 10mce.ini
RADIOSTATESCONFFILE := 20mce-radio-states.ini
Expand Down Expand Up @@ -400,19 +415,62 @@ $(TOOLDIR)/evdev_trace : $(TOOLDIR)/evdev_trace.o evdev.o

$(TESTSDIR)/mcetorture : $(TESTSDIR)/mcetorture.o

# ----------------------------------------------------------------------------
# UNIT TESTS
# ----------------------------------------------------------------------------

UTESTS_PKG_NAMES += check
UTESTS_PKG_NAMES += dbus-1
UTESTS_PKG_NAMES += dbus-glib-1
UTESTS_PKG_NAMES += gconf-2.0
UTESTS_PKG_NAMES += glib-2.0
UTESTS_PKG_NAMES += gthread-2.0

UTESTS_PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(UTESTS_PKG_NAMES))
UTESTS_PKG_LDLIBS := $(shell $(PKG_CONFIG) --libs $(UTESTS_PKG_NAMES))

UTESTS_CFLAGS += $(UTESTS_PKG_CFLAGS)
UTESTS_LDLIBS += $(UTESTS_PKG_LDLIBS)

UTESTS_CFLAGS += -fdata-sections -ffunction-sections
UTESTS_LDLIBS += -Wl,--gc-sections

$(UTESTDIR)/% : CFLAGS += $(UTESTS_CFLAGS)
$(UTESTDIR)/% : LDLIBS += $(UTESTS_LDLIBS)
$(UTESTDIR)/% : LDLIBS += $(foreach fn_sym,$(LINK_STUBS),\
-Wl,--defsym=$(fn_sym)=stub__$(fn_sym))
$(UTESTDIR)/% : $(UTESTDIR)/%.o

$(UTESTDIR)/ut_display : LINK_STUBS += mce_log_file
$(UTESTDIR)/ut_display : LINK_STUBS += mce_write_string_to_file
$(UTESTDIR)/ut_display : datapipe.o
$(UTESTDIR)/ut_display : mce-lib.o
$(UTESTDIR)/ut_display : modetransition.o

# ----------------------------------------------------------------------------
# ACTIONS FOR TOP LEVEL TARGETS
# ----------------------------------------------------------------------------

build:: $(TARGETS) $(MODULES) $(TOOLS)

ifeq ($(ENABLE_UNITTESTS_INSTALL),y)
build:: $(UTESTS)
endif

modules:: $(MODULES)

tools:: $(TOOLS)

check:: $(UTESTS)
for utest in $^; do ./$${utest} || exit; done

clean::
$(RM) $(TARGETS) $(TOOLS) $(MODULES)

ifeq ($(ENABLE_UNITTESTS_INSTALL),y)
$(RM) $(UTESTS)
endif

install:: build
$(INSTALL_DIR) $(DESTDIR)$(VARDIR)
$(INSTALL_DIR) $(DESTDIR)$(RUNDIR)
Expand Down Expand Up @@ -491,6 +549,15 @@ install_man_pages_sv::
$(INSTALL_DTA) man/mcetool.sv.8 $(DESTDIR)/$(_MANDIR)/sv/man8/mcetool.8
$(INSTALL_DTA) man/mcetorture.sv.8 $(DESTDIR)/$(_MANDIR)/sv/man8/mcetorture.8

ifeq ($(ENABLE_UNITTESTS_INSTALL),y)
install:: install_unittests
endif

install_unittests::
$(INSTALL_DIR) $(DESTDIR)$(TESTSDESTDIR)
$(INSTALL_BIN) $(UTESTS) $(DESTDIR)$(TESTSDESTDIR)
$(INSTALL_DTA) $(UTESTDIR)/tests.xml $(DESTDIR)$(TESTSDESTDIR)

# ----------------------------------------------------------------------------
# DOCUMENTATION
# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -528,7 +595,7 @@ fixme::
.PHONY: depend
depend::
@echo "Updating .depend"
$(CC) -MM $(CPPFLAGS) $(MCE_CFLAGS) *.c */*.c |\
$(CC) -MM $(CPPFLAGS) $(MCE_CFLAGS) *.c */*.c */*/*.c |\
./depend_filter.py > .depend

ifneq ($(MAKECMDGOALS),depend) # not while: make depend
Expand Down
12 changes: 12 additions & 0 deletions rpm/mce.spec
Expand Up @@ -37,6 +37,14 @@ Requires: %{name} = %{version}-%{release}
This package contains tools that can be used to interact with
the Mode Control Entity and to get mode information.

%package tests
Summary: Test suite for mce
Group: System/System Control
BuildRequires: pkgconfig(check)

%description tests
This package contains test suite for mce

%prep
%setup -q -n %{name}-%{version}

Expand Down Expand Up @@ -95,3 +103,7 @@ systemctl daemon-reload
%{_sbindir}/mcetorture
%{_mandir}/man8/mcetool.8.gz
%{_mandir}/man8/mcetorture.8.gz

%files tests
%defattr(-,root,root,-)
/opt/tests/mce/*

0 comments on commit 021d8c6

Please sign in to comment.