Skip to content

Commit

Permalink
Add makefiles for testing and a sample test #19
Browse files Browse the repository at this point in the history
  • Loading branch information
giovaneliberato committed Jul 20, 2018
1 parent af013f7 commit fedd7a9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ m4/ltversion.m4
m4/lt~obsolete.m4
m4/intltool.m4

po/pidgin-otrng.pot
pidgin-otr4.pot
po/Makefile.in.in
po/*.gmo
po/Makefile
po/POTFILES
po/stamp-it
stamp-h1

test/Makefile
test/Makefile.in
test/test
test/test-test.o
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AM_CFLAGS+= -DUSING_GTK -DPURPLE_PLUGINS \
-DPIDGIN_OTR_VERSION=\"@VERSION@\" \
-DLOCALEDIR=\"$(datadir)/locale\"

SUBDIRS= po
SUBDIRS= po test

plugindir= ${libdir}/pidgin

Expand Down Expand Up @@ -33,3 +33,6 @@ DISTCLEANFILES= intltool-extract intltool-merge intltool-update

code-style:
clang-format -style=file -i config.h *.h *.c

test: check
test/test
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LT_INIT([disable-static])
AM_PATH_LIBGCRYPT(1:1.2.0,,AC_MSG_ERROR(libgcrypt 1.2.0 or newer is required.))
AM_PATH_LIBOTR(4.0.0,,AC_MSG_ERROR(libotr 4.x >= 4.0.0 is required.))
PKG_CHECK_MODULES([LIBOTRNG], [libotr-ng >= 0.0.1])
PKG_CHECK_MODULES([TEST], [glib-2.0 >= 2.6])
PKG_CHECK_MODULES([EXTRA], [glib-2.0 >= 2.6 gtk+-2.0 >= 2.6 pidgin >= 2.0 purple >= 2.0])

AC_PROG_INTLTOOL
Expand Down Expand Up @@ -165,7 +166,7 @@ if test x$enable_linker_hardening != xno; then
OTR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
fi

AC_OUTPUT([Makefile po/Makefile.in])
AC_OUTPUT([Makefile po/Makefile.in test/Makefile])

echo \
"----------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#TODO include license

check_PROGRAMS = test

test_SOURCES = test.c \
$(pidgin_otrng_la_SOURCES)

test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
test_LDFLAGS = $(pidgin_otrng_la_LDFLAGS) @TEST_LIBS@
11 changes: 11 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <glib.h>

#include "test_plugin.c"

int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);

g_test_add_func("/plugin/sample", test_sample_plugin);

return g_test_run();
}
6 changes: 6 additions & 0 deletions test/test_plugin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <glib.h>


void test_sample_plugin(void) {
g_assert_cmpint(1 + 1, ==, 2);
}

0 comments on commit fedd7a9

Please sign in to comment.