From 64cf2356bef36ab5afd66a7f3623dde7252d274d Mon Sep 17 00:00:00 2001 From: jruoho Date: Wed, 6 Apr 2011 17:41:27 +0000 Subject: [PATCH] Add a test case for the segfault reported in PR lib/43964. --- tests/lib/libprop/t_basic.c | 43 +++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/lib/libprop/t_basic.c b/tests/lib/libprop/t_basic.c index 70acf6faa58e..23d073419c20 100644 --- a/tests/lib/libprop/t_basic.c +++ b/tests/lib/libprop/t_basic.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_basic.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */ +/* $NetBSD: t_basic.c,v 1.3 2011/04/06 17:41:27 jruoho Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_basic.c,v 1.2 2010/11/03 16:10:22 christos Exp $"); +__RCSID("$NetBSD: t_basic.c,v 1.3 2011/04/06 17:41:27 jruoho Exp $"); #include #include @@ -79,12 +79,13 @@ static const char compare1[] = "\n" "\n"; -ATF_TC(simple); -ATF_TC_HEAD(simple, tc) +ATF_TC(prop_basic); +ATF_TC_HEAD(prop_basic, tc) { - atf_tc_set_md_var(tc, "descr", "Checks basic functionality of proplib"); + atf_tc_set_md_var(tc, "descr", "A basic test of proplib(3)"); } -ATF_TC_BODY(simple, tc) + +ATF_TC_BODY(prop_basic, tc) { prop_dictionary_t dict; char *ext1; @@ -160,10 +161,38 @@ ATF_TC_BODY(simple, tc) free(ext1); } +ATF_TC(prop_dictionary_equals); +ATF_TC_HEAD(prop_dictionary_equals, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test prop_dictionary_equals(3)"); +} + +ATF_TC_BODY(prop_dictionary_equals, tc) +{ + prop_dictionary_t c, d; + + atf_tc_expect_death("PR lib/43964"); + + d = prop_dictionary_internalize(compare1); + + ATF_REQUIRE(d != NULL); + + c = prop_dictionary_copy(d); + + ATF_REQUIRE(c != NULL); + + if (prop_dictionary_equals(c, d) != true) + atf_tc_fail("dictionaries are not equal"); + + prop_object_release(c); + prop_object_release(d); +} + ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, simple); + ATF_TP_ADD_TC(tp, prop_basic); + ATF_TP_ADD_TC(tp, prop_dictionary_equals); return atf_no_error(); }