From 5204d1027ad9d0c5553f7fe1ab0dc0649b4916b6 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Mon, 31 Oct 2022 15:36:37 +0000 Subject: [PATCH 1/2] nvlist pack/unpack tester Add an nvpair_packed test command which verifies that an nvlist packed in the XDR format can be unpacked to an identical list and when -r is specified that it matches the unpacking of a reference output. Further, if the -x option is specified it checks that the packed output is identical to a reference packed output stored in /.ref. Reference output can be generated by adding the -R option. The core set of tests is defined in `struct nvcase test_cases[]`, a statically initialized array describing nvpairs to generate. A series of macros are used to keep the verbosity under control. The main exception is embedded nvlists which are initialized in init_nvlists(). The current set is in data_type_t order and all types are coverd, but some edge cases may be unexplored, especially since only a small number of multiple-element nvlists are created. Signed-off-by: Brooks Davis --- tests/zfs-tests/cmd/.gitignore | 1 + tests/zfs-tests/cmd/Makefile.am | 4 + tests/zfs-tests/cmd/nvlist_packed.c | 843 ++++++++++++++++++++++++++++ 3 files changed, 848 insertions(+) create mode 100644 tests/zfs-tests/cmd/nvlist_packed.c diff --git a/tests/zfs-tests/cmd/.gitignore b/tests/zfs-tests/cmd/.gitignore index f68f580728..d8de9a5599 100644 --- a/tests/zfs-tests/cmd/.gitignore +++ b/tests/zfs-tests/cmd/.gitignore @@ -22,6 +22,7 @@ /mmap_seek /mmap_sync /mmapwrite +/nvlist_packed /nvlist_to_lua /randfree_file /randwritecomp diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am index 066abb6ce3..ef1e864b73 100644 --- a/tests/zfs-tests/cmd/Makefile.am +++ b/tests/zfs-tests/cmd/Makefile.am @@ -72,6 +72,10 @@ scripts_zfs_tests_bin_PROGRAMS += %D%/mmap_libaio endif +scripts_zfs_tests_bin_PROGRAMS += %D%/nvlist_packed +%C%_nvlist_packed_LDADD = \ + libnvpair.la + scripts_zfs_tests_bin_PROGRAMS += %D%/nvlist_to_lua %C%_nvlist_to_lua_LDADD = \ libzfs_core.la \ diff --git a/tests/zfs-tests/cmd/nvlist_packed.c b/tests/zfs-tests/cmd/nvlist_packed.c new file mode 100644 index 0000000000..1ccaa5b40a --- /dev/null +++ b/tests/zfs-tests/cmd/nvlist_packed.c @@ -0,0 +1,843 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 SRI International + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under Defense Advanced Research Projects Agency (DARPA) + * Contract No. HR001122C0110 ("ETC"). + * + * 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define NNVLISTS 4 + +#ifndef nitems +#define nitems(x) (sizeof (x) / sizeof ((x)[0])) +#endif + +static int verbose; +static bool genrefs, ref_match_exact; +static const char *refdir; +static int refdir_fd; + +static int tests_run, tests_failed; + +static bool nvlist_equal(nvlist_t *nvl_a, nvlist_t *nvl_b); + +static void +usage(void) +{ + printf("usage:\n"); + printf(" nvlist_pack [options] -a\n"); + printf(" nvlist_pack [options] [ [...]]\n"); + printf(" nvlist_pack [options] -l\n"); + printf("options:\n"); + printf(" -a Run all test cases\n"); + printf(" -l list test cases\n"); + printf(" -r reference directory\n"); + printf(" -R generate reference files (requires -r)\n"); + printf(" -v verbose output\n"); + printf(" -x reference buffers must match exactly\n"); + exit(1); +} + +struct nvcase { + const char *nvc_name; + const char *nvc_nvname; /* pair name, nvc_name used if NULL */ + data_type_t nvc_type; + int nvc_nelem; + const void *nvc_data; + char *nvc_failure_reason; +}; + +#define NVCASE_SIMPLE(type, nvtype) { \ + .nvc_name = #type, \ + .nvc_type = nvtype, \ + .nvc_data = &data_##type[0], \ +} +#define NVCASE_STRING(string) { \ + .nvc_name = "string_" string, \ + .nvc_type = DATA_TYPE_STRING, \ + .nvc_data = string, \ +} +#define _NVCASE_ARRAY(type, nvtype, array, nelem) { \ + .nvc_name = (type), \ + .nvc_type = (nvtype), \ + .nvc_nelem = (nelem), \ + .nvc_data = (array), \ +} +#define _NVCASE_ARRAY_ALL(type, nvtype) \ + _NVCASE_ARRAY(#type "_array", (nvtype), data_##type, \ + nitems(data_##type)) +#define _NVCASE_ARRAY_EMPTY(type, nvtype) \ + _NVCASE_ARRAY(#type "_array_empty", (nvtype), NULL, 0) +#define _NVCASE_ARRAY_SINGLE(type, nvtype) \ + _NVCASE_ARRAY(#type "_array_single", (nvtype), data_##type, 1) +#define NVCASE_ARRAY(type, nvtype) \ + _NVCASE_ARRAY_ALL(type, nvtype), \ + _NVCASE_ARRAY_EMPTY(type, nvtype), \ + _NVCASE_ARRAY_SINGLE(type, nvtype) + +static boolean_t data_boolean[] = {true, false, false, true}; +static uchar_t data_byte[] = {'a', 'b', 'c', 'd'}; +static int8_t data_int8[] = {0, 1, 2, -1}; +static uint8_t data_uint8[] = {0, 1, 2, 255}; +static int16_t data_int16[] = {0, 1, 2, -1}; +static uint16_t data_uint16[] = {0, 1, 2, 255}; +static int32_t data_int32[] = {0, 1, 2, -1}; +static uint32_t data_uint32[] = {0, 1, 2, UINT_MAX}; +static int64_t data_int64[] = {0, 1, 2, -1}; +static uint64_t data_uint64[] = {0, 1, 2, ULONG_MAX}; + +static hrtime_t data_hrtime[] = {0}; +static double data_double[] = {0.0}; + +static const char *data_string[] = {"a", "quick", "brown", "fox"}; + +/* + * Initialized by init_nvlists(). + * The naming allow the use of NVCASE_ARRAY() + */ +static nvlist_t _data_nvlist[NNVLISTS]; +static nvlist_t *data_nvlist[NNVLISTS]; + +static struct nvcase test_cases[] = { + { + .nvc_name = "boolean_flag", + .nvc_type = DATA_TYPE_BOOLEAN, + }, + NVCASE_SIMPLE(byte, DATA_TYPE_BYTE), + NVCASE_SIMPLE(int16, DATA_TYPE_INT16), + NVCASE_SIMPLE(uint16, DATA_TYPE_UINT16), + NVCASE_SIMPLE(int32, DATA_TYPE_INT32), + NVCASE_SIMPLE(uint32, DATA_TYPE_UINT32), + NVCASE_SIMPLE(int64, DATA_TYPE_INT64), + NVCASE_SIMPLE(uint64, DATA_TYPE_UINT64), + + /* XXX: use fixed width nvnames to actually hit all aligments */ + NVCASE_STRING(""), + NVCASE_STRING("0"), + NVCASE_STRING("01"), + NVCASE_STRING("012"), + NVCASE_STRING("0123"), + NVCASE_STRING("01234"), + NVCASE_STRING("012345"), + NVCASE_STRING("0123456"), + NVCASE_STRING("01234567"), + NVCASE_STRING("012345678"), + NVCASE_STRING("0123456789"), + NVCASE_STRING("0123456789a"), + NVCASE_STRING("0123456789ab"), + NVCASE_STRING("0123456789abc"), + NVCASE_STRING("0123456789abcd"), + NVCASE_STRING("0123456789abcde"), + NVCASE_STRING("0123456789abcdef"), + NVCASE_STRING("0123456789abcdefg"), + + NVCASE_ARRAY(byte, DATA_TYPE_BYTE_ARRAY), + NVCASE_ARRAY(int16, DATA_TYPE_INT16_ARRAY), + NVCASE_ARRAY(uint16, DATA_TYPE_UINT16_ARRAY), + NVCASE_ARRAY(int32, DATA_TYPE_INT32_ARRAY), + NVCASE_ARRAY(uint32, DATA_TYPE_UINT32_ARRAY), + NVCASE_ARRAY(int64, DATA_TYPE_INT64_ARRAY), + NVCASE_ARRAY(uint64, DATA_TYPE_UINT64_ARRAY), + NVCASE_ARRAY(string, DATA_TYPE_STRING_ARRAY), + NVCASE_SIMPLE(hrtime, DATA_TYPE_HRTIME), + + { + .nvc_name = "nvlist0", + .nvc_type = DATA_TYPE_NVLIST, + .nvc_data = &_data_nvlist[0], + }, + { + .nvc_name = "nvlist1", + .nvc_type = DATA_TYPE_NVLIST, + .nvc_data = &_data_nvlist[1], + }, + { + .nvc_name = "nvlist2", + .nvc_type = DATA_TYPE_NVLIST, + .nvc_data = &_data_nvlist[2], + }, + { + .nvc_name = "nvlist3", + .nvc_type = DATA_TYPE_NVLIST, + .nvc_data = &_data_nvlist[3], + }, + NVCASE_ARRAY(nvlist, DATA_TYPE_NVLIST_ARRAY), + + NVCASE_SIMPLE(boolean, DATA_TYPE_BOOLEAN_VALUE), + NVCASE_SIMPLE(int8, DATA_TYPE_INT8), + NVCASE_SIMPLE(uint8, DATA_TYPE_UINT8), + NVCASE_ARRAY(boolean, DATA_TYPE_BOOLEAN_ARRAY), + NVCASE_ARRAY(int8, DATA_TYPE_INT8_ARRAY), + NVCASE_ARRAY(uint8, DATA_TYPE_UINT8_ARRAY), + NVCASE_SIMPLE(double, DATA_TYPE_DOUBLE), + + { + .nvc_name = "empty_name", + .nvc_nvname = "", + .nvc_type = DATA_TYPE_BOOLEAN, + }, +}; + +static void +init_nvlists(void) +{ + nvlist_t *nvp; + + for (int i = 0; i < NNVLISTS; i++) { + nvp = fnvlist_alloc(); + fnvlist_add_int32(nvp, "index", i); + + switch (i) { + case 0: + fnvlist_add_byte(nvp, "byte", 'b'); + fnvlist_add_uint32(nvp, "uint32", UINT_MAX); + fnvlist_add_int64(nvp, "int64", -1); + fnvlist_add_string(nvp, "string", "value"); + break; + case 1: + fnvlist_add_nvlist(nvp, "nvlist0", data_nvlist[0]); + break; + case 2: + fnvlist_add_nvlist(nvp, "nvlist1", data_nvlist[1]); + break; + case 3: + fnvlist_add_nvlist(nvp, "nvlist2", data_nvlist[2]); + break; + default: + abort(); + } + + data_nvlist[i] = nvp; + /* + * Hack to allow statically allocated nvlist storage + * Ideally nvlist_init() would be exposed and be able to + * alloc programmer managed storage, but it isn't so we + * cheat and copy the allocated one's contents into + * static storage to allow test_cases[] to be + * initialised at compile time. + */ + memcpy(&_data_nvlist[i], nvp, sizeof (_data_nvlist[i])); + } +} + +static void +list_tests(void) +{ + for (int i = 0; i < nitems(test_cases); i++) + printf("'%s'\n", test_cases[i].nvc_name); + exit(0); +} + +static int +case_populate_nvlist(struct nvcase *tc, nvlist_t *nvl) +{ + const char *name = tc->nvc_nvname != NULL? tc->nvc_nvname : + tc->nvc_name; + + switch (tc->nvc_type) { + case DATA_TYPE_BOOLEAN: + return (nvlist_add_boolean(nvl, name)); + case DATA_TYPE_BOOLEAN_VALUE: + return (nvlist_add_boolean_value(nvl, name, + *(boolean_t *)tc->nvc_data)); + case DATA_TYPE_BYTE: + return (nvlist_add_byte(nvl, name, + *(uchar_t *)tc->nvc_data)); + case DATA_TYPE_INT8 : + return (nvlist_add_int8(nvl, name, + *(int8_t *)tc->nvc_data)); + case DATA_TYPE_UINT8: + return (nvlist_add_uint8(nvl, name, + *(uint8_t *)tc->nvc_data)); + case DATA_TYPE_INT16: + return (nvlist_add_int16(nvl, name, + *(int16_t *)tc->nvc_data)); + case DATA_TYPE_UINT16: + return (nvlist_add_uint16(nvl, name, + *(uint16_t *)tc->nvc_data)); + case DATA_TYPE_INT32: + return (nvlist_add_int32(nvl, name, + *(int32_t *)tc->nvc_data)); + case DATA_TYPE_UINT32: + return (nvlist_add_uint32(nvl, name, + *(uint32_t *)tc->nvc_data)); + case DATA_TYPE_INT64: + return (nvlist_add_int64(nvl, name, + *(int64_t *)tc->nvc_data)); + case DATA_TYPE_UINT64: + return (nvlist_add_uint64(nvl, name, + *(uint64_t *)tc->nvc_data)); + case DATA_TYPE_HRTIME: + return (nvlist_add_hrtime(nvl, name, + *(hrtime_t *)tc->nvc_data)); + case DATA_TYPE_DOUBLE: + return (nvlist_add_double(nvl, name, + *(double *)tc->nvc_data)); + + case DATA_TYPE_BOOLEAN_ARRAY: + return (nvlist_add_boolean_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_BYTE_ARRAY: + return (nvlist_add_byte_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_INT8_ARRAY: + return (nvlist_add_int8_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_UINT8_ARRAY: + return (nvlist_add_uint8_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_INT16_ARRAY: + return (nvlist_add_int16_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_UINT16_ARRAY: + return (nvlist_add_uint16_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_INT32_ARRAY: + return (nvlist_add_int32_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_UINT32_ARRAY: + return (nvlist_add_uint32_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_INT64_ARRAY: + return (nvlist_add_int64_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + case DATA_TYPE_UINT64_ARRAY: + return (nvlist_add_uint64_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + + case DATA_TYPE_STRING: + return (nvlist_add_string(nvl, name, + tc->nvc_data)); + case DATA_TYPE_STRING_ARRAY: + return (nvlist_add_string_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + + case DATA_TYPE_NVLIST: + return (nvlist_add_nvlist(nvl, name, + tc->nvc_data)); + case DATA_TYPE_NVLIST_ARRAY: + return (nvlist_add_nvlist_array(nvl, name, + tc->nvc_data, tc->nvc_nelem)); + default: + return (-1); + } +} + +static nvlist_t * +case_create_nvlist(struct nvcase *tc) +{ + nvlist_t *nvl; + + if (nvlist_alloc(&nvl, 0, 0) != 0) + return (NULL); + + if (case_populate_nvlist(tc, nvl) != 0) + return (NULL); + + return (nvl); +} + +static void +case_failed(struct nvcase *tc, const char *reason) +{ + if (tc->nvc_failure_reason != NULL) + return; /* Already called */ + tests_failed++; + tc->nvc_failure_reason = strdup(reason); + printf("FAIL: %s: %s\n", tc->nvc_name, reason); +} + +static void +run_case(struct nvcase *tc) +{ + nvlist_t *created_nvl, *ref_nvl, *unpacked_nvl; + char *packed_buffer = NULL; + size_t buflen; + + tests_run++; + + created_nvl = case_create_nvlist(tc); + if (created_nvl == NULL) { + case_failed(tc, "case_create_nvlist"); + return; + } + if (nvlist_pack(created_nvl, &packed_buffer, &buflen, NV_ENCODE_XDR, + KM_SLEEP) != 0) { + case_failed(tc, "nvlist_pack"); + return; + } + if (nvlist_unpack(packed_buffer, buflen, &unpacked_nvl, + KM_SLEEP) != 0) { + case_failed(tc, "nvlist_unpack (round-trip)"); + return; + } + + if (!nvlist_equal(created_nvl, unpacked_nvl)) { + case_failed(tc, + "create and unpacked nvlists aren't equal"); + return; + } + + if (refdir != NULL) { + struct stat sb; + char *ref_buffer, *ref_file; + size_t ref_len; + int ref_fd; + + if (asprintf(&ref_file, "%s.ref", tc->nvc_name) == -1) { + case_failed(tc, "asprintf"); + return; + } + if (genrefs) { + ref_fd = openat(refdir_fd, ref_file, + O_WRONLY | O_CREAT | O_TRUNC, 0660); + if (ref_fd == -1) { + fprintf(stderr, + "%s: unable to create ref file %s/%s\n", + tc->nvc_name, refdir, ref_file); + exit(1); + } + if (write(ref_fd, packed_buffer, buflen) != buflen) { + fprintf(stderr, "%s: failed to write packed\n", + tc->nvc_name); + exit(1); + } + close(ref_fd); + } + + ref_fd = openat(refdir_fd, ref_file, O_RDONLY); + if (ref_fd == -1) { + case_failed(tc, "failed to open ref file"); + return; + } + fstat(ref_fd, &sb); + ref_len = sb.st_size; + if (ref_len != buflen) { + case_failed(tc, + "ref_len and buflen aren't the same size"); + close(ref_fd); + return; + } + ref_buffer = malloc(ref_len); + if (read(ref_fd, ref_buffer, ref_len) != sb.st_size) { + case_failed(tc, "failed to read from ref file"); + close(ref_fd); + return; + } + close(ref_fd); + + if (nvlist_unpack(ref_buffer, buflen, &ref_nvl, + KM_SLEEP) != 0) { + case_failed(tc, "nvlist_unpack (ref)"); + return; + } + if (!nvlist_equal(created_nvl, ref_nvl)) { + case_failed(tc, + "created and ref_unpacked nvlists aren't equal"); + return; + } + if (ref_match_exact && + memcmp(packed_buffer, ref_buffer, buflen) != 0) { + case_failed(tc, "packed and ref buffers differ"); + return; + } + } + + printf("PASS: %s\n", tc->nvc_name); +} + +static void +run_case_name(const char *name) +{ + int i; + + for (i = 0; i < nitems(test_cases); i++) { + if (strcmp(name, test_cases[i].nvc_name) == 0) { + run_case(&test_cases[i]); + return; + } + } + fprintf(stderr, "unknown test: '%s'\n", name); + exit(1); +} + +/* CSTYLED */ +#define NVP_EQUAL_TYPE(type, name) __extension__({ \ + bool is_equal; \ + type a, b; \ + nvpair_value_##name(nvp_a, &a); \ + nvpair_value_##name(nvp_b, &b); \ + is_equal = (a == b); \ + is_equal; \ +}) + +/* CSTYLED */ +#define NVP_EQUAL_TYPE_ARRAY(type, name) __extension__({ \ + bool is_equal; \ + type *a, *b; \ + uint_t nelem_a, nelem_b; \ + nvpair_value_##name##_array(nvp_a, &a, &nelem_a); \ + nvpair_value_##name##_array(nvp_b, &b, &nelem_b); \ + is_equal = (nelem_a == nelem_b); \ + if (is_equal) \ + for (uint_t i = 0; i < nelem_a; i++) \ + if (a[i] != b[i]) { \ + is_equal = false; \ + break; \ + } \ + is_equal; \ +}) + +static bool +nvpair_value_equal(nvpair_t *nvp_a, nvpair_t *nvp_b) +{ + if (nvpair_type(nvp_a) != nvpair_type(nvp_b)) { + if (verbose >= 2) + printf("%s: pair types differ\n", __func__); + return (false); + } + switch (nvpair_type(nvp_a)) { + case DATA_TYPE_BOOLEAN: + return (true); /* Presence is the value */ + + case DATA_TYPE_BOOLEAN_VALUE: + if (NVP_EQUAL_TYPE(boolean_t, boolean_value)) + return (true); + break; + case DATA_TYPE_BYTE: + if (NVP_EQUAL_TYPE(uchar_t, byte)) + return (true); + break; + case DATA_TYPE_INT8 : + if (NVP_EQUAL_TYPE(int8_t, int8)) + return (true); + break; + case DATA_TYPE_UINT8: + if (NVP_EQUAL_TYPE(uint8_t, uint8)) + return (true); + break; + case DATA_TYPE_INT16: + if (NVP_EQUAL_TYPE(int16_t, int16)) + return (true); + break; + case DATA_TYPE_UINT16: + if (NVP_EQUAL_TYPE(uint16_t, uint16)) + return (true); + break; + case DATA_TYPE_INT32: + if (NVP_EQUAL_TYPE(int32_t, int32)) + return (true); + break; + case DATA_TYPE_UINT32: + if (NVP_EQUAL_TYPE(uint32_t, uint32)) + return (true); + break; + case DATA_TYPE_INT64: + if (NVP_EQUAL_TYPE(int64_t, int64)) + return (true); + break; + case DATA_TYPE_UINT64: + if (NVP_EQUAL_TYPE(uint64_t, uint64)) + return (true); + break; + case DATA_TYPE_HRTIME: + if (NVP_EQUAL_TYPE(hrtime_t, hrtime)) + return (true); + break; + case DATA_TYPE_DOUBLE: + if (NVP_EQUAL_TYPE(double, double)) + return (true); + break; + + case DATA_TYPE_BOOLEAN_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(boolean_t, boolean)) + return (true); + break; + case DATA_TYPE_BYTE_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(uchar_t, byte)) + return (true); + break; + case DATA_TYPE_INT8_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(int8_t, int8)) + return (true); + break; + case DATA_TYPE_UINT8_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(uint8_t, uint8)) + return (true); + break; + case DATA_TYPE_INT16_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(int16_t, int16)) + return (true); + break; + case DATA_TYPE_UINT16_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(uint16_t, uint16)) + return (true); + break; + case DATA_TYPE_INT32_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(int32_t, int32)) + return (true); + break; + case DATA_TYPE_UINT32_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(uint32_t, uint32)) + return (true); + break; + case DATA_TYPE_INT64_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(int64_t, int64)) + return (true); + break; + case DATA_TYPE_UINT64_ARRAY: + if (NVP_EQUAL_TYPE_ARRAY(uint64_t, uint64)) + return (true); + break; + + case DATA_TYPE_STRING: { + char *str_a, *str_b; + nvpair_value_string(nvp_a, &str_a); + nvpair_value_string(nvp_b, &str_b); + if (strcmp(str_a, str_b) == 0) + return (true); + break; + } + case DATA_TYPE_STRING_ARRAY: { + char **stra_a, **stra_b; + uint_t nelem_a, nelem_b; + nvpair_value_string_array(nvp_a, &stra_a, &nelem_a); + nvpair_value_string_array(nvp_b, &stra_b, &nelem_b); + if (nelem_a != nelem_b) + goto not_equal; + for (int i = 0; i < nelem_a; i++) { + if (strcmp(stra_a[i], stra_b[i]) != 0) + goto not_equal; + } + return (true); + } + + case DATA_TYPE_NVLIST: { + nvlist_t *nvl_a, *nvl_b; + nvpair_value_nvlist(nvp_a, &nvl_a); + nvpair_value_nvlist(nvp_b, &nvl_b); + if (nvlist_equal(nvl_a, nvl_b)) + return (true); + break; + } + case DATA_TYPE_NVLIST_ARRAY: { + nvlist_t **nvla_a, **nvla_b; + uint_t nelem_a, nelem_b; + nvpair_value_nvlist_array(nvp_a, &nvla_a, &nelem_a); + nvpair_value_nvlist_array(nvp_b, &nvla_b, &nelem_b); + if (nelem_a != nelem_b) + goto not_equal; + for (int i = 0; i < nelem_a; i++) { + if (!nvlist_equal(nvla_a[i], nvla_b[i])) + goto not_equal; + } + return (true); + } + + case DATA_TYPE_DONTCARE: + case DATA_TYPE_UNKNOWN: + if (verbose >= 2) + printf("%s: unhandled type %d\n", __func__, + nvpair_type(nvp_a)); + return (false); + } + +not_equal: + if (verbose >= 2) + printf("%s: values are not equal\n", __func__); + return (false); +} +#undef NVP_EQUAL_TYPE +#undef NVP_EQUAL_TYPE_ARRAY + +static bool +nvpair_equal(nvpair_t *nvp_a, nvpair_t *nvp_b) +{ + if (strcmp(nvpair_name(nvp_a), nvpair_name(nvp_b)) != 0) { + if (verbose >= 2) + printf("%s: pair names differ\n", __func__); + return (false); + } + return (nvpair_value_equal(nvp_a, nvp_b)); +} + +/* + * nvlist_equal - check if two nvlists are equal. + * + * Each pair be present in each list and they must appear in the same + * order. While ordering does not matter from an API perspective, it + * must hold for the packed forms to be identical. + */ +static bool +nvlist_equal(nvlist_t *nvl_a, nvlist_t *nvl_b) +{ + nvpair_t *nvp_a, *nvp_b; + + if (fnvlist_num_pairs(nvl_a) != fnvlist_num_pairs(nvl_b)) + return (false); + + if (verbose >= 3) { + nvpair_t *pair; + pair = NULL; + printf("dumping nvp_a\n"); + while ((pair = nvlist_next_nvpair(nvl_a, pair)) != NULL) + printf("'%s'\n", nvpair_name(pair)); + printf("dumping nvp_b\n"); + while ((pair = nvlist_next_nvpair(nvl_b, pair)) != NULL) + printf("'%s'\n", nvpair_name(pair)); + } + + for (nvp_a = nvlist_next_nvpair(nvl_a, NULL), + nvp_b = nvlist_next_nvpair(nvl_b, NULL); + nvp_a != NULL && nvp_b != NULL; + nvp_a = nvlist_next_nvpair(nvl_a, nvp_a), + nvp_b = nvlist_next_nvpair(nvl_b, nvp_b)) { + if (!nvpair_equal(nvp_a, nvp_b)) + return (false); + } + if (nvp_a == NULL && nvp_b == NULL) + return (true); + + return (false); +} + +int +main(int argc, char **argv) +{ + int i, opt; + bool list, run_all; + + list = run_all = false; + + while ((opt = getopt(argc, argv, "alr:Rvx")) != -1) { + switch (opt) { + case 'a': + run_all = true; + break; + case 'l': + list = true; + break; + case 'r': + refdir = optarg; + break; + case 'R': + genrefs = true; + break; + case 'v': + verbose++; + break; + case 'x': + ref_match_exact = true; + break; + default: + fprintf(stderr, "unknown argument %c\n", opt); + usage(); + } + } + argc -= optind; + argv += optind; + if (run_all && list) { + fprintf(stderr, "-a and -l are incompatible\n"); + usage(); + } + if (list && genrefs) { + fprintf(stderr, "-l and -R are incompatible\n"); + usage(); + } + if (list && refdir != NULL) { + fprintf(stderr, "-l and -r are incompatible\n"); + usage(); + } + if (list) { + if (argc == 0) + list_tests(); + fprintf(stderr, "-l and a list of test are incompatible\n"); + usage(); + } + if (argc == 0 && !run_all) + usage(); + if (argc > 0 && run_all) { + fprintf(stderr, "-a and a list of cases are incompatible\n"); + usage(); + } + + if (refdir != NULL) { +#ifdef O_PATH + const int o_path_flag = O_PATH; +#else + const int o_path_flag = O_RDONLY; +#endif + + refdir_fd = open(refdir, O_DIRECTORY | O_CLOEXEC | o_path_flag); + if (refdir_fd == -1) { + fprintf(stderr, "Failed to open refdir %s: %s\n", + refdir, strerror(errno)); + exit(1); + } + } + + init_nvlists(); + + if (run_all) { + for (i = 0; i < nitems(test_cases); i++) + run_case(&test_cases[i]); + } else { + for (i = 0; i < argc; i++) + run_case_name(argv[i]); + } + + if (verbose > 0 && tests_failed > 0) { + printf("Unexpected failures:\n"); + for (i = 0; i < nitems(test_cases); i++) { + if (test_cases[i].nvc_failure_reason != NULL) { + printf("\t%s: %s\n", test_cases[i].nvc_name, + test_cases[i].nvc_failure_reason); + } + } + } + if (verbose >= 0) { + printf("SUMMARY"); + if (tests_run - tests_failed > 0) + printf(": passed %d", tests_run - tests_failed); + if (tests_failed > 0) + printf(": failed %d", tests_failed); + printf("\n"); + } + + return (tests_failed); +} From e84894d2db5760a4299a19eefa79bac8fe38b302 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Mon, 7 Nov 2022 22:24:54 +0000 Subject: [PATCH 2/2] Hook up nvlist XDR packing test Add a new functional test that runs nvlist_packed for all flags and verifies packed verions against committed XDR streams generated on FreeBSD amd64. Streams should be stable on all platforms supported today. Signed-off-by: Brooks Davis --- tests/runfiles/common.run | 4 + tests/runfiles/sanity.run | 4 + tests/zfs-tests/include/commands.cfg | 1 + tests/zfs-tests/tests/Makefile.am | 75 ++++++++++++++++++ .../tests/functional/libnvpair/cleanup.ksh | 34 ++++++++ .../tests/functional/libnvpair/packed.ksh | 48 +++++++++++ .../functional/libnvpair/refs/boolean.ref | Bin 0 -> 52 bytes .../libnvpair/refs/boolean_array.ref | Bin 0 -> 76 bytes .../libnvpair/refs/boolean_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/boolean_array_single.ref | Bin 0 -> 68 bytes .../libnvpair/refs/boolean_flag.ref | Bin 0 -> 52 bytes .../tests/functional/libnvpair/refs/byte.ref | Bin 0 -> 48 bytes .../functional/libnvpair/refs/byte_array.ref | Bin 0 -> 56 bytes .../libnvpair/refs/byte_array_empty.ref | Bin 0 -> 56 bytes .../libnvpair/refs/byte_array_single.ref | Bin 0 -> 64 bytes .../functional/libnvpair/refs/double.ref | Bin 0 -> 56 bytes .../functional/libnvpair/refs/empty_name.ref | Bin 0 -> 40 bytes .../functional/libnvpair/refs/hrtime.ref | Bin 0 -> 56 bytes .../tests/functional/libnvpair/refs/int16.ref | Bin 0 -> 52 bytes .../functional/libnvpair/refs/int16_array.ref | Bin 0 -> 72 bytes .../libnvpair/refs/int16_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/int16_array_single.ref | Bin 0 -> 68 bytes .../tests/functional/libnvpair/refs/int32.ref | Bin 0 -> 52 bytes .../functional/libnvpair/refs/int32_array.ref | Bin 0 -> 72 bytes .../libnvpair/refs/int32_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/int32_array_single.ref | Bin 0 -> 68 bytes .../tests/functional/libnvpair/refs/int64.ref | Bin 0 -> 56 bytes .../functional/libnvpair/refs/int64_array.ref | Bin 0 -> 88 bytes .../libnvpair/refs/int64_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/int64_array_single.ref | Bin 0 -> 72 bytes .../tests/functional/libnvpair/refs/int8.ref | Bin 0 -> 48 bytes .../functional/libnvpair/refs/int8_array.ref | Bin 0 -> 72 bytes .../libnvpair/refs/int8_array_empty.ref | Bin 0 -> 60 bytes .../libnvpair/refs/int8_array_single.ref | Bin 0 -> 68 bytes .../functional/libnvpair/refs/nvlist0.ref | Bin 0 -> 232 bytes .../functional/libnvpair/refs/nvlist1.ref | Bin 0 -> 308 bytes .../functional/libnvpair/refs/nvlist2.ref | Bin 0 -> 384 bytes .../functional/libnvpair/refs/nvlist3.ref | Bin 0 -> 460 bytes .../libnvpair/refs/nvlist_array.ref | Bin 0 -> 1244 bytes .../libnvpair/refs/nvlist_array_empty.ref | Bin 0 -> 60 bytes .../libnvpair/refs/nvlist_array_single.ref | Bin 0 -> 244 bytes .../functional/libnvpair/refs/string_.ref | Bin 0 -> 52 bytes .../functional/libnvpair/refs/string_0.ref | Bin 0 -> 56 bytes .../functional/libnvpair/refs/string_01.ref | Bin 0 -> 60 bytes .../functional/libnvpair/refs/string_012.ref | Bin 0 -> 60 bytes .../functional/libnvpair/refs/string_0123.ref | Bin 0 -> 60 bytes .../libnvpair/refs/string_01234.ref | Bin 0 -> 64 bytes .../libnvpair/refs/string_012345.ref | Bin 0 -> 68 bytes .../libnvpair/refs/string_0123456.ref | Bin 0 -> 68 bytes .../libnvpair/refs/string_01234567.ref | Bin 0 -> 68 bytes .../libnvpair/refs/string_012345678.ref | Bin 0 -> 72 bytes .../libnvpair/refs/string_0123456789.ref | Bin 0 -> 76 bytes .../libnvpair/refs/string_0123456789a.ref | Bin 0 -> 76 bytes .../libnvpair/refs/string_0123456789ab.ref | Bin 0 -> 76 bytes .../libnvpair/refs/string_0123456789abc.ref | Bin 0 -> 80 bytes .../libnvpair/refs/string_0123456789abcd.ref | Bin 0 -> 84 bytes .../libnvpair/refs/string_0123456789abcde.ref | Bin 0 -> 84 bytes .../refs/string_0123456789abcdef.ref | Bin 0 -> 84 bytes .../refs/string_0123456789abcdefg.ref | Bin 0 -> 88 bytes .../libnvpair/refs/string_array.ref | Bin 0 -> 92 bytes .../libnvpair/refs/string_array_empty.ref | Bin 0 -> 60 bytes .../libnvpair/refs/string_array_single.ref | Bin 0 -> 68 bytes .../functional/libnvpair/refs/uint16.ref | Bin 0 -> 52 bytes .../libnvpair/refs/uint16_array.ref | Bin 0 -> 72 bytes .../libnvpair/refs/uint16_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/uint16_array_single.ref | Bin 0 -> 68 bytes .../functional/libnvpair/refs/uint32.ref | Bin 0 -> 52 bytes .../libnvpair/refs/uint32_array.ref | Bin 0 -> 72 bytes .../libnvpair/refs/uint32_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/uint32_array_single.ref | Bin 0 -> 68 bytes .../functional/libnvpair/refs/uint64.ref | Bin 0 -> 56 bytes .../libnvpair/refs/uint64_array.ref | Bin 0 -> 88 bytes .../libnvpair/refs/uint64_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/uint64_array_single.ref | Bin 0 -> 72 bytes .../tests/functional/libnvpair/refs/uint8.ref | Bin 0 -> 52 bytes .../functional/libnvpair/refs/uint8_array.ref | Bin 0 -> 72 bytes .../libnvpair/refs/uint8_array_empty.ref | Bin 0 -> 64 bytes .../libnvpair/refs/uint8_array_single.ref | Bin 0 -> 68 bytes .../tests/functional/libnvpair/setup.ksh | 37 +++++++++ 79 files changed, 203 insertions(+) create mode 100644 tests/zfs-tests/tests/functional/libnvpair/cleanup.ksh create mode 100644 tests/zfs-tests/tests/functional/libnvpair/packed.ksh create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/boolean.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/boolean_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/boolean_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/boolean_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/boolean_flag.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/byte.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/byte_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/byte_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/byte_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/double.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/empty_name.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/hrtime.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int16.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int16_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int16_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int16_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int32.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int32_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int32_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int32_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int64.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int64_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int64_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int64_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int8.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int8_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int8_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/int8_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist0.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist1.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist2.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist3.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_01.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_012.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_01234.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_012345.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_01234567.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_012345678.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789a.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789ab.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abc.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abcd.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abcde.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abcdef.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abcdefg.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/string_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint16.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint32.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint64.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint8.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array_empty.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array_single.ref create mode 100644 tests/zfs-tests/tests/functional/libnvpair/setup.ksh diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 73ca699931..fe1d1213f4 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -713,6 +713,10 @@ tests = ['nopwrite_copies', 'nopwrite_mtime', 'nopwrite_negative', 'nopwrite_varying_compression', 'nopwrite_volume'] tags = ['functional', 'nopwrite'] +[tests/functional/libnvpair] +tests = ['packed'] +tags = ['functional', 'libnvpair'] + [tests/functional/online_offline] tests = ['online_offline_001_pos', 'online_offline_002_neg', 'online_offline_003_neg'] diff --git a/tests/runfiles/sanity.run b/tests/runfiles/sanity.run index f115f0b578..242e239e2f 100644 --- a/tests/runfiles/sanity.run +++ b/tests/runfiles/sanity.run @@ -490,6 +490,10 @@ tags = ['functional', 'nestedfs'] tests = ['nopwrite_sync', 'nopwrite_volume'] tags = ['functional', 'nopwrite'] +[tests/functional/libnvpair] +tests = ['packed'] +tags = ['functional', 'libnvpair'] + [tests/functional/pool_checkpoint] tests = ['checkpoint_conf_change', 'checkpoint_discard_many', 'checkpoint_removal', 'checkpoint_sm_scale', 'checkpoint_twice'] diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index b3cfe149ff..c4f32a91e7 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -203,6 +203,7 @@ export ZFSTEST_FILES='badsend mmap_seek mmap_sync mmapwrite + nvlist_packed nvlist_to_lua randfree_file randwritecomp diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index 39eb44f731..12ec842844 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -334,6 +334,78 @@ nobase_dist_datadir_zfs_tests_tests_DATA += \ functional/mv_files/mv_files_common.kshlib \ functional/nopwrite/nopwrite.shlib \ functional/no_space/enospc.cfg \ + functional/libnvpair/refs/boolean_flag.ref \ + functional/libnvpair/refs/byte.ref \ + functional/libnvpair/refs/int16.ref \ + functional/libnvpair/refs/uint16.ref \ + functional/libnvpair/refs/int32.ref \ + functional/libnvpair/refs/uint32.ref \ + functional/libnvpair/refs/int64.ref \ + functional/libnvpair/refs/uint64.ref \ + functional/libnvpair/refs/string_.ref \ + functional/libnvpair/refs/string_0.ref \ + functional/libnvpair/refs/string_01.ref \ + functional/libnvpair/refs/string_012.ref \ + functional/libnvpair/refs/string_0123.ref \ + functional/libnvpair/refs/string_01234.ref \ + functional/libnvpair/refs/string_012345.ref \ + functional/libnvpair/refs/string_0123456.ref \ + functional/libnvpair/refs/string_01234567.ref \ + functional/libnvpair/refs/string_012345678.ref \ + functional/libnvpair/refs/string_0123456789.ref \ + functional/libnvpair/refs/byte_array.ref \ + functional/libnvpair/refs/string_0123456789a.ref \ + functional/libnvpair/refs/string_0123456789ab.ref \ + functional/libnvpair/refs/string_0123456789abc.ref \ + functional/libnvpair/refs/string_0123456789abcd.ref \ + functional/libnvpair/refs/string_0123456789abcde.ref \ + functional/libnvpair/refs/string_0123456789abcdef.ref \ + functional/libnvpair/refs/string_0123456789abcdefg.ref \ + functional/libnvpair/refs/byte_array_empty.ref \ + functional/libnvpair/refs/byte_array_single.ref \ + functional/libnvpair/refs/int16_array.ref \ + functional/libnvpair/refs/int16_array_empty.ref \ + functional/libnvpair/refs/int16_array_single.ref \ + functional/libnvpair/refs/uint16_array.ref \ + functional/libnvpair/refs/uint16_array_empty.ref \ + functional/libnvpair/refs/uint16_array_single.ref \ + functional/libnvpair/refs/hrtime.ref \ + functional/libnvpair/refs/int32_array.ref \ + functional/libnvpair/refs/int32_array_empty.ref \ + functional/libnvpair/refs/int32_array_single.ref \ + functional/libnvpair/refs/uint32_array.ref \ + functional/libnvpair/refs/uint32_array_empty.ref \ + functional/libnvpair/refs/uint32_array_single.ref \ + functional/libnvpair/refs/int64_array.ref \ + functional/libnvpair/refs/int64_array_empty.ref \ + functional/libnvpair/refs/int64_array_single.ref \ + functional/libnvpair/refs/uint64_array.ref \ + functional/libnvpair/refs/uint64_array_empty.ref \ + functional/libnvpair/refs/uint64_array_single.ref \ + functional/libnvpair/refs/string_array.ref \ + functional/libnvpair/refs/string_array_empty.ref \ + functional/libnvpair/refs/string_array_single.ref \ + functional/libnvpair/refs/nvlist0.ref \ + functional/libnvpair/refs/nvlist1.ref \ + functional/libnvpair/refs/nvlist2.ref \ + functional/libnvpair/refs/nvlist3.ref \ + functional/libnvpair/refs/nvlist_array.ref \ + functional/libnvpair/refs/nvlist_array_empty.ref \ + functional/libnvpair/refs/nvlist_array_single.ref \ + functional/libnvpair/refs/boolean.ref \ + functional/libnvpair/refs/int8.ref \ + functional/libnvpair/refs/uint8.ref \ + functional/libnvpair/refs/boolean_array.ref \ + functional/libnvpair/refs/boolean_array_empty.ref \ + functional/libnvpair/refs/boolean_array_single.ref \ + functional/libnvpair/refs/int8_array.ref \ + functional/libnvpair/refs/int8_array_empty.ref \ + functional/libnvpair/refs/int8_array_single.ref \ + functional/libnvpair/refs/uint8_array.ref \ + functional/libnvpair/refs/uint8_array_empty.ref \ + functional/libnvpair/refs/uint8_array_single.ref \ + functional/libnvpair/refs/double.ref \ + functional/libnvpair/refs/empty_name.ref \ functional/online_offline/online_offline.cfg \ functional/pool_checkpoint/pool_checkpoint.kshlib \ functional/projectquota/projectquota.cfg \ @@ -1538,6 +1610,9 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ functional/no_space/enospc_df.ksh \ functional/no_space/enospc_rm.ksh \ functional/no_space/setup.ksh \ + functional/libnvpair/cleanup.ksh \ + functional/libnvpair/packed.ksh \ + functional/libnvpair/setup.ksh \ functional/online_offline/cleanup.ksh \ functional/online_offline/online_offline_001_pos.ksh \ functional/online_offline/online_offline_002_neg.ksh \ diff --git a/tests/zfs-tests/tests/functional/libnvpair/cleanup.ksh b/tests/zfs-tests/tests/functional/libnvpair/cleanup.ksh new file mode 100644 index 0000000000..dc49790c99 --- /dev/null +++ b/tests/zfs-tests/tests/functional/libnvpair/cleanup.ksh @@ -0,0 +1,34 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2022 SRI International +# +# This software was developed by SRI International, the University of +# Cambridge Computer Laboratory (Department of Computer Science and +# Technology), and Capabilities Limited under Defense Advanced Research +# Projects Agency (DARPA) Contract No. HR001122C0110 ("ETC"). +# + +. $STF_SUITE/include/libtest.shlib + +log_pass diff --git a/tests/zfs-tests/tests/functional/libnvpair/packed.ksh b/tests/zfs-tests/tests/functional/libnvpair/packed.ksh new file mode 100644 index 0000000000..ef50e9a194 --- /dev/null +++ b/tests/zfs-tests/tests/functional/libnvpair/packed.ksh @@ -0,0 +1,48 @@ +#! /bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2022 SRI International +# +# This software was developed by SRI International, the University of +# Cambridge Computer Laboratory (Department of Computer Science and +# Technology), and Capabilities Limited under Defense Advanced Research +# Projects Agency (DARPA) Contract No. HR001122C0110 ("ETC"). +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Ensure that nvlists can be packed and unpacked correctly. +# +# STRATEGY: +# Run all test cases and check against reference outputs +# + +verify_runnable "both" + +log_assert "Ensure nvlist pack/unpack work" + +log_must nvlist_packed -a -r ${STF_SUITE}/tests/functional/libnvpair/refs + +log_pass "Packed nvlists round trip and compare to references" diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/boolean.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/boolean.ref new file mode 100644 index 0000000000000000000000000000000000000000..e169cf5ffab468c06f34173e9bdd3b8ba1c25a40 GIT binary patch literal 52 hcmZQ%WIzTAKn@7AC*|koq$cJ8nGB*p3{nMG2>?@r13>@) literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/boolean_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/boolean_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..a66f023f289dfce7b6de0d81317741cc7440db5e GIT binary patch literal 76 qcmZQ%WIzTMK#ll`+=B4MP0>veO7^DM+flLMl05#JH(EtDd literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/boolean_flag.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/boolean_flag.ref new file mode 100644 index 0000000000000000000000000000000000000000..019f6b4e858fd7cdf5ab05530d1d0d10128e3e09 GIT binary patch literal 52 gcmZQ%WIzTAKn@7=B<1Jlq$cLYr{yH31NkVb0C*M!DF6Tf literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/byte.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/byte.ref new file mode 100644 index 0000000000000000000000000000000000000000..8f021bb1fd743e7c4b4fcc6989bd7bed9bfde7b3 GIT binary patch literal 48 gcmZQ%WIzToK#l?svm{lPqylLsAO@*O1Y$4%05TT>TL1t6 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/byte_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/byte_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..20191e4259190646966b2b0cf814150109105b88 GIT binary patch literal 56 ocmZQ%WIzTgK#m3wb0t-lq{b%}6(v@JrMZA4OJY)T3YZ5Z0Fk=}BLDyZ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/byte_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/byte_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..d1eed756508f17e69eb5f9ac75bebc5a8a262c1e GIT binary patch literal 56 ncmZQ%WIzTgK#m3w3nW#Rq{b%}6(v^2r{)%vR074gkQD*|vv~(8 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/byte_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/byte_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..d94b7683144d0d1412a2252781eacc47ce8c4ffb GIT binary patch literal 64 tcmZQ%WIzTwK#lTq{b%}6(v^27iZ?B=cGbZaRDjDL1aJT_ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/hrtime.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/hrtime.ref new file mode 100644 index 0000000000000000000000000000000000000000..ee20de286674154838b4b1bbaad70365d337c2f3 GIT binary patch literal 56 gcmZQ%WIzTgK#l?svt<;OWag%VrG$Vasw$uW09ZN#=>Px# literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int16.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int16.ref new file mode 100644 index 0000000000000000000000000000000000000000..411a9f2ad9df11f1e3f154ac624a60c8968d0249 GIT binary patch literal 52 dcmZQ%WIzTAKn@7AX6BU`ngJO=zzoDFssJ|Q0sa60 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int16_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int16_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..0ae965558d4ba3839ea89e1e8cb0ebf2c9d5e2f5 GIT binary patch literal 72 ucmZQ%WIzTcK#m3wb7$t27@EZ=78NB{g5t7L2QdHu literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int16_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int16_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..61389231b5f11b27b83f5b1aee61065c0216ebdd GIT binary patch literal 68 rcmZQ%WIzT6Kn@5CW#*L_n#Cs;6(v^27iZ?B=cIy_aRW(^4isGg5fTTJ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int32.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int32.ref new file mode 100644 index 0000000000000000000000000000000000000000..254e0bc38484161730d4750a05556e57ff2f407b GIT binary patch literal 52 dcmZQ%WIzTAKn@7AX6BU`8vz+0HV~tz0suDG0sa60 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int32_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int32_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..e908ca2743939d3ff71ac7b34cc446b85051810a GIT binary patch literal 72 ucmZQ%WIzTcK#lt6+2QdHu literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int32_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int32_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..6f82c2108e45fc96f3c97cbdac85bab5e7d3a5c8 GIT binary patch literal 68 rcmZQ%WIzT6Kn@5CW#*L_8^tFU6(v^27iZ?B=cIy_@d8PZ4isGg5bg() literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int64.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int64.ref new file mode 100644 index 0000000000000000000000000000000000000000..503a97b2fae5eaa71d52b3cb328b3acbb199accc GIT binary patch literal 56 fcmZQ%WIzTgK#l?svu5U%n3+Ii*nt$PDxd%WKr8|Y literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int64_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int64_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..68d1b43a83357fd3727082443c53f3b72180706e GIT binary patch literal 88 ucmZQ%WIzTkK#l_tb7$t2n3=>U78NB{g5>#um<5VKd>DY~X8I2WFbM#MnGDwe literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int64_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int64_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..31d50ff1bcc47b57bb4542f41357bad24da097f0 GIT binary patch literal 64 pcmZQ%WIzTwK#m3w3ufk(n3=>U78NB{#;4{MlvF}g@gpk+u>t9W2RHx# literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int64_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int64_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..eaeb0de9f99d50110c641a8493af92600af6a71a GIT binary patch literal 72 ucmZQ%WIzTcK#lU78NB{#usPirRSuAmGJ{fkPcK`Kmhvbe6@u6R%YFw7 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/int8_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/int8_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..40d4a6d24b7c39fd4cef1e0b8c0d3b29dc6ffc60 GIT binary patch literal 68 qcmZQ%WIzT6Kn@5CX6BVx#3vRNC0524XXd5nq(W3l0x6IV6kPxi83%Cy literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist0.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist0.ref new file mode 100644 index 0000000000000000000000000000000000000000..8a29be67013a706d98e7b4b3902cfcae13c12900 GIT binary patch literal 232 zcmZ9F!3x4a3`DcyZt?8ZLk=E1ii-bZvB*N%gH4P6r~jibvITMAF*772A;_;@lszhoY8WexL|yH;W@*X}_<5$2r@Sz*~et-}}Kvlg_H#$4=ppot_1Z-j3_f!lUI5l{o) adEMF371Ch$Ty7+h75I-hUHZ|V{_6w9S{^I_ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist1.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist1.ref new file mode 100644 index 0000000000000000000000000000000000000000..dc355f8a502b01719c0044cd8ddbdfb602829284 GIT binary patch literal 308 zcmb8p%?iRW48ZYJY=>vB9&+&D(T}nBaX6$fdT`y)_w;@AAE~g52LnHn(2&$QnT1oD zJ*qVIamWWsS>ropSqmT2rMuG*9`p&773IrY+CeY9>n|T`yoQynSo(C%D-TU=)d>?O2sey literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..93561ac89f6ccbbe0c92235c705f2faca252b491 GIT binary patch literal 1244 zcmeH`%L;-(6o$w0LeQ?3EoRZ8WjA`AP?8YDg^rSM)8q62y-$5d4I~V47t{}*a}MV? zGyXGLmTJkqkz8S#6mgW9qo1aJNj?V~MDm7iaH8ZCUPzDwuh|yF8tkAnA>#<77JzPW z^C&U9Etyg-SP#Uw1P#n>4toORK~-;hR^%Go%%o9rCQ@nwvW8RmaW0F#Nou;GYu{48 z!y3H$`z2H}keaA(4(a*EZl3%m4rY literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..e27fbf98ac253a61f2012221d9b44f9262974afd GIT binary patch literal 60 ocmZQ%WIzTQKn@5C<(1`R7MH{)78NB{#;4{MlvIM1i6AQm0OW)SB>(^b literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/nvlist_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..b20a194365db211c34480170cdd0b2e343290b15 GIT binary patch literal 244 zcmYk0O$x#=5JnR*5!bqOk%bG_DxSexloX2uLKaP0>}|b?z9}j6gU8I5`N?Rl*7{OL4`VCgxLJJ_~Ukp&x&S_`gXhmgwcic`vh o{vqNS9I(4Q?j&djbG`Ol@D6M)Jx7u$wFmjbj6M$Y)$+R1A5-Nci~s-t literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_.ref new file mode 100644 index 0000000000000000000000000000000000000000..325938256eb6dc5c4f29dc4152cff6f21b74a601 GIT binary patch literal 52 fcmZQ%WIzTAKn@7A7nc-e=B392nGBpjjG_tvRV)Ka literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0.ref new file mode 100644 index 0000000000000000000000000000000000000000..860cf3d071d24b6795e155e83c6b3449f99689e6 GIT binary patch literal 56 kcmZQ%WIzTgK#m3wa}<{pW#*;F8vxmyKnzmF2;#s10Bb%2xBvhE literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_01.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_01.ref new file mode 100644 index 0000000000000000000000000000000000000000..5c6724102cd897b61de65b507d2693429845ffd8 GIT binary patch literal 60 lcmZQ%WIzTQKn@6V7MB!d=B39Q7(!$@ffPt36HEXk3;==?D01^ZMkR}A~ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_01234.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_01234.ref new file mode 100644 index 0000000000000000000000000000000000000000..70d1748939d54034cd1399e23f35ce28daa9ba26 GIT binary patch literal 64 qcmZQ%WIzTwK#m3w^Awj9W#*;F8yFfHn*jNoKnzmJ3KIab!2kfQFa=xy literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_012345.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_012345.ref new file mode 100644 index 0000000000000000000000000000000000000000..800d18e723ad5bae5da2adf1481ce90f0f516696 GIT binary patch literal 68 qcmZQ%WIzT6K#m3w^A?vBW#*;F8yFfHo0vjWZ~`fiYBpp+kQ4yObp^}- literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456.ref new file mode 100644 index 0000000000000000000000000000000000000000..d80bae7103923daed0ad8a8ee6dccf5a1dde0b13 GIT binary patch literal 68 rcmZQ%WIzT6K#m3w^A(pAW#*;F8yFfHo0yt`m2d({kZN{hL68gp(OCvM literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_01234567.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_01234567.ref new file mode 100644 index 0000000000000000000000000000000000000000..ff971aef05ccd99321eadfa6783c8a2c26f9b07f GIT binary patch literal 68 rcmZQ%WIzT6Kn@7=7nc-e=B39Q7#bOyn3|b`)NleZNHqttAV>lL+kghL literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_012345678.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_012345678.ref new file mode 100644 index 0000000000000000000000000000000000000000..d6344c11946051b78b1cb7f0b22dd1a4ea60d84a GIT binary patch literal 72 tcmZQ%WIzTcK#m0v3lx_WW#*;F8yFfHo0yuJgTy$27^IpLSrEtv0{{a72QUBt literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789.ref new file mode 100644 index 0000000000000000000000000000000000000000..6488575d835270708b06e081ec6af62ea2d62914 GIT binary patch literal 76 tcmZQ%WIzTMKn@5C7MB!d=B39Q7#bOyn3|beSVB~B0x6IVE_4ZyGyo&o2dDr5 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789a.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789a.ref new file mode 100644 index 0000000000000000000000000000000000000000..c693671ed52295068d5c934ba73edca742d7be40 GIT binary patch literal 76 ucmZQ%WIzTMKn@5C6_*rc=B39Q7#bOyn3|beSSEs%aRNz@4sLV_kSqW-F$in` literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789ab.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789ab.ref new file mode 100644 index 0000000000000000000000000000000000000000..2eaade3c167a6e7bdfd55777833770f5c581f60c GIT binary patch literal 76 vcmZQ%WIzTMKn@5C7nc-e=B39Q7#bOyn3|beSSBWc)NukaNCywP1V|D9MezwT literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abc.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abc.ref new file mode 100644 index 0000000000000000000000000000000000000000..8db35412b9ddcabdea9c6495942079da4c76a29f GIT binary patch literal 80 ycmZQ%WIzTsK#m0vixig>W#*;F8yFfHo0yuJTUaJ0B?HAdff%HN7hM7<1_l6s0tx;A literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abcd.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_0123456789abcd.ref new file mode 100644 index 0000000000000000000000000000000000000000..2bba00dc315f97fbf8970f07844673c136ae1f73 GIT binary patch literal 84 ycmZQ%WIzTEK#m0vix!s@W#*;F8yFfHo0yuJTUaJ0C8t1CasnxkE24GIg| literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..a47a74f1308ec54a149ef815b822a0a97c5bc317 GIT binary patch literal 60 ocmZQ%WIzTQKn@5C6_*rc=B39c78NB{#;4{MlvIM12_h>70OMo`82|tP literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/string_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/string_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..86eddce6f03fd4527b2cc404c8ef7690ad70b236 GIT binary patch literal 68 vcmZQ%WIzT6K#m0v3m2CZW#*;FCl(bYR>l_tnK`K-b%H<)(!rPr;z0obHbDsJ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint16.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint16.ref new file mode 100644 index 0000000000000000000000000000000000000000..0ac7b54bbb4f8a7a7873eb18ebbb3119c2d31590 GIT binary patch literal 52 fcmZQ%WIzTAKn@7Am1gFZ7@7fD3=AwljG_tvLMsAw literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..37168018d90c99a12748620ca2bba5a72dafd457 GIT binary patch literal 72 vcmZQ%WIzTcK#m3w^OR=hl^B}ECl(bYR)Y9I%mT$giUFjH35frLI3NH3=aL2{ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..e31d698e26b1cb275143d30cfebe61b27af31e74 GIT binary patch literal 64 qcmZQ%WIzTwK#m3w3zcT(l^B}ECl(bYR>r617L-(imGK}e2C)J3k_V^& literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint16_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..3722cc114275bcfeee6401e37cc7e6fc9ffa3101 GIT binary patch literal 68 scmZQ%WIzT6Kn@5CmuBXb7@EZ=78NB{#usPirRSuA)bRi@NC%2803Kfm3IG5A literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint32.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint32.ref new file mode 100644 index 0000000000000000000000000000000000000000..2773cc71ebb63f1aedbe79bcca95369b9cefa119 GIT binary patch literal 52 ecmZQ%WIzTAKn@7Am1gFZ7#jguKsFGgr~&{&Ap&&( literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..257accf94fb599e91915c62c0ac22f573417c617 GIT binary patch literal 72 wcmZQ%WIzTcK#lr617L-(imGL1f2C)J3a0jRW literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint32_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..48e74f046bb2b142a7f73ba36e21cc0454d61b1e GIT binary patch literal 68 scmZQ%WIzT6Kn@5CmuBXb7#qbW78NB{#usPirRSuA)bRl^NC%2803JOE3IG5A literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint64.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint64.ref new file mode 100644 index 0000000000000000000000000000000000000000..5cf66821f9e93aa1e9f26b904059b75c7fccb271 GIT binary patch literal 56 gcmZQ%WIzTgK#l?svz2D%m6(};r8s~jsw$uW08LE-fB*mh literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..dfceee2f151a250f7a29d075dec32d3d9b3f7a4f GIT binary patch literal 88 vcmZQ%WIzTkK#l_t^OR=hm6(~tCl(bYRs#6~K+FQgKnf0Ex|#k%0Zaw}p%@KL literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint64_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..f2632fbe0d23fdf328d5226600d335c2d7fb905e GIT binary patch literal 64 qcmZQ%WIzTwK#m3w3zcT(m6(~tCl(bYR>r617L-(il?fm#2C)J4Ll`+=B4MPg478BF-QlhE}#GaKvf78 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint8.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint8.ref new file mode 100644 index 0000000000000000000000000000000000000000..d051cccfe99dd62212746f3795b165220d51e4ad GIT binary patch literal 52 dcmZQ%WIzTAKn@7AmS*OaSO6J7AP&SRssKM90$2b5 literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array.ref new file mode 100644 index 0000000000000000000000000000000000000000..23418e847dab986bad357d5e51ce3a38977465dd GIT binary patch literal 72 ucmZQ%WIzTcK#m3wbC+i3l~}|l78NB{g5;%um<5VKe2^}t|3CoZfB*mly$JyT literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array_empty.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array_empty.ref new file mode 100644 index 0000000000000000000000000000000000000000..a69446d7346d0ee802393fc6ae11d90ed94c6325 GIT binary patch literal 64 pcmZQ%WIzTwK#m3w3zlZ)l~}|l78NB{#;4{MlvF}gNg*o+u>te_2ZjIu literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array_single.ref b/tests/zfs-tests/tests/functional/libnvpair/refs/uint8_array_single.ref new file mode 100644 index 0000000000000000000000000000000000000000..cf69f38a69dd1543d71206e9e2976f5998317774 GIT binary patch literal 68 rcmZQ%WIzT6Kn@5Cm1gFZSi~n56(v^27iZ?B=cIy_NdZZa4isGg9hC>@ literal 0 HcmV?d00001 diff --git a/tests/zfs-tests/tests/functional/libnvpair/setup.ksh b/tests/zfs-tests/tests/functional/libnvpair/setup.ksh new file mode 100644 index 0000000000..c8a0bcd27b --- /dev/null +++ b/tests/zfs-tests/tests/functional/libnvpair/setup.ksh @@ -0,0 +1,37 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2022 SRI International +# +# This software was developed by SRI International, the University of +# Cambridge Computer Laboratory (Department of Computer Science and +# Technology), and Capabilities Limited under Defense Advanced Research +# Projects Agency (DARPA) Contract No. HR001122C0110 ("ETC"). +# + +. $STF_SUITE/include/libtest.shlib + +# No setup required, test is self contained other than committed reference +# files. +log_pass +