Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/string check return values
details: https://anonhg.NetBSD.org/src/rev/9853d6b708a5
branches: trunk
changeset: 785509:9853d6b708a5
user: christos <christos%NetBSD.org@localhost>
date: Sun Mar 17 02:23:31 2013 +0000
description:
check return values
diffstat:
tests/lib/libc/string/t_memcpy.c | 17 ++++++++++++++++-
tests/lib/libc/string/t_memset.c | 19 +++++++++++++++++--
2 files changed, 33 insertions(+), 3 deletions(-)
diffs (82 lines):
diff -r 0b7310739e42 -r 9853d6b708a5 tests/lib/libc/string/t_memcpy.c
--- a/tests/lib/libc/string/t_memcpy.c Sun Mar 17 02:13:10 2013 +0000
+++ b/tests/lib/libc/string/t_memcpy.c Sun Mar 17 02:23:31 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memcpy.c,v 1.4 2011/07/14 05:46:04 jruoho Exp $ */
+/* $NetBSD: t_memcpy.c,v 1.5 2013/03/17 02:23:31 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -125,10 +125,25 @@
ATF_CHECK(strncmp(buf, "xxxxxxx", 7) == 0);
}
+ATF_TC(memcpy_return);
+ATF_TC_HEAD(memcpy_return, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test memcpy(3) return value");
+}
+
+ATF_TC_BODY(memcpy_return, tc)
+{
+ char *b = (char *)0x1;
+ char c[2];
+ ATF_REQUIRE_EQ(memcpy(b, b, 0), b);
+ ATF_REQUIRE_EQ(memcpy(c, "ab", sizeof(c)), c);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, memcpy_basic);
+ ATF_TP_ADD_TC(tp, memcpy_return);
ATF_TP_ADD_TC(tp, memccpy_simple);
return atf_no_error();
diff -r 0b7310739e42 -r 9853d6b708a5 tests/lib/libc/string/t_memset.c
--- a/tests/lib/libc/string/t_memset.c Sun Mar 17 02:13:10 2013 +0000
+++ b/tests/lib/libc/string/t_memset.c Sun Mar 17 02:23:31 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $ */
+/* $NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $");
+__RCSID("$NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $");
#include <sys/stat.h>
@@ -63,6 +63,20 @@
atf_tc_fail("memset(3) did not fill a static buffer");
}
+ATF_TC(memset_return);
+ATF_TC_HEAD(memset_return, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test memset(3) return value");
+}
+
+ATF_TC_BODY(memset_return, tc)
+{
+ char *b = (char *)0x1;
+ char c[2];
+ ATF_REQUIRE_EQ(memset(b, 0, 0), b);
+ ATF_REQUIRE_EQ(memset(c, 2, sizeof(c)), c);
+}
+
ATF_TC(memset_basic);
ATF_TC_HEAD(memset_basic, tc)
{
@@ -187,6 +201,7 @@
ATF_TP_ADD_TC(tp, memset_basic);
ATF_TP_ADD_TC(tp, memset_nonzero);
ATF_TP_ADD_TC(tp, memset_struct);
+ ATF_TP_ADD_TC(tp, memset_return);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index