2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2017, Joyent, Inc.
17 * Test various error cases all of which should return EINVAL.
35 bzero(buf
, sizeof (buf
));
36 if ((ret
= libsff_parse(NULL
, sizeof (buf
), 0xa0, &nvl
)) != EINVAL
) {
37 errx(1, "TEST FAILED: failed to return EINVAL on NULL buffer");
40 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0xa0, NULL
)) != EINVAL
) {
41 errx(1, "TEST FAILED: failed to return EINVAL on NULL nvl");
44 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0xa1, &nvl
)) != EINVAL
) {
45 errx(1, "TEST FAILED: failed to return EINVAL on bad page");
48 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0, &nvl
)) != EINVAL
) {
49 errx(1, "TEST FAILED: failed to return EINVAL on bad page");
52 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0xff, &nvl
)) != EINVAL
) {
53 errx(1, "TEST FAILED: failed to return EINVAL on bad page");
56 if ((ret
= libsff_parse(buf
, 0, 0xa0, &nvl
)) != EINVAL
) {
57 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
61 if ((ret
= libsff_parse(buf
, 50, 0xa0, &nvl
)) != EINVAL
) {
62 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
66 buf
[SFF_8472_IDENTIFIER
] = SFF_8024_ID_QSFP
;
67 if ((ret
= libsff_parse(buf
, 0, 0xa0, &nvl
)) != EINVAL
) {
68 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
72 if ((ret
= libsff_parse(buf
, 50, 0xa0, &nvl
)) != EINVAL
) {
73 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
77 if ((ret
= libsff_parse(buf
, 96, 0xa0, &nvl
)) != EINVAL
) {
78 errx(1, "TEST FAILED: failed to return EINVAL on bad 8635 "
82 if ((ret
= libsff_parse(buf
, 128, 0xa0, &nvl
)) != EINVAL
) {
83 errx(1, "TEST FAILED: failed to return EINVAL on bad 8635 "