Skip to content

Commit

Permalink
libkvs/test: Add simple error check tests
Browse files Browse the repository at this point in the history
Add simple error check tests for kvs_lookup and kvs_dir.
  • Loading branch information
chu11 committed Aug 18, 2017
1 parent 306a7aa commit 9d4ad17
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/common/libkvs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ fluxcoreinclude_HEADERS = \

TESTS = \
test_jansson_dirent.t \
test_kvs_txn.t
test_kvs_txn.t \
test_kvs_lookup.t \
test_kvs_dir.t

check_PROGRAMS = \
$(TESTS)
Expand All @@ -61,3 +63,11 @@ test_jansson_dirent_t_LDADD = $(test_ldadd)
test_kvs_txn_t_SOURCES = test/kvs_txn.c
test_kvs_txn_t_CPPFLAGS = $(test_cppflags)
test_kvs_txn_t_LDADD = $(test_ldadd) $(LIBDL)

test_kvs_lookup_t_SOURCES = test/kvs_lookup.c
test_kvs_lookup_t_CPPFLAGS = $(test_cppflags)
test_kvs_lookup_t_LDADD = $(test_ldadd) $(LIBDL)

test_kvs_dir_t_SOURCES = test/kvs_dir.c
test_kvs_dir_t_CPPFLAGS = $(test_cppflags)
test_kvs_dir_t_LDADD = $(test_ldadd) $(LIBDL)
36 changes: 36 additions & 0 deletions src/common/libkvs/test/kvs_dir.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <string.h>
#include <errno.h>

#include "src/common/libflux/flux.h"
#include "kvs_dir.h"
#include "src/common/libtap/tap.h"

void test_error (void)
{
kvsdir_t *dir;

errno = 0;
dir = kvsdir_create (NULL, NULL, NULL, NULL);
ok (dir == NULL && errno == EINVAL,
"kvsdir_create with all NULL args fails with EINVAL");
}

int main (int argc, char *argv[])
{

plan (NO_PLAN);

test_error ();

done_testing();
return (0);
}

/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/

39 changes: 39 additions & 0 deletions src/common/libkvs/test/kvs_lookup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <string.h>
#include <errno.h>

#include "src/common/libflux/flux.h"
#include "kvs_lookup.h"
#include "src/common/libtap/tap.h"

void errors (void)
{
/* check simple error cases */

errno = 0;
ok (flux_kvs_lookup (NULL, 0, NULL) == NULL && errno == EINVAL,
"flux_kvs_lookup fails on bad input");

errno = 0;
ok (flux_kvs_lookupat (NULL, 0, NULL, NULL) == NULL && errno == EINVAL,
"flux_kvs_lookupat fails on bad input");
}

int main (int argc, char *argv[])
{

plan (NO_PLAN);

errors ();

done_testing();
return (0);
}

/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/

0 comments on commit 9d4ad17

Please sign in to comment.