summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-02-06 16:56:55 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-02-06 16:56:55 +0100
commitf3f392caec43b4095bc1d84b315ed7972c13c144 (patch)
tree5c4ba8b5d38f1ae33de71507c5634a15a0b35bfe /test
parent8c081c8888bccbf5adfe0fc4ec518e2cbfba9871 (diff)
parent0a70095271d845d16a3ed17354841b01f33963ad (diff)
downloadlibtdevnc-f3f392caec43b4095bc1d84b315ed7972c13c144.tar.gz
libtdevnc-f3f392caec43b4095bc1d84b315ed7972c13c144.zip
Merge tag 'LibVNCServer-0.9.12'
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am28
-rw-r--r--test/copyrecttest.c1
-rw-r--r--test/tjbench.c15
-rwxr-xr-xtest/wsmaketestframe.py131
-rw-r--r--test/wstest.c206
-rw-r--r--test/wstestdata.inc146
6 files changed, 493 insertions, 34 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index f07fc82..0000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-check_PROGRAMS =
-
-if HAVE_LIBJPEG
-# TurboJPEG wrapper tests
-check_PROGRAMS += tjunittest tjbench
-tjunittest_SOURCES=tjunittest.c ../common/turbojpeg.c ../common/turbojpeg.h \
- tjutil.c tjutil.h
-tjbench_SOURCES=tjbench.c ../common/turbojpeg.c ../common/turbojpeg.h \
- tjutil.c tjutil.h bmp.c bmp.h
-tjbench_LDADD=$(LDADD) -lm
-endif
-
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common
-LDADD = ../libvncserver/libvncserver.la ../libvncclient/libvncclient.la @WSOCKLIB@
-
-if HAVE_LIBPTHREAD
-BACKGROUND_TEST=blooptest
-ENCODINGS_TEST=encodingstest
-endif
-
-copyrecttest_LDADD=$(LDADD) -lm
-
-check_PROGRAMS += $(ENCODINGS_TEST) cargstest copyrecttest $(BACKGROUND_TEST) \
- cursortest
-
-test: encodingstest$(EXEEXT) cargstest$(EXEEXT) copyrecttest$(EXEEXT)
- ./encodingstest && ./cargstest
-
diff --git a/test/copyrecttest.c b/test/copyrecttest.c
index 3564c0e..d53c32d 100644
--- a/test/copyrecttest.c
+++ b/test/copyrecttest.c
@@ -1,4 +1,5 @@
#include <rfb/rfb.h>
+#define _USE_MATH_DEFINES
#include <math.h>
static void initBackground(rfbScreenInfoPtr server)
diff --git a/test/tjbench.c b/test/tjbench.c
index 29aa153..87e1591 100644
--- a/test/tjbench.c
+++ b/test/tjbench.c
@@ -178,7 +178,8 @@ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf,
int y=(int)((double)srcbuf[rindex]*0.299
+ (double)srcbuf[gindex]*0.587
+ (double)srcbuf[bindex]*0.114 + 0.5);
- if(y>255) y=255; if(y<0) y=0;
+ if(y>255) y=255;
+ if(y<0) y=0;
dstbuf[rindex]=abs(dstbuf[rindex]-y);
dstbuf[gindex]=abs(dstbuf[gindex]-y);
dstbuf[bindex]=abs(dstbuf[bindex]-y);
@@ -226,7 +227,8 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2)
{
- if(tilew>w) tilew=w; if(tileh>h) tileh=h;
+ if(tilew>w) tilew=w;
+ if(tileh>h) tileh=h;
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
@@ -323,7 +325,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
for(i=0; i<ntilesw*ntilesh; i++)
{
- if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;
+ if(jpegbuf[i]) {free(jpegbuf[i]); jpegbuf[i]=NULL;}
}
free(jpegbuf); jpegbuf=NULL;
free(jpegsize); jpegsize=NULL;
@@ -337,7 +339,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
{
for(i=0; i<ntilesw*ntilesh; i++)
{
- if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;
+ if(jpegbuf[i]) {free(jpegbuf[i]); jpegbuf[i]=NULL;}
}
free(jpegbuf); jpegbuf=NULL;
}
@@ -392,7 +394,8 @@ void dodecomptest(char *filename)
for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2)
{
- if(tilew>w) tilew=w; if(tileh>h) tileh=h;
+ if(tilew>w) tilew=w;
+ if(tileh>h) tileh=h;
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
@@ -455,7 +458,7 @@ void dodecomptest(char *filename)
{
for(i=0; i<ntilesw*ntilesh; i++)
{
- if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;
+ if(jpegbuf[i]) {free(jpegbuf[i]); jpegbuf[i]=NULL;}
}
free(jpegbuf); jpegbuf=NULL;
}
diff --git a/test/wsmaketestframe.py b/test/wsmaketestframe.py
new file mode 100755
index 0000000..fc03e39
--- /dev/null
+++ b/test/wsmaketestframe.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python3
+# Copyright (C)2017 Andreas Weigel. All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# - 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDERS 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.
+
+import websockets
+import base64
+
+'''
+ Create websocket frames for the wstest websocket decoding unit test.
+
+ Generates c ws_frame_test structure definitions
+ included by wstest.c.
+'''
+
+
+def add_field(s, name, value, first=False):
+ deli = ",\n\t\t"
+ if first:
+ deli = "\t\t"
+ s += "{2}.{0}={1}".format(name, value, deli)
+ return s
+
+
+class Testframe():
+ def __init__(self, frame, descr, modify_bytes={}, experrno=0, mask=True, opcode_overwrite=False):
+ self.frame = frame
+ self.descr = descr
+ self.modify_bytes = modify_bytes
+ self.experrno = experrno
+ self.b64 = True if frame.opcode == 1 or opcode_overwrite == 1 else False
+ self.mask = mask
+
+ def to_carray_initializer(self, buf):
+ values = []
+ for i in range(len(buf)):
+ values.append("0X{0:02X}".format(buf[i]))
+
+ if self.modify_bytes != {}:
+ for k in self.modify_bytes:
+ values[k] = "0X{0:02X}".format(self.modify_bytes[k])
+
+ return "{{{0}}}".format(",".join(values))
+
+
+ def set_frame_buf(self, buf):
+ self.frame_carray = self.to_carray_initializer(buf)
+ self.framelen = len(buf)
+
+ def __str__(self):
+ print("processing frame: {0}".format(self.descr))
+ the_frame = self.frame
+ if self.b64:
+ olddata = self.frame.data
+ newdata = base64.b64encode(self.frame.data)
+ #print("converting\n{0}\nto{1}\n".format(olddata, newdata))
+ the_frame = websockets.framing.Frame(self.frame.fin, self.frame.opcode, base64.b64encode(olddata))
+ websockets.framing.write_frame(the_frame, self.set_frame_buf, self.mask)
+ s = "\t{\n"
+ s = add_field(s, "frame", "{0}".format(self.frame_carray), True)
+ s = add_field(s, "expectedDecodeBuf", self.to_carray_initializer(self.frame.data))
+ s = add_field(s, "frame_len", self.framelen)
+ s = add_field(s, "raw_payload_len", len(self.frame.data))
+ s = add_field(s, "expected_errno", self.experrno)
+ s = add_field(s, "descr", "\"{0}\"".format(self.descr))
+ s = add_field(s, "i", "0")
+ s = add_field(s, "simulate_sock_malfunction_at", "0")
+ s = add_field(s, "errno_val", "0")
+ s = add_field(s, "close_sock_at", "0")
+ s += "\n\t}"
+ return s
+
+### create test frames
+flist = []
+### standard text frames with different lengths
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Testit", encoding="utf-8")), "Short valid text frame"))
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Frame2 does contain much more text and even goes beyond the 126 byte len field. Frame2 does contain much more text and even goes beyond the 126 byte len field.", encoding="utf-8")),
+ "Mid-long valid text frame"))
+#flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray([(x % 26) + 65 for x in range(100000)])), "100k text frame (ABC..YZABC..)"))
+
+### standard binary frames with different lengths
+flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray("Testit", encoding="utf-8")), "Short valid binary frame"))
+flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray("Frame2 does contain much more text and even goes beyond the 126 byte len field. Frame2 does contain much more text and even goes beyond the 126 byte len field.", encoding="utf-8")),
+ "Mid-long valid binary frame"))
+#flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray([(x % 26) + 65 for x in range(100000)])), "100k binary frame (ABC..YZABC..)"))
+
+### some conn reset frames, one with no close message, one with close message
+flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB]))), "Close frame (Reason 1003)", experrno="ECONNRESET"))
+flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB])) + bytearray("I'm a close reason and much more than that!", encoding="utf-8")), "Close frame (Reason 1003) and msg", experrno="ECONNRESET"))
+
+### invalid header values
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Testit", encoding="utf-8")), "Invalid frame: Wrong masking", experrno="EPROTO", mask=False))
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("..Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 16 bit len field", experrno="EPROTO", modify_bytes={ 1: 0xFE, 2: 0x00, 3: 0x0F}))
+flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("........Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 64 bit len field", experrno="EPROTO", modify_bytes={ 1: 0xFF, 2: 0x00, 3: 0x00, 4: 0x00, 5: 0x00, 6: 0x00, 7: 0x00, 8: 0x80, 9: 0x40}))
+
+frag1 = websockets.framing.Frame(0, 1, bytearray("This is a fragmented websocket...", encoding="utf-8"))
+frag2 = websockets.framing.Frame(0, 0, bytearray("... and it goes on...", encoding="utf-8"))
+frag3 = websockets.framing.Frame(1, 0, bytearray("and on and stop", encoding="utf-8"))
+flist.append(Testframe(frag1, "Continuation test frag1"))
+flist.append(Testframe(frag2, "Continuation test frag2", opcode_overwrite=1))
+flist.append(Testframe(frag3, "Continuation test frag3", opcode_overwrite=1))
+
+s = "struct ws_frame_test tests[] = {\n"
+for i in range(len(flist)):
+ s += flist[i].__str__()
+ if (i + 1 < len(flist)):
+ s += ","
+ s += "\n"
+s += "};\n"
+
+with open("wstestdata.inc", "w") as cdatafile:
+ cdatafile.write(s)
diff --git a/test/wstest.c b/test/wstest.c
new file mode 100644
index 0000000..042b75b
--- /dev/null
+++ b/test/wstest.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C)2017 Andreas Weigel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDERS 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.
+ */
+
+#ifndef _WIN32
+
+#include <ws_decode.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* incoming data frames should not be larger than that */
+#define TEST_BUF_SIZE B64LEN(131072) + WSHLENMAX
+
+/* seed is fixed deliberately to get reproducible test cases */
+#define RND_SEED 100
+
+enum {
+ OK,
+ FAIL_DATA,
+ FAIL_ERRNO,
+ FAIL_CLOSED,
+};
+
+const char *result_descr[] = {
+ "",
+ "Data buffers do not match",
+ "Wrong errno",
+ "Wrongly reported closed socket",
+ "Internal test error"
+};
+
+struct ws_frame_test {
+ char frame[TEST_BUF_SIZE];
+ char *pos;
+ char expectedDecodeBuf[TEST_BUF_SIZE];
+ uint64_t n_compare;
+ uint64_t frame_len;
+ uint64_t raw_payload_len;
+ int expected_errno;
+ const char *descr;
+ int ret_bytes[16];
+ int ret_bytes_len;
+ int i;
+ int simulate_sock_malfunction_at;
+ int errno_val;
+ int close_sock_at;
+};
+
+#include "wstestdata.inc"
+
+char el_log[1000000];
+char *el_pos;
+
+static void logtest(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ size_t left = el_log + sizeof(el_log) - el_pos;
+ size_t off = vsnprintf(el_pos, left, fmt, args);
+ el_pos += off;
+ va_end(args);
+}
+
+static int emu_read(void *ctx, char *dst, size_t len);
+
+static int emu_read(void *ctx, char *dst, size_t len)
+{
+ struct ws_frame_test *ft = (struct ws_frame_test *)ctx;
+ ssize_t nret;
+ int r;
+ ssize_t modu;
+
+ rfbLog("emu_read called with dst=%p and len=%lu\n", dst, len);
+ if (ft->simulate_sock_malfunction_at > 0 && ft->simulate_sock_malfunction_at == ft->i) {
+ rfbLog("simulating IO error with errno=%d\n", ft->errno_val);
+ errno = ft->errno_val;
+ return -1;
+ }
+
+ /* return something */
+ r = rand();
+ modu = (ft->frame + ft->frame_len) - ft->pos;
+ rfbLog("r=%d modu=%ld frame=%p pos=%p\n", r, modu, ft->frame, ft->pos);
+ nret = (r % modu) + 1;
+ nret = nret > len ? len : nret;
+
+ rfbLog("copy and return %ld bytes\n", nret);
+ memcpy(dst, ft->pos, nret);
+ ft->pos += nret;
+ rfbLog("leaving %s; pos=%p framebuf=%p nret=%ld\n", __func__, ft->pos, ft->frame, nret);
+ return nret;
+}
+
+static uint64_t run_test(struct ws_frame_test *ft, ws_ctx_t *ctx)
+{
+ uint64_t nleft = ft->raw_payload_len;
+ char dstbuf[ft->raw_payload_len];
+ char *dst = dstbuf;
+ ssize_t n;
+
+ ft->pos = ft->frame;
+
+ ctx->ctxInfo.ctxPtr = (void *)ft;
+
+ while (nleft > 0) {
+ rfbLog("calling ws_decode with dst=%p, len=%lu\n", dst, nleft);
+ n = ctx->decode(ctx, dst, nleft);
+ rfbLog("read n=%ld\n", n);
+ if (n == 0) {
+ if (ft->close_sock_at > 0) {
+ return OK;
+ } else {
+ return FAIL_CLOSED;
+ }
+ } else if (n < 0) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* ok, just call again */
+ } else {
+ if (ft->expected_errno == errno) {
+ rfbLog("errno=%d as expected\n", errno);
+ return OK;
+ } else {
+ rfbLog("errno=%d != expected(%d)\n", errno, ft->expected_errno);
+ return FAIL_ERRNO;
+ }
+ }
+ } else {
+ nleft -= n;
+ dst += n;
+ rfbLog("read n=%ld from decode; dst=%p, nleft=%lu\n", n, dst, nleft);
+ }
+ }
+
+ if (memcmp(ft->expectedDecodeBuf, dstbuf, ft->raw_payload_len) != 0) {
+ ft->expectedDecodeBuf[ft->raw_payload_len] = '\0';
+ dstbuf[ft->raw_payload_len] = '\0';
+ rfbLog("decoded result not equal:\nexpected:\n%s\ngot\n%s\n\n", ft->expectedDecodeBuf, dstbuf);
+ return FAIL_DATA;
+ }
+
+ return OK;
+}
+
+
+int main()
+{
+ ws_ctx_t ctx;
+ int retall= 0;
+ int i;
+ srand(RND_SEED);
+
+ hybiDecodeCleanupComplete(&ctx);
+ ctx.decode = webSocketsDecodeHybi;
+ ctx.ctxInfo.readFunc = emu_read;
+ rfbLog = logtest;
+ rfbErr = logtest;
+
+ for (i = 0; i < ARRAYSIZE(tests); i++) {
+ int ret;
+
+ /* reset output log buffer to begin */
+ el_pos = el_log;
+
+ ret = run_test(&tests[i], &ctx);
+ printf("%s: \"%s\"\n", ret == 0 ? "PASS" : "FAIL", tests[i].descr);
+ if (ret != 0) {
+ *el_pos = '\0';
+ printf("%s", el_log);
+ retall = -1;
+ }
+ }
+ return retall;
+}
+
+#else
+
+int main() {
+ return 0;
+}
+
+#endif
diff --git a/test/wstestdata.inc b/test/wstestdata.inc
new file mode 100644
index 0000000..595b891
--- /dev/null
+++ b/test/wstestdata.inc
@@ -0,0 +1,146 @@
+struct ws_frame_test tests[] = {
+ {
+ .frame={0X81,0X88,0X2F,0X2A,0X17,0X41,0X79,0X6D,0X41,0X3B,0X4B,0X6D,0X7B,0X71},
+ .expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
+ .frame_len=14,
+ .raw_payload_len=6,
+ .expected_errno=0,
+ .descr="Short valid text frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0XFE,0X00,0XD4,0X66,0X27,0XE5,0X24,0X34,0X49,0XAF,0X4C,0X04,0X70,0XB0,0X5D,0X2F,0X60,0XB7,0X52,0X3C,0X7F,0XA8,0X43,0X3F,0X15,0XDC,0X51,0X02,0X60,0XA3,0X54,0X04,0X4E,0XA7,0X50,0X02,0X70,0XAB,0X4B,0X2F,0X60,0XD4,0X52,0X05,0X4A,0XB0,0X43,0X02,0X60,0XB3,0X10,0X02,0X64,0XA7,0X4C,0X04,0X4A,0XB4,0X43,0X3C,0X7F,0XBF,0X48,0X04,0X4E,0XA7,0X4A,0X04,0X15,0XB3,0X5E,0X2F,0X60,0XAF,0X48,0X03,0X70,0XDC,0X51,0X3C,0X64,0XA7,0X14,0X07,0X60,0XB0,0X43,0X2B,0X73,0XAC,0X16,0X2F,0X60,0XAF,0X11,0X02,0X60,0XB0,0X43,0X04,0X60,0XB3,0X51,0X2F,0X60,0XBF,0X54,0X3C,0X70,0X9D,0X4F,0X2A,0X4E,0XA7,0X63,0X05,0X4A,0XA3,0X50,0X3C,0X73,0XAC,0X43,0X3C,0X60,0XDC,0X48,0X05,0X5E,0XA7,0X4E,0X04,0X15,0XD0,0X14,0X3F,0X70,0X89,0X51,0X2F,0X60,0XD4,0X15,0X3F,0X15,0X82,0X43,0X04,0X70,0XDC,0X5D,0X3C,0X74,0XA7,0X14,0X3C,0X7F,0X8D,0X14,0X2F,0X60,0XA3,0X51,0X3C,0X64,0XA7,0X48,0X02,0X4A,0XB3,0X51,0X2F,0X60,0X81,0X52,0X3C,0X7F,0XA8,0X43,0X3F,0X4A,0XB3,0X11,0X04,0X15,0XD0,0X4F,0X2F,0X6F,0XB7,0X4B,0X3C,0X74,0XA4,0X5C,0X2B,0X4D,0XBC,0X43,0X3F,0X49,0X89,0X14,0X3C,0X74,0XA7,0X57,0X3C,0X70,0XD1,0X43,0X3C,0X4A,0X89,0X48,0X04,0X60,0XB4,0X51},
+ .expectedDecodeBuf={0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E,0X20,0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E},
+ .frame_len=220,
+ .raw_payload_len=159,
+ .expected_errno=0,
+ .descr="Mid-long valid text frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X82,0X86,0XDD,0X9B,0XD8,0X56,0X89,0XFE,0XAB,0X22,0XB4,0XEF},
+ .expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
+ .frame_len=12,
+ .raw_payload_len=6,
+ .expected_errno=0,
+ .descr="Short valid binary frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X82,0XFE,0X00,0X9F,0XB5,0X6E,0X7F,0X4C,0XF3,0X1C,0X1E,0X21,0XD0,0X5C,0X5F,0X28,0XDA,0X0B,0X0C,0X6C,0XD6,0X01,0X11,0X38,0XD4,0X07,0X11,0X6C,0XD8,0X1B,0X1C,0X24,0X95,0X03,0X10,0X3E,0XD0,0X4E,0X0B,0X29,0XCD,0X1A,0X5F,0X2D,0XDB,0X0A,0X5F,0X29,0XC3,0X0B,0X11,0X6C,0XD2,0X01,0X1A,0X3F,0X95,0X0C,0X1A,0X35,0XDA,0X00,0X1B,0X6C,0XC1,0X06,0X1A,0X6C,0X84,0X5C,0X49,0X6C,0XD7,0X17,0X0B,0X29,0X95,0X02,0X1A,0X22,0X95,0X08,0X16,0X29,0XD9,0X0A,0X51,0X6C,0XF3,0X1C,0X1E,0X21,0XD0,0X5C,0X5F,0X28,0XDA,0X0B,0X0C,0X6C,0XD6,0X01,0X11,0X38,0XD4,0X07,0X11,0X6C,0XD8,0X1B,0X1C,0X24,0X95,0X03,0X10,0X3E,0XD0,0X4E,0X0B,0X29,0XCD,0X1A,0X5F,0X2D,0XDB,0X0A,0X5F,0X29,0XC3,0X0B,0X11,0X6C,0XD2,0X01,0X1A,0X3F,0X95,0X0C,0X1A,0X35,0XDA,0X00,0X1B,0X6C,0XC1,0X06,0X1A,0X6C,0X84,0X5C,0X49,0X6C,0XD7,0X17,0X0B,0X29,0X95,0X02,0X1A,0X22,0X95,0X08,0X16,0X29,0XD9,0X0A,0X51},
+ .expectedDecodeBuf={0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E,0X20,0X46,0X72,0X61,0X6D,0X65,0X32,0X20,0X64,0X6F,0X65,0X73,0X20,0X63,0X6F,0X6E,0X74,0X61,0X69,0X6E,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X65,0X78,0X74,0X20,0X61,0X6E,0X64,0X20,0X65,0X76,0X65,0X6E,0X20,0X67,0X6F,0X65,0X73,0X20,0X62,0X65,0X79,0X6F,0X6E,0X64,0X20,0X74,0X68,0X65,0X20,0X31,0X32,0X36,0X20,0X62,0X79,0X74,0X65,0X20,0X6C,0X65,0X6E,0X20,0X66,0X69,0X65,0X6C,0X64,0X2E},
+ .frame_len=167,
+ .raw_payload_len=159,
+ .expected_errno=0,
+ .descr="Mid-long valid binary frame",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X88,0X82,0X6B,0X33,0X77,0X94,0X68,0XD8},
+ .expectedDecodeBuf={0X03,0XEB},
+ .frame_len=8,
+ .raw_payload_len=2,
+ .expected_errno=ECONNRESET,
+ .descr="Close frame (Reason 1003)",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X88,0XAD,0X4B,0XA1,0XCE,0XE8,0X48,0X4A,0X87,0XCF,0X26,0X81,0XAF,0XC8,0X28,0XCD,0XA1,0X9B,0X2E,0X81,0XBC,0X8D,0X2A,0XD2,0XA1,0X86,0X6B,0XC0,0XA0,0X8C,0X6B,0XCC,0XBB,0X8B,0X23,0X81,0XA3,0X87,0X39,0XC4,0XEE,0X9C,0X23,0XC0,0XA0,0XC8,0X3F,0XC9,0XAF,0X9C,0X6A},
+ .expectedDecodeBuf={0X03,0XEB,0X49,0X27,0X6D,0X20,0X61,0X20,0X63,0X6C,0X6F,0X73,0X65,0X20,0X72,0X65,0X61,0X73,0X6F,0X6E,0X20,0X61,0X6E,0X64,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X68,0X61,0X6E,0X20,0X74,0X68,0X61,0X74,0X21},
+ .frame_len=51,
+ .raw_payload_len=45,
+ .expected_errno=ECONNRESET,
+ .descr="Close frame (Reason 1003) and msg",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0X08,0X56,0X47,0X56,0X7A,0X64,0X47,0X6C,0X30},
+ .expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
+ .frame_len=10,
+ .raw_payload_len=6,
+ .expected_errno=EPROTO,
+ .descr="Invalid frame: Wrong masking",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0XFE,0X00,0X0F,0X71,0XE9,0X29,0X79,0X44,0XA4,0X07,0X23,0X3B,0X85,0X2C,0X55,0X1D,0X9E,0X06,0X23,0X27,0X9D},
+ .expectedDecodeBuf={0X2E,0XFE,0X00,0X0F,0X72,0X65,0X20,0X49,0X70,0X73,0X75,0X6D},
+ .frame_len=22,
+ .raw_payload_len=12,
+ .expected_errno=EPROTO,
+ .descr="Invalid frame: Length of < 126 with add. 16 bit len field",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X81,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X80,0X40,0X2F,0X40,0XF3,0X5B,0X2F,0X40,0XF2,0X63,0X01,0X1A,0X8D,0X42,0X2A,0X6C,0XAB,0X59,0X00,0X1A,0X91,0X5A},
+ .expectedDecodeBuf={0X2E,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X80,0X40,0X72,0X65,0X20,0X49,0X70,0X73,0X75,0X6D},
+ .frame_len=30,
+ .raw_payload_len=18,
+ .expected_errno=EPROTO,
+ .descr="Invalid frame: Length of < 126 with add. 64 bit len field",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X01,0XAC,0XC9,0X6E,0XC7,0X6E,0X9F,0X29,0XAF,0X1E,0XAA,0X17,0X85,0X1E,0XAA,0X17,0X85,0X06,0X80,0X29,0X9D,0X17,0X90,0X39,0XA3,0X1A,0X93,0X39,0XF2,0X5E,0X93,0X39,0X96,0X09,0XAD,0X5C,0X91,0X07,0XAA,0X5C,0XFE,0X04,0XA8,0X5C,0X91,0X5E,0X85,0X07,0XF3,0X1B},
+ .expectedDecodeBuf={0X54,0X68,0X69,0X73,0X20,0X69,0X73,0X20,0X61,0X20,0X66,0X72,0X61,0X67,0X6D,0X65,0X6E,0X74,0X65,0X64,0X20,0X77,0X65,0X62,0X73,0X6F,0X63,0X6B,0X65,0X74,0X2E,0X2E,0X2E},
+ .frame_len=50,
+ .raw_payload_len=33,
+ .expected_errno=0,
+ .descr="Continuation test frag1",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X00,0X9C,0X52,0XBC,0XD5,0X99,0X1E,0XD5,0XE1,0XEC,0X1B,0XFB,0X93,0XEC,0X08,0XFF,0X97,0XE9,0X36,0XFF,0X97,0XF7,0X30,0X8E,0X83,0XE3,0X1B,0XFB,0XEC,0XEC,0X1E,0XD5,0XE1,0XEC},
+ .expectedDecodeBuf={0X2E,0X2E,0X2E,0X20,0X61,0X6E,0X64,0X20,0X69,0X74,0X20,0X67,0X6F,0X65,0X73,0X20,0X6F,0X6E,0X2E,0X2E,0X2E},
+ .frame_len=34,
+ .raw_payload_len=21,
+ .expected_errno=0,
+ .descr="Continuation test frag2",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ },
+ {
+ .frame={0X80,0X94,0X3B,0X88,0XA1,0XE9,0X62,0XDF,0X94,0X82,0X72,0XCF,0X98,0X9C,0X72,0XCF,0XE7,0X9C,0X61,0XCB,0XE3,0X93,0X5F,0XCF,0X98,0X9E},
+ .expectedDecodeBuf={0X61,0X6E,0X64,0X20,0X6F,0X6E,0X20,0X61,0X6E,0X64,0X20,0X73,0X74,0X6F,0X70},
+ .frame_len=26,
+ .raw_payload_len=15,
+ .expected_errno=0,
+ .descr="Continuation test frag3",
+ .i=0,
+ .simulate_sock_malfunction_at=0,
+ .errno_val=0,
+ .close_sock_at=0
+ }
+};