[sheepdog] [PATCH RFC 3/5] tests/dynamorio: add a new DR based tester for EMFILE handling
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Fri Jul 12 03:54:24 CEST 2013
DR is suitable for testing EMFILE handling because it can open files
transparently and consume fds. This patch adds a new DR client for
this purpose. With this client, we can insert fd consuming at arbital
timing.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
tests/dynamorio/emfile/01.sh | 24 +++++++++++++++++
tests/dynamorio/emfile/CMakeLists.txt | 9 +++++++
tests/dynamorio/emfile/emfile.c | 46 +++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+)
create mode 100755 tests/dynamorio/emfile/01.sh
create mode 100644 tests/dynamorio/emfile/CMakeLists.txt
create mode 100644 tests/dynamorio/emfile/emfile.c
diff --git a/tests/dynamorio/emfile/01.sh b/tests/dynamorio/emfile/01.sh
new file mode 100755
index 0000000..a0d66fa
--- /dev/null
+++ b/tests/dynamorio/emfile/01.sh
@@ -0,0 +1,24 @@
+#! /bin/bash
+
+# testing sockfd shrink with transparent fd consuming
+
+sudo killall -KILL sheep
+sudo killall -KILL shepherd
+
+sudo rm -rf /tmp/sheepdog/dynamorio/*
+
+sudo shepherd
+
+sudo ~/dynamorio/build/bin64/drrun -c libemfile.so 1000 -- \
+ sheep -d -c shepherd:127.0.0.1 -p 7000 -z 0 /tmp/sheepdog/dynamorio/0
+
+for i in `seq 1 5`;
+do
+ sudo sheep -d -c shepherd:127.0.0.1 -p 700$i -z $i\
+ /tmp/sheepdog/dynamorio/$i
+done
+
+sleep 3
+collie cluster format
+
+collie vdi create -P test 100M
diff --git a/tests/dynamorio/emfile/CMakeLists.txt b/tests/dynamorio/emfile/CMakeLists.txt
new file mode 100644
index 0000000..3a548df
--- /dev/null
+++ b/tests/dynamorio/emfile/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 2.8)
+
+SET(DynamoRIO_DIR "~/dynamorio/exports/cmake")
+find_package(DynamoRIO)
+
+add_library(emfile SHARED emfile.c ../common.c)
+configure_DynamoRIO_client(emfile)
+
+use_DynamoRIO_extension(emfile drwrap)
diff --git a/tests/dynamorio/emfile/emfile.c b/tests/dynamorio/emfile/emfile.c
new file mode 100644
index 0000000..7bdaf06
--- /dev/null
+++ b/tests/dynamorio/emfile/emfile.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * journaling.c: DynamoRIO based fault injector for testing the journaling
+ * mechanism of sheep
+ */
+
+#include "dr_api.h"
+
+#include "../common.h"
+#include <stdint.h>
+#include <string.h>
+
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+static int nr_consumed_fds;
+
+DR_EXPORT void dr_init(client_id_t id)
+{
+ int i;
+ const char *option;
+
+ init_log_file();
+
+ option = dr_get_options(id);
+ fi_printf("the passed option to this client: %s\n", option);
+ nr_consumed_fds = atoi(option);
+ fi_printf("number of consumed file descriptors: %d\n", nr_consumed_fds);
+
+ for (i = 0; i < nr_consumed_fds; i++) {
+ int fd = open("/dev/null", O_RDONLY);
+ if (fd < 0)
+ die("opening /dev/null failed: %m");
+ }
+}
--
1.7.10.4
More information about the sheepdog
mailing list