[parted-devel] [PATCH] Add check unittest support and a initial
test for a resizing bug.
Otavio Salvador
otavio at ossystems.com.br
Tue Dec 5 02:45:40 CET 2006
From: Otavio Salvador <otavio at ossystems.com.br>
---
configure.ac | 5 +++++
libparted/Makefile.am | 8 +++++++-
libparted/tests/Makefile.am | 11 +++++++++++
libparted/tests/resize.c | 27 +++++++++++++++++++++++++++
4 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8200564..5dc4ebc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -432,6 +432,10 @@ AC_CHECK_HEADER([execinfo.h], [
])
])
+dnl check for "check", unit testing library/header
+PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
+AM_CONDITIONAL(HAVE_CHECK, test "x$CHECK_LIBS" != "x")
+
dnl Checks for typedefs, structures and compiler characteristics.
AC_PROG_LD
@@ -486,6 +490,7 @@ libparted/fs/ntfs/Makefile
libparted/fs/reiserfs/Makefile
libparted/fs/ufs/Makefile
libparted/fs/xfs/Makefile
+libparted/tests/Makefile
parted/Makefile
partprobe/Makefile
doc/Makefile
diff --git a/libparted/Makefile.am b/libparted/Makefile.am
index 0cb7c09..b071658 100644
--- a/libparted/Makefile.am
+++ b/libparted/Makefile.am
@@ -3,7 +3,13 @@
#
# This file may be modified and/or distributed without restriction.
-SUBDIRS = labels fs
+if HAVE_CHECK
+SUBDIRS_CHECK = tests
+else
+SUBDIRS_CHECK =
+endif
+
+SUBDIRS = labels fs . $(SUBDIRS_CHECK)
LIBS = @INTLLIBS@ @LIBS@
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
new file mode 100644
index 0000000..c4e66e5
--- /dev/null
+++ b/libparted/tests/Makefile.am
@@ -0,0 +1,11 @@
+# This file is part of GNU Parted
+# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+#
+# This file may be modified and/or distributed without restriction.
+
+TESTS = resize
+bin_PROGRAMS = resize
+resize_CFLAGS = @CHECK_CFLAGS@ -I$(top_srcdir)/include
+resize_LDADD = @CHECK_LIBS@ $(top_builddir)/libparted/libparted.la
+resize_SOURCES = resize.c
+
diff --git a/libparted/tests/resize.c b/libparted/tests/resize.c
new file mode 100644
index 0000000..761f81a
--- /dev/null
+++ b/libparted/tests/resize.c
@@ -0,0 +1,27 @@
+#include <parted/parted.h>
+#include <check.h>
+
+START_TEST (test_start_sector)
+{
+ fail_unless(0 == 0, "Erro proposital");
+}
+END_TEST
+
+int main(void)
+{
+ int number_failed;
+ Suite *suite = suite_create( "Resize" );
+ TCase *basic = tcase_create( "Basic" );
+
+ tcase_add_test( basic, test_start_sector );
+ suite_add_tcase( suite, basic );
+
+ SRunner *srunner = srunner_create( suite );
+ srunner_run_all( srunner, CK_VERBOSE );
+
+ number_failed = srunner_ntests_failed( srunner );
+ srunner_free(srunner);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
More information about the parted-devel
mailing list