[Pkg-shadow-commits] r3405 - debian/trunk/tests/common
Nicolas FRANÇOIS
nekral-guest at alioth.debian.org
Thu Jul 14 16:40:03 UTC 2011
Author: nekral-guest
Date: 2011-07-14 16:40:03 +0000 (Thu, 14 Jul 2011)
New Revision: 3405
Added:
debian/trunk/tests/common/open_RDWR_failure.c
debian/trunk/tests/common/time_0.c
Log:
Added 2 libraries to support error injection.
Added: debian/trunk/tests/common/open_RDWR_failure.c
===================================================================
--- debian/trunk/tests/common/open_RDWR_failure.c (rev 0)
+++ debian/trunk/tests/common/open_RDWR_failure.c 2011-07-14 16:40:03 UTC (rev 3405)
@@ -0,0 +1,51 @@
+/*
+ * gcc open_RDWR_failure.c -o open_RDWR_failure.so -shared -ldl
+ * LD_PRELOAD=./open_RDWR_failure.so FAILURE_PATH=/etc/shadow ./test /etc/shadow
+ */
+
+#define _GNU_SOURCE
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+typedef int (*open_type) (const char *pathname, int flag, ...);
+static open_type next_open;
+
+static const char *failure_path = NULL;
+
+int open64 (const char *pathname, int flag, ...)
+{
+ if (NULL == next_open)
+ {
+ next_open = dlsym (RTLD_NEXT, "open64");
+ assert (NULL != next_open);
+ }
+ if (NULL == failure_path) {
+ failure_path = getenv ("FAILURE_PATH");
+ if (NULL == failure_path) {
+ fputs ("No FAILURE_PATH defined\n", stderr);
+ }
+ }
+
+ if ( (NULL != pathname)
+ && (flag & O_RDWR)
+ && (NULL != failure_path)
+ && (strcmp (pathname, failure_path) == 0))
+ {
+ fprintf (stderr, "open FAILURE %s %x ...\n", pathname, flag);
+ errno = EIO;
+ return -1;
+ }
+
+ return next_open (pathname, flag);
+}
+
Added: debian/trunk/tests/common/time_0.c
===================================================================
--- debian/trunk/tests/common/time_0.c (rev 0)
+++ debian/trunk/tests/common/time_0.c 2011-07-14 16:40:03 UTC (rev 3405)
@@ -0,0 +1,16 @@
+/*
+ * gcc time_0.c -o time_0.so -shared
+ * LD_PRELOAD=./time_0.so ./test
+ */
+
+#include <stdio.h>
+#include <time.h>
+
+
+time_t time (time_t *t)
+{
+ fprintf (stderr, "time 0\n");
+
+ return (time_t)0;
+}
+
More information about the Pkg-shadow-commits
mailing list