Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/stdlib Add a test for getenv(3) which fails a...



details:   https://anonhg.NetBSD.org/src/rev/5ed2b39b0a89
branches:  trunk
changeset: 758715:5ed2b39b0a89
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Nov 13 21:08:36 2010 +0000

description:
Add a test for getenv(3) which fails at the moment because it doesn't
handle "=" in variable names properly.

I'll send out a diff for review soon which fixes this.

diffstat:

 tests/lib/libc/stdlib/t_environment.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (65 lines):

diff -r 8e915b4b80b6 -r 5ed2b39b0a89 tests/lib/libc/stdlib/t_environment.c
--- a/tests/lib/libc/stdlib/t_environment.c     Sat Nov 13 19:43:56 2010 +0000
+++ b/tests/lib/libc/stdlib/t_environment.c     Sat Nov 13 21:08:36 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_environment.c,v 1.8 2010/11/13 18:52:55 tron Exp $   */
+/*     $NetBSD: t_environment.c,v 1.9 2010/11/13 21:08:36 tron Exp $   */
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_environment.c,v 1.8 2010/11/13 18:52:55 tron Exp $");
+__RCSID("$NetBSD: t_environment.c,v 1.9 2010/11/13 21:08:36 tron Exp $");
 
 #include <atf-c.h>
 #include <errno.h>
@@ -44,6 +44,7 @@
 ATF_TC(t_putenv);
 ATF_TC(t_clearenv);
 ATF_TC(t_mixed);
+ATF_TC(t_getenv);
 
 ATF_TC_HEAD(t_setenv, tc)
 {
@@ -70,6 +71,12 @@
            "Test mixing setenv(3), unsetenv(3) and putenv(3)");
 }
 
+ATF_TC_HEAD(t_getenv, tc)
+{
+       atf_tc_set_md_var(tc, "descr",
+           "Test setenv(3), getenv(3)");
+}
+
 ATF_TC_BODY(t_setenv, tc)
 {
        size_t i;
@@ -163,12 +170,25 @@
        ATF_CHECK(getenv("mixedcrap") == NULL);
 }
 
+ATF_TC_BODY(t_getenv, tc)
+{
+       ATF_CHECK(setenv("EVIL", "very=bad", 1) != -1);
+       ATF_CHECK_STREQ(getenv("EVIL"), "very=bad");
+
+       atf_tc_expect_fail("getenv(3) doesn't check variable names properly");
+       ATF_CHECK(getenv("EVIL=very") == NULL);
+
+       atf_tc_expect_pass();
+       ATF_CHECK(unsetenv("EVIL") != -1);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
        ATF_TP_ADD_TC(tp, t_setenv);
        ATF_TP_ADD_TC(tp, t_putenv);
        ATF_TP_ADD_TC(tp, t_clearenv);
        ATF_TP_ADD_TC(tp, t_mixed);
+       ATF_TP_ADD_TC(tp, t_getenv);
 
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index