diff --git a/src/modules/kvs/test/commit.c b/src/modules/kvs/test/commit.c index f9d2ce956048..f9630c3c4779 100644 --- a/src/modules/kvs/test/commit.c +++ b/src/modules/kvs/test/commit.c @@ -745,6 +745,42 @@ void commit_basic_commit_process_test_multiple_fences_merge (void) cache_destroy (cache); } +void commit_basic_commit_process_test_invalid_commit (void) +{ + struct cache *cache; + commit_mgr_t *cm; + commit_t *cbad, *c; + blobref_t rootref; + + cache = create_cache_with_empty_rootdir (rootref); + + ok ((cm = commit_mgr_create (cache, + KVS_PRIMARY_NAMESPACE, + "sha1", + NULL, + &test_global)) != NULL, + "commit_mgr_create works"); + + create_ready_commit (cm, "fence1", "key1", "1", 0, 0); + create_ready_commit (cm, "fence2", "key2", "2", 0, 0); + + ok ((cbad = commit_mgr_get_ready_commit (cm)) != NULL, + "commit_mgr_get_ready_commit returns ready commit"); + + ok (commit_mgr_merge_ready_commits (cm) == 0, + "commit_mgr_merge_ready_commits success"); + + ok ((c = commit_mgr_get_ready_commit (cm)) != NULL, + "commit_mgr_get_ready_commit returns ready commit"); + + ok (commit_process (cbad, 1, rootref) == COMMIT_PROCESS_ERROR + && commit_get_errnum (cbad) == EINVAL, + "commit_process fails on bad commit"); + + commit_mgr_destroy (cm); + cache_destroy (cache); +} + void commit_basic_root_not_dir (void) { struct cache *cache; @@ -2304,6 +2340,7 @@ int main (int argc, char *argv[]) commit_basic_commit_process_test (); commit_basic_commit_process_test_multiple_fences (); commit_basic_commit_process_test_multiple_fences_merge (); + commit_basic_commit_process_test_invalid_commit (); commit_basic_root_not_dir (); commit_basic_iter_not_ready_tests (); commit_process_root_missing ();