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 tests for putenv(3)
details: https://anonhg.NetBSD.org/src/rev/f4c37a80b6fc
branches: trunk
changeset: 757879:f4c37a80b6fc
user: christos <christos%NetBSD.org@localhost>
date: Fri Oct 01 20:12:20 2010 +0000
description:
Add tests for putenv(3)
diffstat:
tests/lib/libc/stdlib/t_environment.c | 36 +++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 6 deletions(-)
diffs (71 lines):
diff -r f77cc11dc626 -r f4c37a80b6fc tests/lib/libc/stdlib/t_environment.c
--- a/tests/lib/libc/stdlib/t_environment.c Fri Oct 01 20:11:32 2010 +0000
+++ b/tests/lib/libc/stdlib/t_environment.c Fri Oct 01 20:12:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_environment.c,v 1.1 2010/09/23 17:38:08 christos Exp $ */
+/* $NetBSD: t_environment.c,v 1.2 2010/10/01 20:12:20 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -32,22 +32,29 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_environment.c,v 1.1 2010/09/23 17:38:08 christos Exp $");
+__RCSID("$NetBSD: t_environment.c,v 1.2 2010/10/01 20:12:20 christos Exp $");
#include <atf-c.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-ATF_TC(t_environment);
+ATF_TC(t_setenv);
+ATF_TC(t_putenv);
-ATF_TC_HEAD(t_environment, tc)
+ATF_TC_HEAD(t_setenv, tc)
{
atf_tc_set_md_var(tc, "descr",
"Test setenv(3), getenv(3), unsetenv(3)");
}
-ATF_TC_BODY(t_environment, tc)
+ATF_TC_HEAD(t_putenv, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test putenv(3), getenv(3), unsetenv(3)");
+}
+
+ATF_TC_BODY(t_setenv, tc)
{
size_t i;
char name[1024];
@@ -66,9 +73,26 @@
}
}
+ATF_TC_BODY(t_putenv, tc)
+{
+ char string[1024];
+
+ snprintf(string, sizeof(string), "crap=true");
+ ATF_CHECK(putenv(string) != -1);
+ ATF_CHECK_STREQ(getenv("crap"), "true");
+ string[1] = 'l';
+ ATF_CHECK_STREQ(getenv("clap"), "true");
+ ATF_CHECK(getenv("crap") == NULL);
+ string[1] = 'r';
+ unsetenv("crap");
+ ATF_CHECK(getenv("crap") == NULL);
+
+}
+
ATF_TP_ADD_TCS(tp)
{
- ATF_TP_ADD_TC(tp, t_environment);
+ ATF_TP_ADD_TC(tp, t_setenv);
+ ATF_TP_ADD_TC(tp, t_putenv);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index