Index: head/etc/mtree/BSD.tests.dist =================================================================== --- head/etc/mtree/BSD.tests.dist (revision 269602) +++ head/etc/mtree/BSD.tests.dist (revision 269603) @@ -1,284 +1,286 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . include atf-c .. atf-c++ .. .. share atf .. doc atf .. .. .. tests bin chown .. date .. mv .. pax .. pkill .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. test .. .. cddl lib .. sbin .. usr.bin .. usr.sbin .. .. etc .. games .. gnu lib .. usr.bin .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libcrypt .. libmp .. + libnv + .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. growfs .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys kern .. netinet .. .. usr.bin apply .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. calendar .. comm .. file2c .. join .. jot .. lastcomm .. m4 .. ncal .. printf .. sed regress.multitest.out .. .. tr .. truncate .. units .. uudecode .. uuencode .. xargs .. yacc yacc .. .. .. usr.sbin etcupdate .. newsyslog .. sa .. .. .. .. Index: head/lib/libnv/Makefile =================================================================== --- head/lib/libnv/Makefile (revision 269602) +++ head/lib/libnv/Makefile (revision 269603) @@ -1,161 +1,167 @@ # $FreeBSD$ +.include + LIB= nv SHLIBDIR?= /lib SHLIB_MAJOR= 0 SRCS= dnvlist.c SRCS+= msgio.c SRCS+= nvlist.c SRCS+= nvpair.c INCS= dnv.h INCS+= nv.h MAN+= nv.3 MLINKS+=nv.3 libnv.3 \ nv.3 nvlist.3 MLINKS+=nv.3 nvlist_create.3 \ nv.3 nvlist_destroy.3 \ nv.3 nvlist_error.3 \ nv.3 nvlist_empty.3 \ nv.3 nvlist_clone.3 \ nv.3 nvlist_dump.3 \ nv.3 nvlist_fdump.3 \ nv.3 nvlist_size.3 \ nv.3 nvlist_pack.3 \ nv.3 nvlist_unpack.3 \ nv.3 nvlist_send.3 \ nv.3 nvlist_recv.3 \ nv.3 nvlist_xfer.3 \ nv.3 nvlist_next.3 \ nv.3 nvlist_exists.3 \ nv.3 nvlist_exists_type.3 \ nv.3 nvlist_exists_null.3 \ nv.3 nvlist_exists_bool.3 \ nv.3 nvlist_exists_number.3 \ nv.3 nvlist_exists_string.3 \ nv.3 nvlist_exists_nvlist.3 \ nv.3 nvlist_exists_descriptor.3 \ nv.3 nvlist_exists_binary.3 \ nv.3 nvlist_add_null.3 \ nv.3 nvlist_add_bool.3 \ nv.3 nvlist_add_number.3 \ nv.3 nvlist_add_string.3 \ nv.3 nvlist_add_stringf.3 \ nv.3 nvlist_add_stringv.3 \ nv.3 nvlist_add_nvlist.3 \ nv.3 nvlist_add_descriptor.3 \ nv.3 nvlist_add_binary.3 \ nv.3 nvlist_move_string.3 \ nv.3 nvlist_move_nvlist.3 \ nv.3 nvlist_move_descriptor.3 \ nv.3 nvlist_move_binary.3 \ nv.3 nvlist_get_bool.3 \ nv.3 nvlist_get_number.3 \ nv.3 nvlist_get_string.3 \ nv.3 nvlist_get_nvlist.3 \ nv.3 nvlist_get_descriptor.3 \ nv.3 nvlist_get_binary.3 \ nv.3 nvlist_take_bool.3 \ nv.3 nvlist_take_number.3 \ nv.3 nvlist_take_string.3 \ nv.3 nvlist_take_nvlist.3 \ nv.3 nvlist_take_descriptor.3 \ nv.3 nvlist_take_binary.3 \ nv.3 nvlist_free.3 \ nv.3 nvlist_free_type.3 \ nv.3 nvlist_free_null.3 \ nv.3 nvlist_free_bool.3 \ nv.3 nvlist_free_number.3 \ nv.3 nvlist_free_string.3 \ nv.3 nvlist_free_nvlist.3 \ nv.3 nvlist_free_descriptor.3 \ nv.3 nvlist_free_binary.3 MLINKS+=nv.3 nvlist_existsf.3 \ nv.3 nvlist_existsf_type.3 \ nv.3 nvlist_existsf_null.3 \ nv.3 nvlist_existsf_bool.3 \ nv.3 nvlist_existsf_number.3 \ nv.3 nvlist_existsf_string.3 \ nv.3 nvlist_existsf_nvlist.3 \ nv.3 nvlist_existsf_descriptor.3 \ nv.3 nvlist_existsf_binary.3 \ nv.3 nvlist_addf_null.3 \ nv.3 nvlist_addf_bool.3 \ nv.3 nvlist_addf_number.3 \ nv.3 nvlist_addf_string.3 \ nv.3 nvlist_addf_nvlist.3 \ nv.3 nvlist_addf_descriptor.3 \ nv.3 nvlist_addf_binary.3 \ nv.3 nvlist_movef_string.3 \ nv.3 nvlist_movef_nvlist.3 \ nv.3 nvlist_movef_descriptor.3 \ nv.3 nvlist_movef_binary.3 \ nv.3 nvlist_getf_bool.3 \ nv.3 nvlist_getf_number.3 \ nv.3 nvlist_getf_string.3 \ nv.3 nvlist_getf_nvlist.3 \ nv.3 nvlist_getf_descriptor.3 \ nv.3 nvlist_getf_binary.3 \ nv.3 nvlist_takef_bool.3 \ nv.3 nvlist_takef_number.3 \ nv.3 nvlist_takef_string.3 \ nv.3 nvlist_takef_nvlist.3 \ nv.3 nvlist_takef_descriptor.3 \ nv.3 nvlist_takef_binary.3 \ nv.3 nvlist_freef.3 \ nv.3 nvlist_freef_type.3 \ nv.3 nvlist_freef_null.3 \ nv.3 nvlist_freef_bool.3 \ nv.3 nvlist_freef_number.3 \ nv.3 nvlist_freef_string.3 \ nv.3 nvlist_freef_nvlist.3 \ nv.3 nvlist_freef_descriptor.3 \ nv.3 nvlist_freef_binary.3 MLINKS+=nv.3 nvlist_existsv.3 \ nv.3 nvlist_existsv_type.3 \ nv.3 nvlist_existsv_null.3 \ nv.3 nvlist_existsv_bool.3 \ nv.3 nvlist_existsv_number.3 \ nv.3 nvlist_existsv_string.3 \ nv.3 nvlist_existsv_nvlist.3 \ nv.3 nvlist_existsv_descriptor.3 \ nv.3 nvlist_existsv_binary.3 \ nv.3 nvlist_addv_null.3 \ nv.3 nvlist_addv_bool.3 \ nv.3 nvlist_addv_number.3 \ nv.3 nvlist_addv_string.3 \ nv.3 nvlist_addv_nvlist.3 \ nv.3 nvlist_addv_descriptor.3 \ nv.3 nvlist_addv_binary.3 \ nv.3 nvlist_movev_string.3 \ nv.3 nvlist_movev_nvlist.3 \ nv.3 nvlist_movev_descriptor.3 \ nv.3 nvlist_movev_binary.3 \ nv.3 nvlist_getv_bool.3 \ nv.3 nvlist_getv_number.3 \ nv.3 nvlist_getv_string.3 \ nv.3 nvlist_getv_nvlist.3 \ nv.3 nvlist_getv_descriptor.3 \ nv.3 nvlist_getv_binary.3 \ nv.3 nvlist_takev_bool.3 \ nv.3 nvlist_takev_number.3 \ nv.3 nvlist_takev_string.3 \ nv.3 nvlist_takev_nvlist.3 \ nv.3 nvlist_takev_descriptor.3 \ nv.3 nvlist_takev_binary.3 \ nv.3 nvlist_freef.3 \ nv.3 nvlist_freev_type.3 \ nv.3 nvlist_freev_null.3 \ nv.3 nvlist_freev_bool.3 \ nv.3 nvlist_freev_number.3 \ nv.3 nvlist_freev_string.3 \ nv.3 nvlist_freev_nvlist.3 \ nv.3 nvlist_freev_descriptor.3 \ nv.3 nvlist_freev_binary.3 WARNS?= 6 + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Index: head/lib/libnv/tests/Makefile =================================================================== --- head/lib/libnv/tests/Makefile (nonexistent) +++ head/lib/libnv/tests/Makefile (revision 269603) @@ -0,0 +1,17 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/lib/libnv + +TAP_TESTS_C+= nvlist_add_test +TAP_TESTS_C+= nvlist_exists_test +TAP_TESTS_C+= nvlist_free_test +TAP_TESTS_C+= nvlist_get_test +TAP_TESTS_C+= nvlist_move_test +TAP_TESTS_C+= nvlist_send_recv_test + +DPADD+= ${LIBNV} +LDADD+= -lnv + +WARNS?= 6 + +.include Property changes on: head/lib/libnv/tests/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libnv/tests/nvlist_add_test.c =================================================================== --- head/lib/libnv/tests/nvlist_add_test.c (nonexistent) +++ head/lib/libnv/tests/nvlist_add_test.c (revision 269603) @@ -0,0 +1,196 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +int +main(void) +{ + const nvlist_t *cnvl; + nvlist_t *nvl; + + printf("1..94\n"); + + nvl = nvlist_create(0); + + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + nvlist_add_null(nvl, "nvlist/null"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_null(nvl, "nvlist/null")); + + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/true")); + nvlist_add_bool(nvl, "nvlist/bool/true", true); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool/true")); + + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/false")); + nvlist_add_bool(nvl, "nvlist/bool/false", false); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool/false")); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/0")); + nvlist_add_number(nvl, "nvlist/number/0", 0); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_number(nvl, "nvlist/number/0")); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/1")); + nvlist_add_number(nvl, "nvlist/number/1", 1); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_number(nvl, "nvlist/number/1")); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/-1")); + nvlist_add_number(nvl, "nvlist/number/-1", -1); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_number(nvl, "nvlist/number/-1")); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); + nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); + nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); + nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/")); + nvlist_add_string(nvl, "nvlist/string/", ""); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/string/")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/x")); + nvlist_add_string(nvl, "nvlist/string/x", "x"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/")); + nvlist_add_stringf(nvl, "nvlist/stringf/", "%s", ""); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/stringf/")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/x")); + nvlist_add_stringf(nvl, "nvlist/stringf/x", "%s", "x"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/stringf/x")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/666Xabc")); + nvlist_add_stringf(nvl, "nvlist/stringf/666Xabc", "%d%c%s", 666, 'X', "abc"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/stringf/666Xabc")); + + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x")); + nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); + + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + + CHECK(nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool/true")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool/false")); + CHECK(nvlist_exists_number(nvl, "nvlist/number/0")); + CHECK(nvlist_exists_number(nvl, "nvlist/number/1")); + CHECK(nvlist_exists_number(nvl, "nvlist/number/-1")); + CHECK(nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); + CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); + CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); + CHECK(nvlist_exists_string(nvl, "nvlist/string/")); + CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); + CHECK(nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_exists_string(nvl, "nvlist/stringf/")); + CHECK(nvlist_exists_string(nvl, "nvlist/stringf/x")); + CHECK(nvlist_exists_string(nvl, "nvlist/stringf/666Xabc")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + + cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist"); + CHECK(nvlist_exists_null(cnvl, "nvlist/null")); + CHECK(nvlist_exists_bool(cnvl, "nvlist/bool/true")); + CHECK(nvlist_exists_bool(cnvl, "nvlist/bool/false")); + CHECK(nvlist_exists_number(cnvl, "nvlist/number/0")); + CHECK(nvlist_exists_number(cnvl, "nvlist/number/1")); + CHECK(nvlist_exists_number(cnvl, "nvlist/number/-1")); + CHECK(nvlist_exists_number(cnvl, "nvlist/number/UINT64_MAX")); + CHECK(nvlist_exists_number(cnvl, "nvlist/number/INT64_MIN")); + CHECK(nvlist_exists_number(cnvl, "nvlist/number/INT64_MAX")); + CHECK(nvlist_exists_string(cnvl, "nvlist/string/")); + CHECK(nvlist_exists_string(cnvl, "nvlist/string/x")); + CHECK(nvlist_exists_string(cnvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/")); + CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/x")); + CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/666Xabc")); + CHECK(nvlist_exists_descriptor(cnvl, "nvlist/descriptor/STDERR_FILENO")); + CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/x")); + CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + + nvlist_destroy(nvl); + + return (0); +} Property changes on: head/lib/libnv/tests/nvlist_add_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libnv/tests/nvlist_exists_test.c =================================================================== --- head/lib/libnv/tests/nvlist_exists_test.c (nonexistent) +++ head/lib/libnv/tests/nvlist_exists_test.c (revision 269603) @@ -0,0 +1,321 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include + +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +int +main(void) +{ + nvlist_t *nvl; + + printf("1..232\n"); + + nvl = nvlist_create(0); + + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/null")); + CHECK(!nvlist_exists_number(nvl, "nvlist/null")); + CHECK(!nvlist_exists_string(nvl, "nvlist/null")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/null")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/null")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/null")); + nvlist_add_null(nvl, "nvlist/null"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/null")); + CHECK(nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/null")); + CHECK(!nvlist_exists_number(nvl, "nvlist/null")); + CHECK(!nvlist_exists_string(nvl, "nvlist/null")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/null")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/null")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/null")); + + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_null(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_string(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/bool")); + nvlist_add_bool(nvl, "nvlist/bool", true); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_null(nvl, "nvlist/bool")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_string(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/bool")); + + CHECK(!nvlist_exists(nvl, "nvlist/number")); + CHECK(!nvlist_exists_null(nvl, "nvlist/number")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/number")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/number")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/number")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/number")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/number")); + nvlist_add_number(nvl, "nvlist/number", 0); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/number")); + CHECK(!nvlist_exists_null(nvl, "nvlist/number")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/number")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/number")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/number")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/number")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/number")); + + CHECK(!nvlist_exists(nvl, "nvlist/string")); + CHECK(!nvlist_exists_null(nvl, "nvlist/string")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/string")); + CHECK(!nvlist_exists_number(nvl, "nvlist/string")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/string")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/string")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/string")); + nvlist_add_string(nvl, "nvlist/string", "test"); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/string")); + CHECK(!nvlist_exists_null(nvl, "nvlist/string")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/string")); + CHECK(!nvlist_exists_number(nvl, "nvlist/string")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/string")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/string")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/string")); + + CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_null(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_number(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_string(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/nvlist")); + nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_null(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_number(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_string(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/nvlist")); + + CHECK(!nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_null(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_number(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_string(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/descriptor")); + nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_null(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_number(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_string(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/descriptor")); + + CHECK(!nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_number(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_string(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); + nvlist_add_binary(nvl, "nvlist/binary", "test", 4); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_number(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_string(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/binary")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + CHECK(nvlist_exists(nvl, "nvlist/null")); + CHECK(nvlist_exists(nvl, "nvlist/bool")); + CHECK(nvlist_exists(nvl, "nvlist/number")); + CHECK(nvlist_exists(nvl, "nvlist/string")); + CHECK(nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_null(nvl, "nvlist/null"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(nvlist_exists(nvl, "nvlist/bool")); + CHECK(nvlist_exists(nvl, "nvlist/number")); + CHECK(nvlist_exists(nvl, "nvlist/string")); + CHECK(nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_bool(nvl, "nvlist/bool"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(nvlist_exists(nvl, "nvlist/number")); + CHECK(nvlist_exists(nvl, "nvlist/string")); + CHECK(nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_number(nvl, "nvlist/number"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists(nvl, "nvlist/number")); + CHECK(nvlist_exists(nvl, "nvlist/string")); + CHECK(nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_string(nvl, "nvlist/string"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists(nvl, "nvlist/number")); + CHECK(!nvlist_exists(nvl, "nvlist/string")); + CHECK(nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_nvlist(nvl, "nvlist/nvlist"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists(nvl, "nvlist/number")); + CHECK(!nvlist_exists(nvl, "nvlist/string")); + CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_descriptor(nvl, "nvlist/descriptor"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists(nvl, "nvlist/number")); + CHECK(!nvlist_exists(nvl, "nvlist/string")); + CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_binary(nvl, "nvlist/binary"); + CHECK(!nvlist_exists(nvl, "nvlist/null")); + CHECK(!nvlist_exists(nvl, "nvlist/bool")); + CHECK(!nvlist_exists(nvl, "nvlist/number")); + CHECK(!nvlist_exists(nvl, "nvlist/string")); + CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists(nvl, "nvlist/binary")); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); + + CHECK(nvlist_empty(nvl)); + + nvlist_destroy(nvl); + + return (0); +} Property changes on: head/lib/libnv/tests/nvlist_exists_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libnv/tests/nvlist_free_test.c =================================================================== --- head/lib/libnv/tests/nvlist_free_test.c (nonexistent) +++ head/lib/libnv/tests/nvlist_free_test.c (revision 269603) @@ -0,0 +1,221 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include + +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +int +main(void) +{ + nvlist_t *nvl; + + printf("1..114\n"); + + nvl = nvlist_create(0); + + nvlist_add_null(nvl, "nvlist/null"); + nvlist_add_bool(nvl, "nvlist/bool", true); + nvlist_add_number(nvl, "nvlist/number", 0); + nvlist_add_string(nvl, "nvlist/string", "test"); + nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); + nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO); + nvlist_add_binary(nvl, "nvlist/binary", "test", 4); + + CHECK(nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_null(nvl, "nvlist/null"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_bool(nvl, "nvlist/bool"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_number(nvl, "nvlist/number"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_string(nvl, "nvlist/string"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_nvlist(nvl, "nvlist/nvlist"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_descriptor(nvl, "nvlist/descriptor"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free_binary(nvl, "nvlist/binary"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); + + CHECK(nvlist_empty(nvl)); + + nvlist_add_null(nvl, "nvlist/null"); + nvlist_add_bool(nvl, "nvlist/bool", true); + nvlist_add_number(nvl, "nvlist/number", 0); + nvlist_add_string(nvl, "nvlist/string", "test"); + nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); + nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO); + nvlist_add_binary(nvl, "nvlist/binary", "test", 4); + + CHECK(nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/null"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/bool"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/number"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/string"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/nvlist"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/descriptor"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); + + nvlist_free(nvl, "nvlist/binary"); + CHECK(!nvlist_exists_null(nvl, "nvlist/null")); + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); + CHECK(!nvlist_exists_number(nvl, "nvlist/number")); + CHECK(!nvlist_exists_string(nvl, "nvlist/string")); + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); + + CHECK(nvlist_empty(nvl)); + + nvlist_destroy(nvl); + + return (0); +} Property changes on: head/lib/libnv/tests/nvlist_free_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libnv/tests/nvlist_get_test.c =================================================================== --- head/lib/libnv/tests/nvlist_get_test.c (nonexistent) +++ head/lib/libnv/tests/nvlist_get_test.c (revision 269603) @@ -0,0 +1,182 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include + +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +#define fd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF) + +int +main(void) +{ + const nvlist_t *cnvl; + nvlist_t *nvl; + size_t size; + + printf("1..83\n"); + + nvl = nvlist_create(0); + + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/true")); + nvlist_add_bool(nvl, "nvlist/bool/true", true); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_get_bool(nvl, "nvlist/bool/true") == true); + + CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/false")); + nvlist_add_bool(nvl, "nvlist/bool/false", false); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_get_bool(nvl, "nvlist/bool/false") == false); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/0")); + nvlist_add_number(nvl, "nvlist/number/0", 0); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_get_number(nvl, "nvlist/number/0") == 0); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/1")); + nvlist_add_number(nvl, "nvlist/number/1", 1); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_get_number(nvl, "nvlist/number/1") == 1); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/-1")); + nvlist_add_number(nvl, "nvlist/number/-1", -1); + CHECK(nvlist_error(nvl) == 0); + CHECK((int)nvlist_get_number(nvl, "nvlist/number/-1") == -1); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); + nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_get_number(nvl, "nvlist/number/UINT64_MAX") == UINT64_MAX); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); + nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN); + CHECK(nvlist_error(nvl) == 0); + CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MIN") == INT64_MIN); + + CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); + nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX); + CHECK(nvlist_error(nvl) == 0); + CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MAX") == INT64_MAX); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/")); + nvlist_add_string(nvl, "nvlist/string/", ""); + CHECK(nvlist_error(nvl) == 0); + CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/"), "") == 0); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/x")); + nvlist_add_string(nvl, "nvlist/string/x", "x"); + CHECK(nvlist_error(nvl) == 0); + CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/x"), "x") == 0); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); + CHECK(nvlist_error(nvl) == 0); + CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0); + + CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO); + CHECK(nvlist_error(nvl) == 0); + CHECK(fd_is_valid(nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"))); + + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x")); + nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1); + CHECK(nvlist_error(nvl) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", NULL), "x", 1) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", &size), "x", 1) == 0); + CHECK(size == 1); + + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_error(nvl) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); + + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); + CHECK(nvlist_error(nvl) == 0); + cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist"); + CHECK(nvlist_get_bool(cnvl, "nvlist/bool/true") == true); + CHECK(nvlist_get_bool(cnvl, "nvlist/bool/false") == false); + CHECK(nvlist_get_number(cnvl, "nvlist/number/0") == 0); + CHECK(nvlist_get_number(cnvl, "nvlist/number/1") == 1); + CHECK((int)nvlist_get_number(cnvl, "nvlist/number/-1") == -1); + CHECK(nvlist_get_number(cnvl, "nvlist/number/UINT64_MAX") == UINT64_MAX); + CHECK((int64_t)nvlist_get_number(cnvl, "nvlist/number/INT64_MIN") == INT64_MIN); + CHECK((int64_t)nvlist_get_number(cnvl, "nvlist/number/INT64_MAX") == INT64_MAX); + CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/"), "") == 0); + CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/x"), "x") == 0); + CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0); + /* TODO */ + CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/x", NULL), "x", 1) == 0); + CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/x", &size), "x", 1) == 0); + CHECK(size == 1); + CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); + + CHECK(nvlist_get_bool(nvl, "nvlist/bool/true") == true); + CHECK(nvlist_get_bool(nvl, "nvlist/bool/false") == false); + CHECK(nvlist_get_number(nvl, "nvlist/number/0") == 0); + CHECK(nvlist_get_number(nvl, "nvlist/number/1") == 1); + CHECK((int)nvlist_get_number(nvl, "nvlist/number/-1") == -1); + CHECK(nvlist_get_number(nvl, "nvlist/number/UINT64_MAX") == UINT64_MAX); + CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MIN") == INT64_MIN); + CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MAX") == INT64_MAX); + CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/"), "") == 0); + CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/x"), "x") == 0); + CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0); + CHECK(fd_is_valid(nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"))); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", NULL), "x", 1) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", &size), "x", 1) == 0); + CHECK(size == 1); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); + + nvlist_destroy(nvl); + + return (0); +} Property changes on: head/lib/libnv/tests/nvlist_get_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libnv/tests/nvlist_move_test.c =================================================================== --- head/lib/libnv/tests/nvlist_move_test.c (nonexistent) +++ head/lib/libnv/tests/nvlist_move_test.c (revision 269603) @@ -0,0 +1,161 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include + +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +int +main(void) +{ + const nvlist_t *cnvl; + nvlist_t *nvl; + void *ptr; + size_t size; + int fd; + + printf("1..52\n"); + + nvl = nvlist_create(0); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/")); + ptr = strdup(""); + CHECK(ptr != NULL); + nvlist_move_string(nvl, "nvlist/string/", ptr); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/string/")); + CHECK(ptr == nvlist_get_string(nvl, "nvlist/string/")); + + CHECK(!nvlist_exists_string(nvl, "nvlist/string/x")); + ptr = strdup("x"); + CHECK(ptr != NULL); + nvlist_move_string(nvl, "nvlist/string/x", ptr); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); + CHECK(ptr == nvlist_get_string(nvl, "nvlist/string/x")); + + CHECK(!nvlist_exists_string(nvl, + "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + ptr = strdup("abcdefghijklmnopqrstuvwxyz"); + CHECK(ptr != NULL); + nvlist_move_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", + ptr); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_string(nvl, + "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + CHECK(ptr == + nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + + CHECK(!nvlist_exists_descriptor(nvl, + "nvlist/descriptor/STDERR_FILENO")); + fd = dup(STDERR_FILENO); + CHECK(fd >= 0); + nvlist_move_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", fd); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + CHECK(fd == + nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + + CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x")); + ptr = malloc(1); + CHECK(ptr != NULL); + memcpy(ptr, "x", 1); + nvlist_move_binary(nvl, "nvlist/binary/x", ptr, 1); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); + CHECK(ptr == nvlist_get_binary(nvl, "nvlist/binary/x", NULL)); + CHECK(ptr == nvlist_get_binary(nvl, "nvlist/binary/x", &size)); + CHECK(size == 1); + + CHECK(!nvlist_exists_binary(nvl, + "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + ptr = malloc(sizeof("abcdefghijklmnopqrstuvwxyz")); + CHECK(ptr != NULL); + memcpy(ptr, "abcdefghijklmnopqrstuvwxyz", + sizeof("abcdefghijklmnopqrstuvwxyz")); + nvlist_move_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", + ptr, sizeof("abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_binary(nvl, + "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + CHECK(ptr == nvlist_get_binary(nvl, + "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL)); + CHECK(ptr == nvlist_get_binary(nvl, + "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size)); + CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); + + CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + ptr = nvlist_clone(nvl); + CHECK(ptr != NULL); + nvlist_move_nvlist(nvl, "nvlist/nvlist", ptr); + CHECK(nvlist_error(nvl) == 0); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + CHECK(ptr == nvlist_get_nvlist(nvl, "nvlist/nvlist")); + + CHECK(nvlist_exists_string(nvl, "nvlist/string/")); + CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); + CHECK(nvlist_exists_string(nvl, + "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); + CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); + CHECK(nvlist_exists_binary(nvl, + "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); + + cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist"); + CHECK(nvlist_exists_string(cnvl, "nvlist/string/")); + CHECK(nvlist_exists_string(cnvl, "nvlist/string/x")); + CHECK(nvlist_exists_string(cnvl, + "nvlist/string/abcdefghijklmnopqrstuvwxyz")); + CHECK(nvlist_exists_descriptor(cnvl, + "nvlist/descriptor/STDERR_FILENO")); + CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/x")); + CHECK(nvlist_exists_binary(cnvl, + "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); + + nvlist_destroy(nvl); + + return (0); +} Property changes on: head/lib/libnv/tests/nvlist_move_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libnv/tests/nvlist_send_recv_test.c =================================================================== --- head/lib/libnv/tests/nvlist_send_recv_test.c (nonexistent) +++ head/lib/libnv/tests/nvlist_send_recv_test.c (revision 269603) @@ -0,0 +1,325 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +#define fd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF) + +static void +child(int sock) +{ + nvlist_t *nvl; + + nvl = nvlist_create(0); + + nvlist_add_bool(nvl, "nvlist/bool/true", true); + nvlist_add_bool(nvl, "nvlist/bool/false", false); + nvlist_add_number(nvl, "nvlist/number/0", 0); + nvlist_add_number(nvl, "nvlist/number/1", 1); + nvlist_add_number(nvl, "nvlist/number/-1", -1); + nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX); + nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN); + nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX); + nvlist_add_string(nvl, "nvlist/string/", ""); + nvlist_add_string(nvl, "nvlist/string/x", "x"); + nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); + nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO); + nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1); + nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")); + nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); + + nvlist_send(sock, nvl); + + nvlist_destroy(nvl); +} + +static void +parent(int sock) +{ + nvlist_t *nvl; + const nvlist_t *cnvl; + const char *name, *cname; + void *cookie, *ccookie; + int type, ctype; + size_t size; + + nvl = nvlist_recv(sock); + CHECK(nvlist_error(nvl) == 0); + if (nvlist_error(nvl) != 0) + err(1, "nvlist_recv() failed"); + + cookie = NULL; + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_BOOL); + CHECK(strcmp(name, "nvlist/bool/true") == 0); + CHECK(nvlist_get_bool(nvl, name) == true); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_BOOL); + CHECK(strcmp(name, "nvlist/bool/false") == 0); + CHECK(nvlist_get_bool(nvl, name) == false); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NUMBER); + CHECK(strcmp(name, "nvlist/number/0") == 0); + CHECK(nvlist_get_number(nvl, name) == 0); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NUMBER); + CHECK(strcmp(name, "nvlist/number/1") == 0); + CHECK(nvlist_get_number(nvl, name) == 1); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NUMBER); + CHECK(strcmp(name, "nvlist/number/-1") == 0); + CHECK((int)nvlist_get_number(nvl, name) == -1); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NUMBER); + CHECK(strcmp(name, "nvlist/number/UINT64_MAX") == 0); + CHECK(nvlist_get_number(nvl, name) == UINT64_MAX); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NUMBER); + CHECK(strcmp(name, "nvlist/number/INT64_MIN") == 0); + CHECK((int64_t)nvlist_get_number(nvl, name) == INT64_MIN); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NUMBER); + CHECK(strcmp(name, "nvlist/number/INT64_MAX") == 0); + CHECK((int64_t)nvlist_get_number(nvl, name) == INT64_MAX); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_STRING); + CHECK(strcmp(name, "nvlist/string/") == 0); + CHECK(strcmp(nvlist_get_string(nvl, name), "") == 0); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_STRING); + CHECK(strcmp(name, "nvlist/string/x") == 0); + CHECK(strcmp(nvlist_get_string(nvl, name), "x") == 0); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_STRING); + CHECK(strcmp(name, "nvlist/string/abcdefghijklmnopqrstuvwxyz") == 0); + CHECK(strcmp(nvlist_get_string(nvl, name), "abcdefghijklmnopqrstuvwxyz") == 0); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_DESCRIPTOR); + CHECK(strcmp(name, "nvlist/descriptor/STDERR_FILENO") == 0); + CHECK(fd_is_valid(nvlist_get_descriptor(nvl, name))); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_BINARY); + CHECK(strcmp(name, "nvlist/binary/x") == 0); + CHECK(memcmp(nvlist_get_binary(nvl, name, NULL), "x", 1) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, name, &size), "x", 1) == 0); + CHECK(size == 1); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_BINARY); + CHECK(strcmp(name, "nvlist/binary/abcdefghijklmnopqrstuvwxyz") == 0); + CHECK(memcmp(nvlist_get_binary(nvl, name, NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(memcmp(nvlist_get_binary(nvl, name, &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name != NULL); + CHECK(type == NV_TYPE_NVLIST); + CHECK(strcmp(name, "nvlist/nvlist") == 0); + cnvl = nvlist_get_nvlist(nvl, name); + + ccookie = NULL; + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_BOOL); + CHECK(strcmp(cname, "nvlist/bool/true") == 0); + CHECK(nvlist_get_bool(cnvl, cname) == true); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_BOOL); + CHECK(strcmp(cname, "nvlist/bool/false") == 0); + CHECK(nvlist_get_bool(cnvl, cname) == false); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_NUMBER); + CHECK(strcmp(cname, "nvlist/number/0") == 0); + CHECK(nvlist_get_number(cnvl, cname) == 0); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_NUMBER); + CHECK(strcmp(cname, "nvlist/number/1") == 0); + CHECK(nvlist_get_number(cnvl, cname) == 1); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_NUMBER); + CHECK(strcmp(cname, "nvlist/number/-1") == 0); + CHECK((int)nvlist_get_number(cnvl, cname) == -1); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_NUMBER); + CHECK(strcmp(cname, "nvlist/number/UINT64_MAX") == 0); + CHECK(nvlist_get_number(cnvl, cname) == UINT64_MAX); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_NUMBER); + CHECK(strcmp(cname, "nvlist/number/INT64_MIN") == 0); + CHECK((int64_t)nvlist_get_number(cnvl, cname) == INT64_MIN); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_NUMBER); + CHECK(strcmp(cname, "nvlist/number/INT64_MAX") == 0); + CHECK((int64_t)nvlist_get_number(cnvl, cname) == INT64_MAX); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_STRING); + CHECK(strcmp(cname, "nvlist/string/") == 0); + CHECK(strcmp(nvlist_get_string(cnvl, cname), "") == 0); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_STRING); + CHECK(strcmp(cname, "nvlist/string/x") == 0); + CHECK(strcmp(nvlist_get_string(cnvl, cname), "x") == 0); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_STRING); + CHECK(strcmp(cname, "nvlist/string/abcdefghijklmnopqrstuvwxyz") == 0); + CHECK(strcmp(nvlist_get_string(cnvl, cname), "abcdefghijklmnopqrstuvwxyz") == 0); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_DESCRIPTOR); + CHECK(strcmp(cname, "nvlist/descriptor/STDERR_FILENO") == 0); + CHECK(fd_is_valid(nvlist_get_descriptor(cnvl, cname))); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_BINARY); + CHECK(strcmp(cname, "nvlist/binary/x") == 0); + CHECK(memcmp(nvlist_get_binary(cnvl, cname, NULL), "x", 1) == 0); + CHECK(memcmp(nvlist_get_binary(cnvl, cname, &size), "x", 1) == 0); + CHECK(size == 1); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname != NULL); + CHECK(ctype == NV_TYPE_BINARY); + CHECK(strcmp(cname, "nvlist/binary/abcdefghijklmnopqrstuvwxyz") == 0); + CHECK(memcmp(nvlist_get_binary(cnvl, cname, NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(memcmp(nvlist_get_binary(cnvl, cname, &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); + CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); + + cname = nvlist_next(cnvl, &ctype, &ccookie); + CHECK(cname == NULL); + + name = nvlist_next(nvl, &type, &cookie); + CHECK(name == NULL); +} + +int +main(void) +{ + int status, socks[2]; + pid_t pid; + + printf("1..126\n"); + fflush(stdout); + + if (socketpair(PF_UNIX, SOCK_STREAM, 0, socks) < 0) + err(1, "socketpair() failed"); + pid = fork(); + switch (pid) { + case -1: + /* Failure. */ + err(1, "unable to fork"); + case 0: + /* Child. */ + close(socks[0]); + child(socks[1]); + return (0); + default: + /* Parent. */ + close(socks[1]); + parent(socks[0]); + break; + } + + if (waitpid(pid, &status, 0) < 0) + err(1, "waitpid() failed"); + + return (0); +} Property changes on: head/lib/libnv/tests/nvlist_send_recv_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/nvlist_add.c =================================================================== --- head/tools/regression/lib/libnv/nvlist_add.c (revision 269602) +++ head/tools/regression/lib/libnv/nvlist_add.c (nonexistent) @@ -1,196 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Pawel Jakub Dawidek under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHORS 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 AUTHORS 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. - * - * $FreeBSD$ - */ - -#include -#include -#include - -#include - -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ - ntest++; \ -} while (0) - -int -main(void) -{ - const nvlist_t *cnvl; - nvlist_t *nvl; - - printf("1..94\n"); - - nvl = nvlist_create(0); - - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - nvlist_add_null(nvl, "nvlist/null"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_null(nvl, "nvlist/null")); - - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/true")); - nvlist_add_bool(nvl, "nvlist/bool/true", true); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool/true")); - - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/false")); - nvlist_add_bool(nvl, "nvlist/bool/false", false); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool/false")); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/0")); - nvlist_add_number(nvl, "nvlist/number/0", 0); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_number(nvl, "nvlist/number/0")); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/1")); - nvlist_add_number(nvl, "nvlist/number/1", 1); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_number(nvl, "nvlist/number/1")); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/-1")); - nvlist_add_number(nvl, "nvlist/number/-1", -1); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_number(nvl, "nvlist/number/-1")); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); - nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); - nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); - nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/")); - nvlist_add_string(nvl, "nvlist/string/", ""); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/string/")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/x")); - nvlist_add_string(nvl, "nvlist/string/x", "x"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/")); - nvlist_add_stringf(nvl, "nvlist/stringf/", "%s", ""); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/stringf/")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/x")); - nvlist_add_stringf(nvl, "nvlist/stringf/x", "%s", "x"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/stringf/x")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/666Xabc")); - nvlist_add_stringf(nvl, "nvlist/stringf/666Xabc", "%d%c%s", 666, 'X', "abc"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/stringf/666Xabc")); - - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x")); - nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); - - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - - CHECK(nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool/true")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool/false")); - CHECK(nvlist_exists_number(nvl, "nvlist/number/0")); - CHECK(nvlist_exists_number(nvl, "nvlist/number/1")); - CHECK(nvlist_exists_number(nvl, "nvlist/number/-1")); - CHECK(nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); - CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); - CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); - CHECK(nvlist_exists_string(nvl, "nvlist/string/")); - CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); - CHECK(nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_exists_string(nvl, "nvlist/stringf/")); - CHECK(nvlist_exists_string(nvl, "nvlist/stringf/x")); - CHECK(nvlist_exists_string(nvl, "nvlist/stringf/666Xabc")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - - cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist"); - CHECK(nvlist_exists_null(cnvl, "nvlist/null")); - CHECK(nvlist_exists_bool(cnvl, "nvlist/bool/true")); - CHECK(nvlist_exists_bool(cnvl, "nvlist/bool/false")); - CHECK(nvlist_exists_number(cnvl, "nvlist/number/0")); - CHECK(nvlist_exists_number(cnvl, "nvlist/number/1")); - CHECK(nvlist_exists_number(cnvl, "nvlist/number/-1")); - CHECK(nvlist_exists_number(cnvl, "nvlist/number/UINT64_MAX")); - CHECK(nvlist_exists_number(cnvl, "nvlist/number/INT64_MIN")); - CHECK(nvlist_exists_number(cnvl, "nvlist/number/INT64_MAX")); - CHECK(nvlist_exists_string(cnvl, "nvlist/string/")); - CHECK(nvlist_exists_string(cnvl, "nvlist/string/x")); - CHECK(nvlist_exists_string(cnvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/")); - CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/x")); - CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/666Xabc")); - CHECK(nvlist_exists_descriptor(cnvl, "nvlist/descriptor/STDERR_FILENO")); - CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/x")); - CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - - nvlist_destroy(nvl); - - return (0); -} Property changes on: head/tools/regression/lib/libnv/nvlist_add.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/nvlist_send_recv.c =================================================================== --- head/tools/regression/lib/libnv/nvlist_send_recv.c (revision 269602) +++ head/tools/regression/lib/libnv/nvlist_send_recv.c (nonexistent) @@ -1,325 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Pawel Jakub Dawidek under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHORS 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 AUTHORS 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. - * - * $FreeBSD$ - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ - ntest++; \ -} while (0) - -#define fd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF) - -static void -child(int sock) -{ - nvlist_t *nvl; - - nvl = nvlist_create(0); - - nvlist_add_bool(nvl, "nvlist/bool/true", true); - nvlist_add_bool(nvl, "nvlist/bool/false", false); - nvlist_add_number(nvl, "nvlist/number/0", 0); - nvlist_add_number(nvl, "nvlist/number/1", 1); - nvlist_add_number(nvl, "nvlist/number/-1", -1); - nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX); - nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN); - nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX); - nvlist_add_string(nvl, "nvlist/string/", ""); - nvlist_add_string(nvl, "nvlist/string/x", "x"); - nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); - nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO); - nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1); - nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")); - nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); - - nvlist_send(sock, nvl); - - nvlist_destroy(nvl); -} - -static void -parent(int sock) -{ - nvlist_t *nvl; - const nvlist_t *cnvl; - const char *name, *cname; - void *cookie, *ccookie; - int type, ctype; - size_t size; - - nvl = nvlist_recv(sock); - CHECK(nvlist_error(nvl) == 0); - if (nvlist_error(nvl) != 0) - err(1, "nvlist_recv() failed"); - - cookie = NULL; - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_BOOL); - CHECK(strcmp(name, "nvlist/bool/true") == 0); - CHECK(nvlist_get_bool(nvl, name) == true); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_BOOL); - CHECK(strcmp(name, "nvlist/bool/false") == 0); - CHECK(nvlist_get_bool(nvl, name) == false); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NUMBER); - CHECK(strcmp(name, "nvlist/number/0") == 0); - CHECK(nvlist_get_number(nvl, name) == 0); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NUMBER); - CHECK(strcmp(name, "nvlist/number/1") == 0); - CHECK(nvlist_get_number(nvl, name) == 1); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NUMBER); - CHECK(strcmp(name, "nvlist/number/-1") == 0); - CHECK((int)nvlist_get_number(nvl, name) == -1); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NUMBER); - CHECK(strcmp(name, "nvlist/number/UINT64_MAX") == 0); - CHECK(nvlist_get_number(nvl, name) == UINT64_MAX); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NUMBER); - CHECK(strcmp(name, "nvlist/number/INT64_MIN") == 0); - CHECK((int64_t)nvlist_get_number(nvl, name) == INT64_MIN); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NUMBER); - CHECK(strcmp(name, "nvlist/number/INT64_MAX") == 0); - CHECK((int64_t)nvlist_get_number(nvl, name) == INT64_MAX); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_STRING); - CHECK(strcmp(name, "nvlist/string/") == 0); - CHECK(strcmp(nvlist_get_string(nvl, name), "") == 0); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_STRING); - CHECK(strcmp(name, "nvlist/string/x") == 0); - CHECK(strcmp(nvlist_get_string(nvl, name), "x") == 0); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_STRING); - CHECK(strcmp(name, "nvlist/string/abcdefghijklmnopqrstuvwxyz") == 0); - CHECK(strcmp(nvlist_get_string(nvl, name), "abcdefghijklmnopqrstuvwxyz") == 0); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_DESCRIPTOR); - CHECK(strcmp(name, "nvlist/descriptor/STDERR_FILENO") == 0); - CHECK(fd_is_valid(nvlist_get_descriptor(nvl, name))); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_BINARY); - CHECK(strcmp(name, "nvlist/binary/x") == 0); - CHECK(memcmp(nvlist_get_binary(nvl, name, NULL), "x", 1) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, name, &size), "x", 1) == 0); - CHECK(size == 1); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_BINARY); - CHECK(strcmp(name, "nvlist/binary/abcdefghijklmnopqrstuvwxyz") == 0); - CHECK(memcmp(nvlist_get_binary(nvl, name, NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, name, &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name != NULL); - CHECK(type == NV_TYPE_NVLIST); - CHECK(strcmp(name, "nvlist/nvlist") == 0); - cnvl = nvlist_get_nvlist(nvl, name); - - ccookie = NULL; - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_BOOL); - CHECK(strcmp(cname, "nvlist/bool/true") == 0); - CHECK(nvlist_get_bool(cnvl, cname) == true); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_BOOL); - CHECK(strcmp(cname, "nvlist/bool/false") == 0); - CHECK(nvlist_get_bool(cnvl, cname) == false); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_NUMBER); - CHECK(strcmp(cname, "nvlist/number/0") == 0); - CHECK(nvlist_get_number(cnvl, cname) == 0); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_NUMBER); - CHECK(strcmp(cname, "nvlist/number/1") == 0); - CHECK(nvlist_get_number(cnvl, cname) == 1); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_NUMBER); - CHECK(strcmp(cname, "nvlist/number/-1") == 0); - CHECK((int)nvlist_get_number(cnvl, cname) == -1); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_NUMBER); - CHECK(strcmp(cname, "nvlist/number/UINT64_MAX") == 0); - CHECK(nvlist_get_number(cnvl, cname) == UINT64_MAX); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_NUMBER); - CHECK(strcmp(cname, "nvlist/number/INT64_MIN") == 0); - CHECK((int64_t)nvlist_get_number(cnvl, cname) == INT64_MIN); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_NUMBER); - CHECK(strcmp(cname, "nvlist/number/INT64_MAX") == 0); - CHECK((int64_t)nvlist_get_number(cnvl, cname) == INT64_MAX); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_STRING); - CHECK(strcmp(cname, "nvlist/string/") == 0); - CHECK(strcmp(nvlist_get_string(cnvl, cname), "") == 0); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_STRING); - CHECK(strcmp(cname, "nvlist/string/x") == 0); - CHECK(strcmp(nvlist_get_string(cnvl, cname), "x") == 0); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_STRING); - CHECK(strcmp(cname, "nvlist/string/abcdefghijklmnopqrstuvwxyz") == 0); - CHECK(strcmp(nvlist_get_string(cnvl, cname), "abcdefghijklmnopqrstuvwxyz") == 0); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_DESCRIPTOR); - CHECK(strcmp(cname, "nvlist/descriptor/STDERR_FILENO") == 0); - CHECK(fd_is_valid(nvlist_get_descriptor(cnvl, cname))); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_BINARY); - CHECK(strcmp(cname, "nvlist/binary/x") == 0); - CHECK(memcmp(nvlist_get_binary(cnvl, cname, NULL), "x", 1) == 0); - CHECK(memcmp(nvlist_get_binary(cnvl, cname, &size), "x", 1) == 0); - CHECK(size == 1); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname != NULL); - CHECK(ctype == NV_TYPE_BINARY); - CHECK(strcmp(cname, "nvlist/binary/abcdefghijklmnopqrstuvwxyz") == 0); - CHECK(memcmp(nvlist_get_binary(cnvl, cname, NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(memcmp(nvlist_get_binary(cnvl, cname, &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); - - cname = nvlist_next(cnvl, &ctype, &ccookie); - CHECK(cname == NULL); - - name = nvlist_next(nvl, &type, &cookie); - CHECK(name == NULL); -} - -int -main(void) -{ - int status, socks[2]; - pid_t pid; - - printf("1..126\n"); - fflush(stdout); - - if (socketpair(PF_UNIX, SOCK_STREAM, 0, socks) < 0) - err(1, "socketpair() failed"); - pid = fork(); - switch (pid) { - case -1: - /* Failure. */ - err(1, "unable to fork"); - case 0: - /* Child. */ - close(socks[0]); - child(socks[1]); - return (0); - default: - /* Parent. */ - close(socks[1]); - parent(socks[0]); - break; - } - - if (waitpid(pid, &status, 0) < 0) - err(1, "waitpid() failed"); - - return (0); -} Property changes on: head/tools/regression/lib/libnv/nvlist_send_recv.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/nvlist_get.c =================================================================== --- head/tools/regression/lib/libnv/nvlist_get.c (revision 269602) +++ head/tools/regression/lib/libnv/nvlist_get.c (nonexistent) @@ -1,182 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Pawel Jakub Dawidek under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHORS 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 AUTHORS 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include - -#include - -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ - ntest++; \ -} while (0) - -#define fd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF) - -int -main(void) -{ - const nvlist_t *cnvl; - nvlist_t *nvl; - size_t size; - - printf("1..83\n"); - - nvl = nvlist_create(0); - - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/true")); - nvlist_add_bool(nvl, "nvlist/bool/true", true); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_get_bool(nvl, "nvlist/bool/true") == true); - - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/false")); - nvlist_add_bool(nvl, "nvlist/bool/false", false); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_get_bool(nvl, "nvlist/bool/false") == false); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/0")); - nvlist_add_number(nvl, "nvlist/number/0", 0); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_get_number(nvl, "nvlist/number/0") == 0); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/1")); - nvlist_add_number(nvl, "nvlist/number/1", 1); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_get_number(nvl, "nvlist/number/1") == 1); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/-1")); - nvlist_add_number(nvl, "nvlist/number/-1", -1); - CHECK(nvlist_error(nvl) == 0); - CHECK((int)nvlist_get_number(nvl, "nvlist/number/-1") == -1); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX")); - nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_get_number(nvl, "nvlist/number/UINT64_MAX") == UINT64_MAX); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MIN")); - nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN); - CHECK(nvlist_error(nvl) == 0); - CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MIN") == INT64_MIN); - - CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MAX")); - nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX); - CHECK(nvlist_error(nvl) == 0); - CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MAX") == INT64_MAX); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/")); - nvlist_add_string(nvl, "nvlist/string/", ""); - CHECK(nvlist_error(nvl) == 0); - CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/"), "") == 0); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/x")); - nvlist_add_string(nvl, "nvlist/string/x", "x"); - CHECK(nvlist_error(nvl) == 0); - CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/x"), "x") == 0); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); - CHECK(nvlist_error(nvl) == 0); - CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0); - - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO); - CHECK(nvlist_error(nvl) == 0); - CHECK(fd_is_valid(nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"))); - - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x")); - nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1); - CHECK(nvlist_error(nvl) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", NULL), "x", 1) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", &size), "x", 1) == 0); - CHECK(size == 1); - - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_error(nvl) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); - - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); - CHECK(nvlist_error(nvl) == 0); - cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist"); - CHECK(nvlist_get_bool(cnvl, "nvlist/bool/true") == true); - CHECK(nvlist_get_bool(cnvl, "nvlist/bool/false") == false); - CHECK(nvlist_get_number(cnvl, "nvlist/number/0") == 0); - CHECK(nvlist_get_number(cnvl, "nvlist/number/1") == 1); - CHECK((int)nvlist_get_number(cnvl, "nvlist/number/-1") == -1); - CHECK(nvlist_get_number(cnvl, "nvlist/number/UINT64_MAX") == UINT64_MAX); - CHECK((int64_t)nvlist_get_number(cnvl, "nvlist/number/INT64_MIN") == INT64_MIN); - CHECK((int64_t)nvlist_get_number(cnvl, "nvlist/number/INT64_MAX") == INT64_MAX); - CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/"), "") == 0); - CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/x"), "x") == 0); - CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0); - /* TODO */ - CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/x", NULL), "x", 1) == 0); - CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/x", &size), "x", 1) == 0); - CHECK(size == 1); - CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); - - CHECK(nvlist_get_bool(nvl, "nvlist/bool/true") == true); - CHECK(nvlist_get_bool(nvl, "nvlist/bool/false") == false); - CHECK(nvlist_get_number(nvl, "nvlist/number/0") == 0); - CHECK(nvlist_get_number(nvl, "nvlist/number/1") == 1); - CHECK((int)nvlist_get_number(nvl, "nvlist/number/-1") == -1); - CHECK(nvlist_get_number(nvl, "nvlist/number/UINT64_MAX") == UINT64_MAX); - CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MIN") == INT64_MIN); - CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MAX") == INT64_MAX); - CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/"), "") == 0); - CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/x"), "x") == 0); - CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0); - CHECK(fd_is_valid(nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"))); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", NULL), "x", 1) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", &size), "x", 1) == 0); - CHECK(size == 1); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0); - CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); - - nvlist_destroy(nvl); - - return (0); -} Property changes on: head/tools/regression/lib/libnv/nvlist_get.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/nvlist_move.c =================================================================== --- head/tools/regression/lib/libnv/nvlist_move.c (revision 269602) +++ head/tools/regression/lib/libnv/nvlist_move.c (nonexistent) @@ -1,161 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Pawel Jakub Dawidek under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHORS 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 AUTHORS 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include - -#include - -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ - ntest++; \ -} while (0) - -int -main(void) -{ - const nvlist_t *cnvl; - nvlist_t *nvl; - void *ptr; - size_t size; - int fd; - - printf("1..52\n"); - - nvl = nvlist_create(0); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/")); - ptr = strdup(""); - CHECK(ptr != NULL); - nvlist_move_string(nvl, "nvlist/string/", ptr); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/string/")); - CHECK(ptr == nvlist_get_string(nvl, "nvlist/string/")); - - CHECK(!nvlist_exists_string(nvl, "nvlist/string/x")); - ptr = strdup("x"); - CHECK(ptr != NULL); - nvlist_move_string(nvl, "nvlist/string/x", ptr); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); - CHECK(ptr == nvlist_get_string(nvl, "nvlist/string/x")); - - CHECK(!nvlist_exists_string(nvl, - "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - ptr = strdup("abcdefghijklmnopqrstuvwxyz"); - CHECK(ptr != NULL); - nvlist_move_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", - ptr); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_string(nvl, - "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - CHECK(ptr == - nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - - CHECK(!nvlist_exists_descriptor(nvl, - "nvlist/descriptor/STDERR_FILENO")); - fd = dup(STDERR_FILENO); - CHECK(fd >= 0); - nvlist_move_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", fd); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - CHECK(fd == - nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x")); - ptr = malloc(1); - CHECK(ptr != NULL); - memcpy(ptr, "x", 1); - nvlist_move_binary(nvl, "nvlist/binary/x", ptr, 1); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); - CHECK(ptr == nvlist_get_binary(nvl, "nvlist/binary/x", NULL)); - CHECK(ptr == nvlist_get_binary(nvl, "nvlist/binary/x", &size)); - CHECK(size == 1); - - CHECK(!nvlist_exists_binary(nvl, - "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - ptr = malloc(sizeof("abcdefghijklmnopqrstuvwxyz")); - CHECK(ptr != NULL); - memcpy(ptr, "abcdefghijklmnopqrstuvwxyz", - sizeof("abcdefghijklmnopqrstuvwxyz")); - nvlist_move_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", - ptr, sizeof("abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_binary(nvl, - "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - CHECK(ptr == nvlist_get_binary(nvl, - "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL)); - CHECK(ptr == nvlist_get_binary(nvl, - "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size)); - CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz")); - - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - ptr = nvlist_clone(nvl); - CHECK(ptr != NULL); - nvlist_move_nvlist(nvl, "nvlist/nvlist", ptr); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(ptr == nvlist_get_nvlist(nvl, "nvlist/nvlist")); - - CHECK(nvlist_exists_string(nvl, "nvlist/string/")); - CHECK(nvlist_exists_string(nvl, "nvlist/string/x")); - CHECK(nvlist_exists_string(nvl, - "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x")); - CHECK(nvlist_exists_binary(nvl, - "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - - cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist"); - CHECK(nvlist_exists_string(cnvl, "nvlist/string/")); - CHECK(nvlist_exists_string(cnvl, "nvlist/string/x")); - CHECK(nvlist_exists_string(cnvl, - "nvlist/string/abcdefghijklmnopqrstuvwxyz")); - CHECK(nvlist_exists_descriptor(cnvl, - "nvlist/descriptor/STDERR_FILENO")); - CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/x")); - CHECK(nvlist_exists_binary(cnvl, - "nvlist/binary/abcdefghijklmnopqrstuvwxyz")); - - nvlist_destroy(nvl); - - return (0); -} Property changes on: head/tools/regression/lib/libnv/nvlist_move.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/nvlist_exists.c =================================================================== --- head/tools/regression/lib/libnv/nvlist_exists.c (revision 269602) +++ head/tools/regression/lib/libnv/nvlist_exists.c (nonexistent) @@ -1,321 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Pawel Jakub Dawidek under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHORS 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 AUTHORS 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. - * - * $FreeBSD$ - */ - -#include -#include - -#include - -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ - ntest++; \ -} while (0) - -int -main(void) -{ - nvlist_t *nvl; - - printf("1..232\n"); - - nvl = nvlist_create(0); - - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/null")); - CHECK(!nvlist_exists_number(nvl, "nvlist/null")); - CHECK(!nvlist_exists_string(nvl, "nvlist/null")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/null")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/null")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/null")); - nvlist_add_null(nvl, "nvlist/null"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/null")); - CHECK(nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/null")); - CHECK(!nvlist_exists_number(nvl, "nvlist/null")); - CHECK(!nvlist_exists_string(nvl, "nvlist/null")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/null")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/null")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/null")); - - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_null(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_string(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/bool")); - nvlist_add_bool(nvl, "nvlist/bool", true); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_null(nvl, "nvlist/bool")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_string(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/bool")); - - CHECK(!nvlist_exists(nvl, "nvlist/number")); - CHECK(!nvlist_exists_null(nvl, "nvlist/number")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/number")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/number")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/number")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/number")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/number")); - nvlist_add_number(nvl, "nvlist/number", 0); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/number")); - CHECK(!nvlist_exists_null(nvl, "nvlist/number")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/number")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/number")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/number")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/number")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/number")); - - CHECK(!nvlist_exists(nvl, "nvlist/string")); - CHECK(!nvlist_exists_null(nvl, "nvlist/string")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/string")); - CHECK(!nvlist_exists_number(nvl, "nvlist/string")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/string")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/string")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/string")); - nvlist_add_string(nvl, "nvlist/string", "test"); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/string")); - CHECK(!nvlist_exists_null(nvl, "nvlist/string")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/string")); - CHECK(!nvlist_exists_number(nvl, "nvlist/string")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/string")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/string")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/string")); - - CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_null(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_number(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_string(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/nvlist")); - nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_null(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_number(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_string(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/nvlist")); - - CHECK(!nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_null(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_number(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_string(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/descriptor")); - nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_null(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_number(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_string(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/descriptor")); - - CHECK(!nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_number(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_string(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); - nvlist_add_binary(nvl, "nvlist/binary", "test", 4); - CHECK(nvlist_error(nvl) == 0); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_number(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_string(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/binary")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - CHECK(nvlist_exists(nvl, "nvlist/null")); - CHECK(nvlist_exists(nvl, "nvlist/bool")); - CHECK(nvlist_exists(nvl, "nvlist/number")); - CHECK(nvlist_exists(nvl, "nvlist/string")); - CHECK(nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_null(nvl, "nvlist/null"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(nvlist_exists(nvl, "nvlist/bool")); - CHECK(nvlist_exists(nvl, "nvlist/number")); - CHECK(nvlist_exists(nvl, "nvlist/string")); - CHECK(nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_bool(nvl, "nvlist/bool"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(nvlist_exists(nvl, "nvlist/number")); - CHECK(nvlist_exists(nvl, "nvlist/string")); - CHECK(nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_number(nvl, "nvlist/number"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists(nvl, "nvlist/number")); - CHECK(nvlist_exists(nvl, "nvlist/string")); - CHECK(nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_string(nvl, "nvlist/string"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists(nvl, "nvlist/number")); - CHECK(!nvlist_exists(nvl, "nvlist/string")); - CHECK(nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_nvlist(nvl, "nvlist/nvlist"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists(nvl, "nvlist/number")); - CHECK(!nvlist_exists(nvl, "nvlist/string")); - CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_descriptor(nvl, "nvlist/descriptor"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists(nvl, "nvlist/number")); - CHECK(!nvlist_exists(nvl, "nvlist/string")); - CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_binary(nvl, "nvlist/binary"); - CHECK(!nvlist_exists(nvl, "nvlist/null")); - CHECK(!nvlist_exists(nvl, "nvlist/bool")); - CHECK(!nvlist_exists(nvl, "nvlist/number")); - CHECK(!nvlist_exists(nvl, "nvlist/string")); - CHECK(!nvlist_exists(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists(nvl, "nvlist/binary")); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); - - CHECK(nvlist_empty(nvl)); - - nvlist_destroy(nvl); - - return (0); -} Property changes on: head/tools/regression/lib/libnv/nvlist_exists.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/nvlist_free.c =================================================================== --- head/tools/regression/lib/libnv/nvlist_free.c (revision 269602) +++ head/tools/regression/lib/libnv/nvlist_free.c (nonexistent) @@ -1,221 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Pawel Jakub Dawidek under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHORS 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 AUTHORS 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. - * - * $FreeBSD$ - */ - -#include -#include - -#include - -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ - ntest++; \ -} while (0) - -int -main(void) -{ - nvlist_t *nvl; - - printf("1..114\n"); - - nvl = nvlist_create(0); - - nvlist_add_null(nvl, "nvlist/null"); - nvlist_add_bool(nvl, "nvlist/bool", true); - nvlist_add_number(nvl, "nvlist/number", 0); - nvlist_add_string(nvl, "nvlist/string", "test"); - nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); - nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO); - nvlist_add_binary(nvl, "nvlist/binary", "test", 4); - - CHECK(nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_null(nvl, "nvlist/null"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_bool(nvl, "nvlist/bool"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_number(nvl, "nvlist/number"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_string(nvl, "nvlist/string"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_nvlist(nvl, "nvlist/nvlist"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_descriptor(nvl, "nvlist/descriptor"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free_binary(nvl, "nvlist/binary"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); - - CHECK(nvlist_empty(nvl)); - - nvlist_add_null(nvl, "nvlist/null"); - nvlist_add_bool(nvl, "nvlist/bool", true); - nvlist_add_number(nvl, "nvlist/number", 0); - nvlist_add_string(nvl, "nvlist/string", "test"); - nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl); - nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO); - nvlist_add_binary(nvl, "nvlist/binary", "test", 4); - - CHECK(nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/null"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/bool"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/number"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/string"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/nvlist"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/descriptor"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(nvlist_exists_binary(nvl, "nvlist/binary")); - - nvlist_free(nvl, "nvlist/binary"); - CHECK(!nvlist_exists_null(nvl, "nvlist/null")); - CHECK(!nvlist_exists_bool(nvl, "nvlist/bool")); - CHECK(!nvlist_exists_number(nvl, "nvlist/number")); - CHECK(!nvlist_exists_string(nvl, "nvlist/string")); - CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist")); - CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor")); - CHECK(!nvlist_exists_binary(nvl, "nvlist/binary")); - - CHECK(nvlist_empty(nvl)); - - nvlist_destroy(nvl); - - return (0); -} Property changes on: head/tools/regression/lib/libnv/nvlist_free.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/tools/regression/lib/libnv/Makefile =================================================================== --- head/tools/regression/lib/libnv/Makefile (revision 269602) +++ head/tools/regression/lib/libnv/Makefile (nonexistent) @@ -1,35 +0,0 @@ -# $FreeBSD$ - -TESTS= nvlist_add -TESTS+= nvlist_exists -TESTS+= nvlist_free -TESTS+= nvlist_get -TESTS+= nvlist_move -TESTS+= nvlist_send_recv - -CFLAGS= -O2 -pipe -fstack-protector -CFLAGS+=-Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -CFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -CFLAGS+=-Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -CFLAGS+=-Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -CFLAGS+=-Wold-style-definition -Wno-pointer-sign -Wextra - -LDFLAGS+=-lnv - -all: ${TESTS} ${TESTS:=.t} - -.for TEST in ${TESTS} - -${TEST}: ${TEST}.c - ${CC} ${CFLAGS} ${LDFLAGS} ${@}.c -o $@ - -${TEST}.t: ${TEST} - @printf "#!/bin/sh\n\n%s/%s\n" ${.CURDIR} ${@:.t=} > $@ - -.endfor - -test: all - @prove -r ${.CURDIR} - -clean: - rm -f ${TESTS} ${TESTS:=.t} Property changes on: head/tools/regression/lib/libnv/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property