summaryrefslogtreecommitdiffstats
path: root/tests/basic/gfapi
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2014-06-17 17:44:11 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-03-26 12:26:38 -0700
commitbf8a5c9f21381690dc8ba25bcfba44619a6e2434 (patch)
tree648261a2f77d71aa28d2b683649c0f383425a91d /tests/basic/gfapi
parent02c045790136fc6e979a82d4d7fa8d1d298478fb (diff)
tests: Added a script to test the glfs_fini hang fix
The script has been added as '.sh' instead of '.t' to avoid regression tests failure which may happen due to instability of glfs_fini. In addition, there is still some support needed to compile libgfapi* tests in our current regression test framework. BUG: 1093594 Change-Id: If66817f330320e8c092340008b36616e1d954127 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/8092 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'tests/basic/gfapi')
-rw-r--r--tests/basic/gfapi/Makefile.am2
-rw-r--r--tests/basic/gfapi/libgfapi-fini-hang.c58
-rwxr-xr-xtests/basic/gfapi/libgfapi-fini-hang.sh40
3 files changed, 99 insertions, 1 deletions
diff --git a/tests/basic/gfapi/Makefile.am b/tests/basic/gfapi/Makefile.am
index 2041112a7af..39fc04b0f39 100644
--- a/tests/basic/gfapi/Makefile.am
+++ b/tests/basic/gfapi/Makefile.am
@@ -4,7 +4,7 @@
CFLAGS = -Wall -g $(shell pkg-config --cflags glusterfs-api)
LDFLAGS = $(shell pkg-config --libs glusterfs-api)
-BINARIES = upcall-cache-invalidate
+BINARIES = upcall-cache-invalidate libgfapi-fini-hang
%: %.c
diff --git a/tests/basic/gfapi/libgfapi-fini-hang.c b/tests/basic/gfapi/libgfapi-fini-hang.c
new file mode 100644
index 00000000000..ee16bd7ce58
--- /dev/null
+++ b/tests/basic/gfapi/libgfapi-fini-hang.c
@@ -0,0 +1,58 @@
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+#include <limits.h>
+#include <alloca.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "api/glfs.h"
+#include "api/glfs-handles.h"
+
+#define LOG_ERR(func, ret) do { \
+ if (ret != 0) { \
+ fprintf (stderr, "%s : returned error %d\n", func, ret); \
+ exit(1); \
+ } else { \
+ fprintf (stderr, "%s : returned %d\n", func, ret); \
+ } \
+} while (0)
+
+int
+main (int argc, char *argv[])
+{
+ glfs_t *fs = NULL;
+ int ret = 0, i;
+ glfs_fd_t *fd = NULL;
+ char readbuf[32];
+ char *filename = "a1";
+
+ fprintf (stderr, "Starting libgfapi_fini\n");
+
+ if (argc < 2) {
+ fprintf (stderr, "Invalid argument\n");
+ exit(1);
+ }
+
+ fs = glfs_new (argv[1]);
+ if (!fs) {
+ fprintf (stderr, "glfs_new: returned NULL\n");
+ exit(1);
+ }
+
+ ret = glfs_set_volfile_server (fs, "tcp", "localhost", 0);
+ LOG_ERR("glfs_set_volfile_server", ret);
+
+ ret = glfs_set_logging (fs, "/dev/stderr", 7);
+ LOG_ERR("glfs_set_logging", ret);
+
+ /* Do not call glfs_init.
+ * glfs_fini() shouldn't hang in that case*/
+ ret = glfs_fini(fs);
+ LOG_ERR("glfs_fini", ret);
+ fprintf (stderr, "End of libgfapi_fini\n");
+
+ exit(0);
+}
+
+
diff --git a/tests/basic/gfapi/libgfapi-fini-hang.sh b/tests/basic/gfapi/libgfapi-fini-hang.sh
new file mode 100755
index 00000000000..56633288020
--- /dev/null
+++ b/tests/basic/gfapi/libgfapi-fini-hang.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+
+function check_process () {
+ pgrep libgfapi-fini-hang
+ if [ $? -eq 1 ] ; then
+ echo "Y"
+ else
+ echo "N"
+ fi
+}
+
+cleanup;
+
+TEST glusterd
+
+TEST $CLI volume create $V0 $H0:$B0/brick1;
+EXPECT 'Created' volinfo_field $V0 'Status';
+
+TEST $CLI volume start $V0;
+EXPECT 'Started' volinfo_field $V0 'Status';
+
+build_tester -lgfapi $(dirname $0)/libgfapi-fini-hang.c -o $M0/libgfapi-fini-hang
+TEST cd $M0
+ ./libgfapi-fini-hang $V0 &
+lpid=$!
+
+# check if the process "libgfapi-fini-hang" exits with in $PROCESS_UP_TIMEOUT
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Y' check_process
+
+# Kill the process if present
+TEST ! kill -9 $lpid
+
+TEST rm -f $M0/libgfapi-fini-hang
+
+TEST $CLI volume stop $V0
+TEST $CLI volume delete $V0
+
+cleanup;