Skip to content

Commit

Permalink
t/kvs: Add lookup_invalid rpc coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
chu11 committed Jan 31, 2019
1 parent 2c67fd7 commit e5915e9
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
6 changes: 6 additions & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 = \
Expand Down
72 changes: 72 additions & 0 deletions t/kvs/lookup_invalid.c
Original file line number Diff line number Diff line change
@@ -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 <assert.h>
#include <libgen.h>
#include <pthread.h>
#include <getopt.h>
#include <inttypes.h>
#include <czmq.h>
#include <jansson.h>
#include <flux/core.h>

#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
*/
9 changes: 9 additions & 0 deletions t/t1001-kvs-internals.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e5915e9

Please sign in to comment.