Exemple #1
0
static void
test(const char *testname, boolean_t expect_success, boolean_t expect_match)
{
	char *progstr = "input = ...; return {output=input}";

	nvlist_t *outnvl;

	(void) printf("\nrunning test '%s'; input:\n", testname);
	dump_nvlist(nvl, 4);

	int err = lzc_channel_program(pool, progstr,
	    10 * 1000 * 1000, 10 * 1024 * 1024, nvl, &outnvl);

	(void) printf("lzc_channel_program returned %u\n", err);
	dump_nvlist(outnvl, 5);

	if (err == 0 && expect_match) {
		/*
		 * Verify that outnvl is the same as input nvl, if we expect
		 * them to be. The input and output will never match if the
		 * input contains an array (since arrays are converted to lua
		 * tables), so this is only asserted for some test cases.
		 */
		nvlist_t *real_outnvl = fnvlist_lookup_nvlist(outnvl, "return");
		real_outnvl = fnvlist_lookup_nvlist(real_outnvl, "output");
		if (!nvlist_equal(nvl, real_outnvl)) {
			unexpected_failures = B_TRUE;
			(void) printf("unexpected input/output mismatch for "
			    "case: %s\n", testname);
		}
	}
	if (err != 0 && expect_success) {
		unexpected_failures = B_TRUE;
		(void) printf("unexpected FAIL of case: %s\n", testname);
	}

	fnvlist_free(nvl);
	nvl = fnvlist_alloc();
}
Exemple #2
0
static void
dltran_verbose_dump(datalink_id_t linkid, uint_t tranid)
{
	uint8_t buf[256];
	size_t buflen = sizeof (buf);
	int ret;
	nvlist_t *nvl;

	if (dltran_read_page(linkid, tranid, 0xa0, buf, &buflen) != 0) {
		dltran_errors++;
		return;
	}

	ret = libsff_parse(buf, buflen, 0xa0, &nvl);
	if (ret == 0) {
		dump_nvlist(nvl, 8);
		nvlist_free(nvl);
	} else {
		fprintf(stderr, "failed to parse sfp data: %s\n",
		    strerror(ret));
		dltran_errors++;
	}
}