diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic/gfapi/Makefile.am | 2 | ||||
-rw-r--r-- | tests/basic/gfapi/gfapi-load-volfile.c | 65 | ||||
-rw-r--r-- | tests/basic/gfapi/gfapi-load-volfile.t | 28 | ||||
-rw-r--r-- | tests/basic/gfapi/protocol-client.vol.in | 14 |
4 files changed, 108 insertions, 1 deletions
diff --git a/tests/basic/gfapi/Makefile.am b/tests/basic/gfapi/Makefile.am index 3cad969672e..e30fefea5b9 100644 --- a/tests/basic/gfapi/Makefile.am +++ b/tests/basic/gfapi/Makefile.am @@ -5,7 +5,7 @@ CFLAGS = -Wall -g $(shell pkg-config --cflags glusterfs-api) LDFLAGS = $(shell pkg-config --libs glusterfs-api) BINARIES = upcall-cache-invalidate libgfapi-fini-hang anonymous_fd seek \ - bug1283983 bug1291259 gfapi-ssl-test + bug1283983 bug1291259 gfapi-ssl-test gfapi-load-volfile %: %.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ diff --git a/tests/basic/gfapi/gfapi-load-volfile.c b/tests/basic/gfapi/gfapi-load-volfile.c new file mode 100644 index 00000000000..91d5677bd44 --- /dev/null +++ b/tests/basic/gfapi/gfapi-load-volfile.c @@ -0,0 +1,65 @@ +/* + * Create a glfs instance based on a .vol file + * + * This is used to measure memory leaks by initializing a graph through a .vol + * file and destroying it again. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <api/glfs.h> + +#define PROGNAME "gfapi-load-volfile" + +void +usage(FILE *output) +{ + fprintf(output, "Usage: " PROGNAME " <volfile>\n"); +} + +void +main(int argc, char **argv) +{ + int ret = 0; + glfs_t *fs = NULL; + + if (argc != 2) { + usage(stderr); + exit(EXIT_FAILURE); + } + + if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-h")) { + usage(stdout); + exit(EXIT_SUCCESS); + } + + fs = glfs_new(PROGNAME); + if (!fs) { + perror("glfs_new failed"); + exit(EXIT_FAILURE); + } + + glfs_set_logging(fs, PROGNAME ".log", 9); + + ret = glfs_set_volfile(fs, argv[1]); + if (ret) { + perror("glfs_set_volfile failed"); + ret = EXIT_FAILURE; + goto out; + } + + ret = glfs_init(fs); + if (ret) { + perror("glfs_init failed"); + ret = EXIT_FAILURE; + goto out; + } + + ret = EXIT_SUCCESS; +out: + glfs_fini(fs); + + exit(ret); +} diff --git a/tests/basic/gfapi/gfapi-load-volfile.t b/tests/basic/gfapi/gfapi-load-volfile.t new file mode 100644 index 00000000000..d914cacd819 --- /dev/null +++ b/tests/basic/gfapi/gfapi-load-volfile.t @@ -0,0 +1,28 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup + +TEST glusterd + +TEST $CLI volume create ${V0} ${H0}:${B0}/brick0 +EXPECT 'Created' volinfo_field ${V0} 'Status' + +TEST $CLI volume start ${V0} +EXPECT 'Started' volinfo_field ${V0} 'Status' + +TEST build_tester $(dirname ${0})/gfapi-load-volfile.c -lgfapi + +sed -e "s,@@HOSTNAME@@,${H0},g" -e "s,@@BRICKPATH@@,${B0}/brick0,g" \ + $(dirname ${0})/protocol-client.vol.in \ + > $(dirname ${0})/protocol-client.vol + +TEST ./$(dirname ${0})/gfapi-load-volfile \ + $(dirname ${0})/protocol-client.vol + +cleanup_tester $(dirname ${0})/gfapi-load-volfile +cleanup_tester $(dirname ${0})/protocol-client.vol + +cleanup diff --git a/tests/basic/gfapi/protocol-client.vol.in b/tests/basic/gfapi/protocol-client.vol.in new file mode 100644 index 00000000000..ef35001e29f --- /dev/null +++ b/tests/basic/gfapi/protocol-client.vol.in @@ -0,0 +1,14 @@ +# +# This .vol file expects that there is +# +# 1. GlusterD listening on @@HOSTNAME@@ +# 2. a volume that provides a brick on @@BRICKPATH@@ +# 3. the volume with the brick has been started +# +volume test + type protocol/client + option remote-host @@HOSTNAME@@ + option remote-subvolume @@BRICKPATH@@ + option transport-type socket +end-volume + |