From e5915e967bd434611f3ae418dde7a70517cd5e24 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Wed, 30 Jan 2019 10:14:01 -0800 Subject: [PATCH] t/kvs: Add lookup_invalid rpc coverage test --- t/Makefile.am | 6 ++++ t/kvs/lookup_invalid.c | 72 +++++++++++++++++++++++++++++++++++++++++ t/t1001-kvs-internals.t | 9 ++++++ 3 files changed, 87 insertions(+) create mode 100644 t/kvs/lookup_invalid.c diff --git a/t/Makefile.am b/t/Makefile.am index 9e5529539ad7..4578a03f937d 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -258,6 +258,7 @@ check_PROGRAMS = \ kvs/transactionmerge \ kvs/fence_namespace_remove \ kvs/fence_invalid \ + kvs/lookup_invalid \ kvs/commit_order \ kvs/issue1760 \ kvs/issue1876 \ @@ -382,6 +383,11 @@ kvs_fence_invalid_CPPFLAGS = $(test_cppflags) kvs_fence_invalid_LDADD = \ $(test_ldadd) $(LIBDL) $(LIBUTIL) +kvs_lookup_invalid_SOURCES = kvs/lookup_invalid.c +kvs_lookup_invalid_CPPFLAGS = $(test_cppflags) +kvs_lookup_invalid_LDADD = \ + $(test_ldadd) $(LIBDL) $(LIBUTIL) + kvs_commit_order_SOURCES = kvs/commit_order.c kvs_commit_order_CPPFLAGS = $(test_cppflags) kvs_commit_order_LDADD = \ diff --git a/t/kvs/lookup_invalid.c b/t/kvs/lookup_invalid.c new file mode 100644 index 000000000000..78855dda8aec --- /dev/null +++ b/t/kvs/lookup_invalid.c @@ -0,0 +1,72 @@ +/************************************************************\ + * Copyright 2014 Lawrence Livermore National Security, LLC + * (c.f. AUTHORS, NOTICE.LLNS, COPYING) + * + * This file is part of the Flux resource manager framework. + * For details, see https://github.com/flux-framework. + * + * SPDX-License-Identifier: LGPL-3.0 +\************************************************************/ + +#if HAVE_CONFIG_H +#include "config.h" +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/common/libutil/oom.h" +#include "src/common/libutil/log.h" +#include "src/common/libutil/xzmalloc.h" + +static void usage (void) +{ + fprintf (stderr, "Usage: lookup_invalid key\n"); + exit (1); +} + +int main (int argc, char *argv[]) +{ + flux_t *h = NULL; + char *key = NULL; + flux_future_t *f = NULL; + + log_init (basename (argv[0])); + + if (argc != 2) + usage (); + key = argv[1]; + + if (!(h = flux_open (NULL, 0))) { + log_err_exit ("flux_open"); + goto done; + } + + /* invalid lookup - do not specify namespace or root ref */ + if (!(f = flux_rpc_pack (h, "kvs.lookup", FLUX_NODEID_ANY, 0, + "{s:s s:i}", + "key", key, + "flags", 0))) + log_err_exit ("flux_rpc_pack"); + + if (flux_future_get (f, NULL) < 0) { + printf ("flux_future_get: %s\n", flux_strerror (errno)); + goto done; + } + +done: + flux_future_destroy (f); + flux_close (h); + log_fini (); + + return 0; +} + +/* + * vi:tabstop=4 shiftwidth=4 expandtab + */ diff --git a/t/t1001-kvs-internals.t b/t/t1001-kvs-internals.t index 6b548f68d01a..bb5199153f87 100755 --- a/t/t1001-kvs-internals.t +++ b/t/t1001-kvs-internals.t @@ -465,4 +465,13 @@ test_expect_success 'kvs: test invalid fence arguments on rank 1' ' grep "flux_future_get: Invalid argument" invalid_output ' +# +# test invalid lookup rpc +# + +test_expect_success 'kvs: test invalid lookup rpc' ' + ${FLUX_BUILD_DIR}/t/kvs/lookup_invalid a-key > lookup_invalid_output && + grep "flux_future_get: Protocol error" lookup_invalid_output +' + test_done