From: Karel Zak Date: Fri, 27 Nov 2009 00:13:01 +0000 (+0100) Subject: libmount: add test_version X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=055927931ca5a6acc106366f1e097ac18401fc69;p=util-linux libmount: add test_version Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/Makefile.am b/shlibs/mount/src/Makefile.am index 0483367a..f9cc68f9 100644 --- a/shlibs/mount/src/Makefile.am +++ b/shlibs/mount/src/Makefile.am @@ -20,7 +20,7 @@ libmount_la_DEPENDENCIES = $(libmount_la_LIBADD) mount.sym mount.h.in libmount_la_LDFLAGS = -Wl,--version-script=$(ul_libmount_srcdir)/mount.sym \ -version-info $(LIBMOUNT_VERSION_INFO) -tests = +tests = test_version EXTRA_DIST = mount.sym mount.h.in CLEANFILES = $(tests) diff --git a/shlibs/mount/src/version.c b/shlibs/mount/src/version.c index 8fd38a3c..0380e1c2 100644 --- a/shlibs/mount/src/version.c +++ b/shlibs/mount/src/version.c @@ -50,3 +50,31 @@ int mnt_get_library_version(const char **ver_string) return mnt_parse_version_string(lib_version); } + +#ifdef TEST_PROGRAM +int test_version(struct mtest *ts, int argc, char *argv[]) +{ + const char *ver; + + mnt_get_library_version(&ver); + + printf("Library version: %s\n", ver); + printf("Library API version: " LIBMOUNT_VERSION "\n"); + + if (mnt_get_library_version(NULL) == + mnt_parse_version_string(LIBMOUNT_VERSION)) + return 0; + + return -1; +} + +int main(int argc, char *argv[]) +{ + struct mtest ts[] = { + { "--print", test_version, "print versions" }, + { NULL } + }; + + return mnt_run_test(ts, argc, argv); +} +#endif