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 "
42 "(%s instead)", strerror(ret
));
45 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0xa1, &nvl
)) != EINVAL
) {
46 errx(1, "TEST FAILED: failed to return EINVAL on bad page "
47 "(%s instead)", strerror(ret
));
50 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0, &nvl
)) != EINVAL
) {
51 errx(1, "TEST FAILED: failed to return EINVAL on bad page "
52 "(%s instead)", strerror(ret
));
55 if ((ret
= libsff_parse(buf
, sizeof (buf
), 0xff, &nvl
)) != EINVAL
) {
56 errx(1, "TEST FAILED: failed to return EINVAL on bad page "
57 "(%s instead)", strerror(ret
));
60 if ((ret
= libsff_parse(buf
, 0, 0xa0, &nvl
)) != EINVAL
) {
61 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
62 "size (%s instead)", strerror(ret
));
65 if ((ret
= libsff_parse(buf
, 50, 0xa0, &nvl
)) != EINVAL
) {
66 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
67 "size (%s instead)", strerror(ret
));
70 buf
[SFF_8472_IDENTIFIER
] = SFF_8024_ID_QSFP
;
71 if ((ret
= libsff_parse(buf
, 0, 0xa0, &nvl
)) != EINVAL
) {
72 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
73 "size (%s instead)", strerror(ret
));
76 if ((ret
= libsff_parse(buf
, 50, 0xa0, &nvl
)) != EINVAL
) {
77 errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
78 "size (%s instead)", strerror(ret
));
81 if ((ret
= libsff_parse(buf
, 96, 0xa0, &nvl
)) != EINVAL
) {
82 errx(1, "TEST FAILED: failed to return EINVAL on bad 8635 "
83 "size (%s instead)", strerror(ret
));
86 if ((ret
= libsff_parse(buf
, 128, 0xa0, &nvl
)) != EINVAL
) {
87 errx(1, "TEST FAILED: failed to return EINVAL on bad 8635 "
88 "size (%s instead)", strerror(ret
));