summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-02-22 19:34:25 +0100
committerWerner Koch <wk@gnupg.org>2013-02-22 19:34:25 +0100
commitab2e01598446120dac09e49c63a5c8fc27a1bc32 (patch)
tree8f4754f75299d38a2b2f7b2cfc4d85c20b5205b6 /tests
parenta4d64a06f9b80ed58cd8f9ca4a68393733c36b1f (diff)
downloadlibassuan-ab2e01598446120dac09e49c63a5c8fc27a1bc32.tar.gz
Add assuan_check_version and ASSUAN_VERSION_NUMBER.
* src/assuan.c (assuan_check_version): New. (digitp, parse_version_number, parse_version_string) (compare_versions): New. Taken from libksba. * configure.ac (VERSION_NUMBER): New ac_subst. * src/Makefile.am (assuan.h): Pass VERSION and VERSION_NUMBER to mkheader. * src/assuan.h.in (ASSUAN_VERSION, ASSUAN_VERSION_NUMBER): New macros. (assuan_check_version): New prototype. * src/libassuan.def, src/libassuan.vers: Add assuan_check_version. * src/mkheader.c (write_special, main): Support version and version_number. * tests/version.c: New. * tests/Makefile.am (TESTS): Add version. -- All our other libs have a version number check, thus we should have one in Libassuan as well.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/version.c90
2 files changed, 95 insertions, 5 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d82e18b..024ffe2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,17 +18,17 @@
## Process this file with automake to produce Makefile.in
-TESTS_ENVIRONMENT =
+TESTS_ENVIRONMENT =
EXTRA_DIST = motd ce-createpipe.c
-BUILT_SOURCES =
-CLEANFILES =
+BUILT_SOURCES =
+CLEANFILES =
-TESTS = pipeconnect
+TESTS = version pipeconnect
if HAVE_W32CE_SYSTEM
-w32cetools = ce-createpipe ce-server
+w32cetools = ce-createpipe ce-server
endif
if USE_DESCRIPTOR_PASSING
diff --git a/tests/version.c b/tests/version.c
new file mode 100644
index 0000000..96e43c0
--- /dev/null
+++ b/tests/version.c
@@ -0,0 +1,90 @@
+/* version.c - Check the version info fucntions
+ Copyright (C) 2013 g10 Code GmbH
+
+ This file is part of Assuan.
+
+ Assuan is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Assuan is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "../src/assuan.h"
+#include "common.h"
+
+
+/*
+
+ M A I N
+
+*/
+int
+main (int argc, char **argv)
+{
+ int last_argc = -1;
+
+ if (argc)
+ {
+ log_set_prefix (*argv);
+ argc--; argv++;
+ }
+ while (argc && last_argc != argc )
+ {
+ last_argc = argc;
+ if (!strcmp (*argv, "--help"))
+ {
+ puts (
+"usage: ./version [options]\n"
+"\n"
+"Options:\n"
+" --verbose Show what is going on\n"
+);
+ exit (0);
+ }
+ if (!strcmp (*argv, "--verbose"))
+ {
+ verbose = 1;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--debug"))
+ {
+ verbose = debug = 1;
+ argc--; argv++;
+ }
+ }
+
+ assuan_set_assuan_log_prefix (log_prefix);
+
+ if (!assuan_check_version (ASSUAN_VERSION))
+ log_error ("assuan_check_version returned an error\n");
+ if (!assuan_check_version ("2.0.99"))
+ log_error ("assuan_check_version returned an error for an old version\n");
+ if (assuan_check_version ("15"))
+ log_error ("assuan_check_version did not returned an error"
+ " for a newer version\n");
+ if (verbose || errorcount)
+ {
+ log_info ("Version from header: %s (0x%06x)\n",
+ ASSUAN_VERSION, ASSUAN_VERSION_NUMBER);
+ log_info ("Version from binary: %s \n", assuan_check_version (NULL));
+ }
+
+ return errorcount ? 1 : 0;
+}