summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2006-09-14 14:24:34 +0000
committerWerner Koch <wk@gnupg.org>2006-09-14 14:24:34 +0000
commit12172fa6fa5136cfaa8eca23cb83840386a3892f (patch)
tree8261c598e67f51dd708bc9b2a11f56704e2db224 /tests
parent1a01e7ec9f4943367ed27330017f52a1bf2cbaa5 (diff)
downloadlibgpg-error-12172fa6fa5136cfaa8eca23cb83840386a3892f.tar.gz
Ready for a new releaselibgpg-error-1.4
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/t-syserror.c84
2 files changed, 85 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0530cf8..488f86f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,7 +19,7 @@
## Process this file with automake to produce Makefile.in
-TESTS = t-strerror
+TESTS = t-strerror t-syserror
INCLUDES = -I$(top_builddir)/src
diff --git a/tests/t-syserror.c b/tests/t-syserror.c
new file mode 100644
index 0000000..b6973c3
--- /dev/null
+++ b/tests/t-syserror.c
@@ -0,0 +1,84 @@
+/* t-syserror.c - System error specific regression test.
+ Copyright (C) 2006 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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.
+
+ libgpg-error 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 libgpgme-error; if not, write to the Free
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <errno.h>
+
+#include <gpg-error.h>
+
+int
+main (int argc, char *argv[])
+{
+ FILE *fp;
+ int save_errno;
+ gpg_err_code_t ec;
+
+ fp = fopen ("/does-not-exist/110761/nowhere.foo", "r");
+ if (fp)
+ {
+ fclose (fp);
+ fp = fopen (" no this file does not exists foo 4711", "r");
+ }
+ if (fp)
+ {
+ fprintf (stderr, "unable to run test\n");
+ return 1;
+ }
+ save_errno = errno;
+
+ ec = gpg_err_code_from_syserror ();
+ if (ec != GPG_ERR_ENOENT)
+ {
+ fprintf (stderr, "fopen failed with bad code: %d\n", save_errno);
+ return 1;
+ }
+
+ if (ec != gpg_err_code_from_errno (save_errno))
+ {
+ fprintf (stderr, "oops at %d\n",__LINE__);
+ return 1;
+ }
+
+ errno = 0;
+
+ ec = gpg_err_code_from_syserror ();
+ if (ec != GPG_ERR_MISSING_ERRNO)
+ {
+ fprintf (stderr, "oops at %d\n",__LINE__);
+ return 1;
+ }
+
+ if ( gpg_err_code_from_errno (0) )
+ {
+ fprintf (stderr, "oops at %d\n",__LINE__);
+ return 1;
+ }
+
+
+ return 0;
+}