Source-Changes-HG archive

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

[src/trunk]: src/tests/lib Add some tests for librefuse



details:   https://anonhg.NetBSD.org/src/rev/e27d7122b12a
branches:  trunk
changeset: 348896:e27d7122b12a
user:      pho <pho%NetBSD.org@localhost>
date:      Mon Nov 14 16:10:31 2016 +0000

description:
Add some tests for librefuse

diffstat:

 tests/lib/Makefile                 |    4 +-
 tests/lib/librefuse/Makefile       |   14 ++++
 tests/lib/librefuse/t_refuse_opt.c |  104 +++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 2 deletions(-)

diffs (141 lines):

diff -r a07cb62d3ae9 -r e27d7122b12a tests/lib/Makefile
--- a/tests/lib/Makefile        Mon Nov 14 10:40:59 2016 +0000
+++ b/tests/lib/Makefile        Mon Nov 14 16:10:31 2016 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.25 2016/01/01 21:38:54 jakllsch Exp $
+# $NetBSD: Makefile,v 1.26 2016/11/14 16:10:31 pho Exp $
 
 .include <bsd.own.mk>
 
 TESTS_SUBDIRS= csu libbluetooth libc libcrypt libcurses libevent libexecinfo \
-               libm libobjc libposix libppath libprop libpthread \
+               libm libobjc libposix libppath libprop libpthread librefuse \
                librt libtre libusbhid libutil semaphore
 
 .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
diff -r a07cb62d3ae9 -r e27d7122b12a tests/lib/librefuse/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/librefuse/Makefile      Mon Nov 14 16:10:31 2016 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2016/11/14 16:10:31 pho Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/lib/librefuse
+
+DPADD+=                ${LIBREFUSE}
+LDADD+=                -lrefuse
+
+TESTS_C=       t_refuse_opt
+
+.include <bsd.test.mk>
diff -r a07cb62d3ae9 -r e27d7122b12a tests/lib/librefuse/t_refuse_opt.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/librefuse/t_refuse_opt.c        Mon Nov 14 16:10:31 2016 +0000
@@ -0,0 +1,104 @@
+/*     $NetBSD: t_refuse_opt.c,v 1.1 2016/11/14 16:10:31 pho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * 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/cdefs.h>
+__RCSID("$NetBSD: t_refuse_opt.c,v 1.1 2016/11/14 16:10:31 pho Exp $");
+
+#include <atf-c.h>
+
+#include <fuse.h>
+
+#include "../../h_macros.h"
+
+ATF_TC(efuse_opt_add_arg);
+ATF_TC_HEAD(efuse_opt_add_arg, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_arg(3) works");
+}
+
+ATF_TC_BODY(efuse_opt_add_arg, tc)
+{
+       struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+
+       RZ(fuse_opt_add_arg(&args, "foo"));
+       RZ(fuse_opt_add_arg(&args, "bar"));
+
+       ATF_REQUIRE_EQ(args.argc, 2);
+       ATF_CHECK_STREQ(args.argv[0], "foo");
+       ATF_CHECK_STREQ(args.argv[1], "bar");
+       ATF_CHECK(args.allocated != 0);
+}
+
+ATF_TC(efuse_opt_insert_arg);
+ATF_TC_HEAD(efuse_opt_insert_arg, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_insert_arg(3) works");
+}
+
+ATF_TC_BODY(efuse_opt_insert_arg, tc)
+{
+       struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+
+       RZ(fuse_opt_insert_arg(&args, 0, "foo"));
+       RZ(fuse_opt_insert_arg(&args, 0, "bar"));
+
+       ATF_REQUIRE_EQ(args.argc, 2);
+       ATF_CHECK_STREQ(args.argv[0], "bar");
+       ATF_CHECK_STREQ(args.argv[1], "foo");
+       ATF_CHECK(args.allocated != 0);
+}
+
+ATF_TC(efuse_opt_add_opt);
+ATF_TC_HEAD(efuse_opt_add_opt, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_opt(3) works");
+}
+
+ATF_TC_BODY(efuse_opt_add_opt, tc)
+{
+       char* opt = NULL;
+
+       atf_tc_expect_death("fuse_opt_add_opt(3) is not implemented yet");
+
+       RZ(fuse_opt_add_opt(&opt, "foo"));
+       ATF_CHECK_STREQ(opt, "foo");
+
+       RZ(fuse_opt_add_opt(&opt, "b\\a,r"));
+       ATF_CHECK_STREQ(opt, "foo,b\\a,r");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+       ATF_TP_ADD_TC(tp, efuse_opt_add_arg);
+       ATF_TP_ADD_TC(tp, efuse_opt_insert_arg);
+       ATF_TP_ADD_TC(tp, efuse_opt_add_opt);
+
+       return atf_no_error();
+}



Home | Main Index | Thread Index | Old Index