summaryrefslogtreecommitdiffstats
path: root/test/wstest.c
diff options
context:
space:
mode:
authorAndreas Weigel <andreaswe@securepoint.de>2017-02-20 15:13:03 +0100
committerChristian Beier <dontmind@freeshell.org>2017-05-14 20:38:28 +0200
commit826e0f9e39a49ae3598f8709218180f835af269b (patch)
treec5f5b3a257159b962f18726fd9b1e8b3b70c1d6f /test/wstest.c
parentf19d6ee225ff35eb54ca06927a921c98ff721adc (diff)
downloadlibtdevnc-826e0f9e39a49ae3598f8709218180f835af269b.tar.gz
libtdevnc-826e0f9e39a49ae3598f8709218180f835af269b.zip
add generation wstest to cmake
add wstestdata.c, because the python data generation script has too many dependencies remove some redundance from jpeg test creation add support for decoding close messages
Diffstat (limited to 'test/wstest.c')
-rw-r--r--test/wstest.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/test/wstest.c b/test/wstest.c
index 30324cb..4a5ba91 100644
--- a/test/wstest.c
+++ b/test/wstest.c
@@ -23,6 +23,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _WIN32
+
#include <ws_decode.h>
#include <stdio.h>
#include <stdlib.h>
@@ -30,11 +32,11 @@
#include <unistd.h>
#include <errno.h>
-#ifndef _WIN32
-
+/* 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
-#define WS_TMP_LOG "ws_tmp.log"
enum {
OK,
@@ -55,6 +57,7 @@ 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;
@@ -67,6 +70,8 @@ struct ws_frame_test {
int close_sock_at;
};
+#include "wstestdata.c"
+
char el_log[1000000];
char *el_pos;
@@ -160,15 +165,15 @@ static uint64_t run_test(struct ws_frame_test *ft, ws_ctx_t *ctx)
return OK;
}
-#include "wstestdata.in"
int main()
{
ws_ctx_t ctx;
- int retall= 0;
+ int retall= 0;
+ int i;
srand(RND_SEED);
- for (int i = 0; i < ARRAYSIZE(tests); i++) {
+ for (i = 0; i < ARRAYSIZE(tests); i++) {
int ret;
el_pos = el_log;
@@ -192,4 +197,10 @@ int main()
return retall;
}
+#else
+
+int main() {
+ return 0;
+}
+
#endif