Module Name:    src
Committed By:   pooka
Date:           Sat Feb 19 13:19:53 UTC 2011

Modified Files:
        src/tests/lib/librumphijack: Makefile
Added Files:
        src/tests/lib/librumphijack: h_cwd.c t_cwd.sh

Log Message:
a basic getcwd() test


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/librumphijack/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/librumphijack/h_cwd.c \
    src/tests/lib/librumphijack/t_cwd.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/librumphijack/Makefile
diff -u src/tests/lib/librumphijack/Makefile:1.3 src/tests/lib/librumphijack/Makefile:1.4
--- src/tests/lib/librumphijack/Makefile:1.3	Mon Feb 14 15:14:00 2011
+++ src/tests/lib/librumphijack/Makefile	Sat Feb 19 13:19:52 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2011/02/14 15:14:00 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2011/02/19 13:19:52 pooka Exp $
 #
 
 .include <bsd.own.mk>
@@ -6,9 +6,11 @@
 TESTSDIR=	${TESTSBASE}/lib/librumphijack
 
 TESTS_SH=	t_asyncio
+TESTS_SH+=	t_cwd
 TESTS_SH+=	t_tcpip
 TESTS_C=	h_client
 TESTS_C+=	h_netget
+TESTS_C+=	h_cwd
 
 FILES=		netstat.expout index.html
 FILESDIR=	${TESTSDIR}

Added files:

Index: src/tests/lib/librumphijack/h_cwd.c
diff -u /dev/null src/tests/lib/librumphijack/h_cwd.c:1.1
--- /dev/null	Sat Feb 19 13:19:53 2011
+++ src/tests/lib/librumphijack/h_cwd.c	Sat Feb 19 13:19:52 2011
@@ -0,0 +1,90 @@
+/*      $NetBSD: h_cwd.c,v 1.1 2011/02/19 13:19:52 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <err.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+	char pwd[1024];
+
+	if (chdir("/rump") == -1)
+		err(1, "chdir1");
+	if (getcwd(pwd, sizeof(pwd)) == NULL)
+		err(1, "getcwd1");
+	if (strcmp(pwd, "/rump") != 0)
+		errx(1, "strcmp1");
+
+	if (mkdir("dir", 0777) == -1)
+		err(1, "mkdir2");
+	if (chdir("dir") == -1)
+		err(1, "chdir2");
+	if (getcwd(pwd, sizeof(pwd)) == NULL)
+		err(1, "getcwd2");
+	if (strcmp(pwd, "/rump/dir") != 0)
+		errx(1, "strcmp2");
+
+	if (mkdir("dir", 0777) == -1)
+		err(1, "mkdir3");
+	if (chdir("dir") == -1)
+		err(1, "chdir3");
+	if (getcwd(pwd, sizeof(pwd)) == NULL)
+		err(1, "getcwd3");
+	if (strcmp(pwd, "/rump/dir/dir") != 0)
+		errx(1, "strcmp3");
+
+	if (chdir("..") == -1)
+		err(1, "chdir4");
+	if (getcwd(pwd, sizeof(pwd)) == NULL)
+		err(1, "getcwd4");
+	if (strcmp(pwd, "/rump/dir") != 0)
+		errx(1, "strcmp4");
+
+	if (chdir("../../../../../../..") == -1)
+		err(1, "chdir5");
+	if (getcwd(pwd, sizeof(pwd)) == NULL)
+		err(1, "getcwd5");
+	if (strcmp(pwd, "/rump") != 0)
+		errx(1, "strcmp5");
+
+	if (chdir("/") == -1)
+		err(1, "chdir6");
+	if (getcwd(pwd, sizeof(pwd)) == NULL)
+		err(1, "getcwd6");
+	if (strcmp(pwd, "/") != 0)
+		errx(1, "strcmp6");
+
+	return 0;
+}
Index: src/tests/lib/librumphijack/t_cwd.sh
diff -u /dev/null src/tests/lib/librumphijack/t_cwd.sh:1.1
--- /dev/null	Sat Feb 19 13:19:53 2011
+++ src/tests/lib/librumphijack/t_cwd.sh	Sat Feb 19 13:19:52 2011
@@ -0,0 +1,53 @@
+#       $NetBSD: t_cwd.sh,v 1.1 2011/02/19 13:19:52 pooka Exp $
+#
+# Copyright (c) 2011 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+rumpsrv='rump_server -lrumpvfs'
+export RUMP_SERVER=unix://csock
+
+atf_test_case basic cleanup
+basic_head()
+{
+        atf_set "descr" "basic cwd test"
+}
+
+basic_body()
+{
+
+	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
+	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+	    $(atf_get_srcdir)/h_cwd
+}
+
+basic_cleanup()
+{
+	rump.halt
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case basic
+}

Reply via email to