]> granicus.if.org Git - check/commitdiff
check_check_pack: add tests for using pack(), upack() improperly
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sat, 4 Jan 2014 18:34:10 +0000 (18:34 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sat, 4 Jan 2014 18:34:10 +0000 (18:34 +0000)
Sure, check does not use these improperly, but if we did,
just making sure they respond as expected.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1028 64e312b2-a51f-0410-8e61-82d0ca0eb02a

tests/check_check_pack.c

index dad75c3d761bf1a207bdb152e451e41aa1543314..baa1bb2d74a8a811261565af422417796c34d830 100644 (file)
@@ -131,6 +131,22 @@ START_TEST(test_pack_len)
 }
 END_TEST
 
+START_TEST(test_pack_abuse)
+{
+  char *buf;
+  CtxMsg cmsg;
+
+  /* Should report -1 (e.g. invalid) if no buffer is passed */
+  ck_assert_int_eq(pack(CK_MSG_CTX, NULL, (CheckMsg *) &cmsg), -1);
+
+  /* Should report 0 (e.g. nothing packed) if no message is passed */
+  ck_assert_int_eq(pack(CK_MSG_CTX, &buf, NULL), 0);
+
+  /* Should report -1 (e.g. invalid) if no buffer is passed */
+  ck_assert_int_eq(upack(NULL, (CheckMsg *) &cmsg, CK_MSG_CTX), -1);
+}
+END_TEST
+
 START_TEST(test_pack_ctx_limit)
 {
   CtxMsg cmsg;
@@ -403,6 +419,7 @@ Suite *make_pack_suite(void)
   tcase_add_test (tc_core, test_pack_loc);
   tcase_add_test (tc_core, test_pack_ctx);
   tcase_add_test (tc_core, test_pack_len);
+  tcase_add_test (tc_core, test_pack_abuse);
 #if defined(HAVE_FORK) && HAVE_FORK==1
   tcase_add_test (tc_core, test_ppack);
   tcase_add_test (tc_core, test_ppack_noctx);