diff --git a/src/tltest/tltest-json-passthrough.c b/src/tltest/tltest-json-passthrough.c index 697a3208..ca27d54d 100644 --- a/src/tltest/tltest-json-passthrough.c +++ b/src/tltest/tltest-json-passthrough.c @@ -135,7 +135,7 @@ tltest_json_passthrough_buf(const char *name, GUARD("create a sink", tlog_json_sink_create(&sink, ¶ms)); } - pkt = TLOG_PKT_IO(0, 0, true, data_buf, data_len); + pkt = TLOG_PKT_IO(0, 0, 0, 0, true, data_buf, data_len); GUARD("write the buffer to the sink", tlog_sink_write(sink, &pkt, NULL, NULL)); @@ -236,12 +236,18 @@ main(void) #define PKT_VOID \ TLOG_PKT_VOID -#define PKT_WINDOW(_tv_sec, _tv_nsec, _width, _height) \ - TLOG_PKT_WINDOW(_tv_sec, _tv_nsec, _width, _height) -#define PKT_IO(_tv_sec, _tv_nsec, _output, _buf, _len) \ - TLOG_PKT_IO(_tv_sec, _tv_nsec, _output, _buf, _len) -#define PKT_IO_STR(_tv_sec, _tv_nsec, _output, _buf) \ - TLOG_PKT_IO_STR(_tv_sec, _tv_nsec, _output, _buf) +#define PKT_WINDOW(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _width, _height) \ + TLOG_PKT_WINDOW(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _width, _height) +#define PKT_IO(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf, _len) \ + TLOG_PKT_IO(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf, _len) +#define PKT_IO_STR(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf) \ + TLOG_PKT_IO_STR(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf) #define OP_WRITE(_pkt) TLTEST_JSON_SINK_OP_WRITE(_pkt) #define OP_FLUSH TLTEST_JSON_SINK_OP_FLUSH @@ -311,7 +317,7 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)) + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)) }, ), OUTPUT( @@ -326,14 +332,14 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), OP_READ_OK(PKT_VOID) } ) @@ -343,14 +349,14 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 0, 0)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 0, 0)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 0, 0)), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 0, 0)), OP_READ_OK(PKT_VOID) } ) @@ -360,14 +366,14 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, USHRT_MAX, USHRT_MAX)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, USHRT_MAX, USHRT_MAX)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, USHRT_MAX, USHRT_MAX)), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, USHRT_MAX, USHRT_MAX)), OP_READ_OK(PKT_VOID) } ) @@ -377,16 +383,16 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 10, 20)), - OP_WRITE(PKT_WINDOW(0, 1000000, 30, 40)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 10, 20)), + OP_WRITE(PKT_WINDOW(0, 1000000, 0, 0, 30, 40)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 10, 20)), - OP_READ_OK(PKT_WINDOW(0, 1000000, 30, 40)), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 10, 20)), + OP_READ_OK(PKT_WINDOW(0, 1000000, 0, 0, 30, 40)), OP_READ_OK(PKT_VOID) } ) @@ -396,20 +402,20 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 10, 20)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 10, 20)), OP_WRITE(PKT_WINDOW(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - 30, 40)), + 0, 0, 30, 40)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 10, 20)), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 10, 20)), OP_READ_OK(PKT_WINDOW(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - 30, 40)), + 0, 0, 30, 40)), OP_READ_OK(PKT_VOID) } ) @@ -419,14 +425,14 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), OP_READ_OK(PKT_VOID) } ) @@ -436,14 +442,14 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "Я")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "Я")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "Я")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "Я")), OP_READ_OK(PKT_VOID) } ) @@ -453,14 +459,14 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xe1\x9a\xa0")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xe1\x9a\xa0")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "\xe1\x9a\xa0")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "\xe1\x9a\xa0")), OP_READ_OK(PKT_VOID) } ) @@ -470,7 +476,7 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xf0\x9d\x84\x9e")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d\x84\x9e")), OP_FLUSH }, @@ -478,7 +484,7 @@ main(void) OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "\xf0\x9d\x84\x9e")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d\x84\x9e")), OP_READ_OK(PKT_VOID) } ) @@ -491,14 +497,14 @@ main(void) INPUT( .chunk_size = 2048, .op_list = { - OP_WRITE(PKT_IO(0, 0, true, buf, sizeof(buf))), + OP_WRITE(PKT_IO(0, 0, 0, 0, true, buf, sizeof(buf))), OP_FLUSH }, ), OUTPUT( .io_size = sizeof(buf), .op_list = { - OP_READ_OK(PKT_IO(0, 0, true, buf, sizeof(buf))), + OP_READ_OK(PKT_IO(0, 0, 0, 0, true, buf, sizeof(buf))), OP_READ_OK(PKT_VOID) } ) @@ -511,14 +517,14 @@ main(void) INPUT( .chunk_size = 2048, .op_list = { - OP_WRITE(PKT_IO(0, 0, true, buf, sizeof(buf))), + OP_WRITE(PKT_IO(0, 0, 0, 0, true, buf, sizeof(buf))), OP_FLUSH }, ), OUTPUT( .io_size = sizeof(buf), .op_list = { - OP_READ_OK(PKT_IO(0, 0, true, buf, sizeof(buf))), + OP_READ_OK(PKT_IO(0, 0, 0, 0, true, buf, sizeof(buf))), OP_READ_OK(PKT_VOID) } ) @@ -528,15 +534,15 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_IO_STR(0, 0, true, "B")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "B")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "AB")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "AB")), OP_READ_OK(PKT_VOID) } ) @@ -546,16 +552,16 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_IO_STR(0, 1000000, true, "B")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_IO_STR(0, 1000000, 0, 0, true, "B")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), - OP_READ_OK(PKT_IO_STR(0, 1000000, true, "B")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_READ_OK(PKT_IO_STR(0, 1000000, 0, 0, true, "B")), OP_READ_OK(PKT_VOID) } ) @@ -565,20 +571,20 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), OP_WRITE(PKT_IO_STR(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "B")), + 0, 0, true, "B")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), OP_READ_OK(PKT_IO_STR(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "B")), + 0, 0, true, "B")), OP_READ_OK(PKT_VOID) } ) @@ -588,15 +594,15 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xf0\x9d")), - OP_WRITE(PKT_IO_STR(0, 1000000, true, "\x84\x9e")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d")), + OP_WRITE(PKT_IO_STR(0, 1000000, 0, 0, true, "\x84\x9e")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 1000000, true, + OP_READ_OK(PKT_IO_STR(0, 1000000, 0, 0, true, "\xf0\x9d\x84\x9e")), OP_READ_OK(PKT_VOID) } @@ -607,10 +613,10 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xf0\x9d")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d")), OP_WRITE(PKT_IO_STR(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "\x84\x9e")), + 0, 0, true, "\x84\x9e")), OP_FLUSH }, ), @@ -619,7 +625,7 @@ main(void) .op_list = { OP_READ_OK(PKT_IO_STR(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "\xf0\x9d\x84\x9e")), + 0, 0, true, "\xf0\x9d\x84\x9e")), OP_READ_OK(PKT_VOID) } ) @@ -629,20 +635,20 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_WINDOW(0, 0, 300, 400)), - OP_WRITE(PKT_IO_STR(0, 0, true, "B")), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 300, 400)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "B")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), - OP_READ_OK(PKT_WINDOW(0, 0, 300, 400)), - OP_READ_OK(PKT_IO_STR(0, 0, true, "B")), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 300, 400)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "B")), OP_READ_OK(PKT_VOID) } ) @@ -652,20 +658,20 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), - OP_WRITE(PKT_IO_STR(0, 0, true, "B")), - OP_WRITE(PKT_WINDOW(0, 0, 300, 400)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "B")), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 300, 400)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(0, 0, true, "B")), - OP_READ_OK(PKT_WINDOW(0, 0, 300, 400)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "B")), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 300, 400)), OP_READ_OK(PKT_VOID) } ) @@ -675,18 +681,18 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, false, "A")), - OP_WRITE(PKT_IO_STR(0, 0, true, "B")), - OP_WRITE(PKT_IO_STR(0, 0, false, "C")), - OP_WRITE(PKT_IO_STR(0, 0, true, "D")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, false, "A")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "B")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, false, "C")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "D")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, false, "AC")), - OP_READ_OK(PKT_IO_STR(0, 0, true, "BD")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, false, "AC")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "BD")), OP_READ_OK(PKT_VOID) } ) @@ -696,18 +702,18 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_IO_STR(0, 0, false, "B")), - OP_WRITE(PKT_IO_STR(0, 0, true, "C")), - OP_WRITE(PKT_IO_STR(0, 0, false, "D")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, false, "B")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "C")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, false, "D")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, false, "BD")), - OP_READ_OK(PKT_IO_STR(0, 0, true, "AC")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, false, "BD")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "AC")), OP_READ_OK(PKT_VOID) } ) @@ -717,20 +723,20 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, false, "A")), - OP_WRITE(PKT_IO_STR(1, 0, true, "B")), - OP_WRITE(PKT_IO_STR(2, 0, false, "C")), - OP_WRITE(PKT_IO_STR(3, 0, true, "D")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, false, "A")), + OP_WRITE(PKT_IO_STR(1, 0, 0, 0, true, "B")), + OP_WRITE(PKT_IO_STR(2, 0, 0, 0, false, "C")), + OP_WRITE(PKT_IO_STR(3, 0, 0, 0, true, "D")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, false, "A")), - OP_READ_OK(PKT_IO_STR(1, 0, true, "B")), - OP_READ_OK(PKT_IO_STR(2, 0, false, "C")), - OP_READ_OK(PKT_IO_STR(3, 0, true, "D")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, false, "A")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "B")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, false, "C")), + OP_READ_OK(PKT_IO_STR(3, 0, 0, 0, true, "D")), OP_READ_OK(PKT_VOID) } ) @@ -740,20 +746,20 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_IO_STR(1, 0, false, "B")), - OP_WRITE(PKT_IO_STR(2, 0, true, "C")), - OP_WRITE(PKT_IO_STR(3, 0, false, "D")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_IO_STR(1, 0, 0, 0, false, "B")), + OP_WRITE(PKT_IO_STR(2, 0, 0, 0, true, "C")), + OP_WRITE(PKT_IO_STR(3, 0, 0, 0, false, "D")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "B")), - OP_READ_OK(PKT_IO_STR(2, 0, true, "C")), - OP_READ_OK(PKT_IO_STR(3, 0, false, "D")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "B")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, true, "C")), + OP_READ_OK(PKT_IO_STR(3, 0, 0, 0, false, "D")), OP_READ_OK(PKT_VOID) } ) @@ -763,15 +769,15 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), OP_READ_OK(PKT_VOID) } ) @@ -781,17 +787,17 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), - OP_WRITE(PKT_IO_STR(0, 0, true, "A")), - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "A")), + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(0, 0, true, "A")), + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "A")), OP_READ_OK(PKT_VOID) } ) @@ -801,17 +807,17 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "AB")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "AB")), OP_FLUSH, - OP_WRITE(PKT_IO_STR(0, 0, true, "CD")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "CD")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "AB")), - OP_READ_OK(PKT_IO_STR(0, 0, true, "CD")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "AB")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "CD")), OP_READ_OK(PKT_VOID) } ) @@ -821,16 +827,16 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "AB")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "AB")), OP_CUT, - OP_WRITE(PKT_IO_STR(0, 0, true, "CD")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "CD")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "ABCD")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "ABCD")), OP_READ_OK(PKT_VOID) } ) @@ -840,16 +846,16 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xf0\x9d")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d")), OP_FLUSH, - OP_WRITE(PKT_IO_STR(0, 0, true, "\x84\x9e")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\x84\x9e")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "\xf0\x9d\x84\x9e")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d\x84\x9e")), OP_READ_OK(PKT_VOID) } ) @@ -859,16 +865,16 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xf0\x9d")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d")), OP_CUT, - OP_WRITE(PKT_IO_STR(0, 0, true, "\x84\x9e")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\x84\x9e")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "\xf0\x9d\x84\x9e")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d\x84\x9e")), OP_READ_OK(PKT_VOID) } ) @@ -878,18 +884,18 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, "\xf0\x9d")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d")), OP_CUT, OP_FLUSH, - OP_WRITE(PKT_IO_STR(0, 0, true, "\x84\x9e")), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "\x84\x9e")), OP_FLUSH }, ), OUTPUT( .io_size = 4, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "\xf0\x9d")), - OP_READ_OK(PKT_IO_STR(0, 0, true, "\x84\x9e")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "\xf0\x9d")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "\x84\x9e")), OP_READ_OK(PKT_VOID) } ) @@ -899,7 +905,7 @@ main(void) INPUT( .chunk_size = 2048, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "自河南经乱关内阻饥兄弟离散各在一处…" "符离及下邽弟妹" "" @@ -917,7 +923,7 @@ main(void) OUTPUT( .io_size = 1024, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "自河南经乱关内阻饥兄弟离散各在一处…" "符离及下邽弟妹" "" @@ -938,7 +944,7 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef0123456789abc" "0123456789abcdef0123456789abc")), OP_FLUSH @@ -947,9 +953,9 @@ main(void) OUTPUT( .io_size = 58, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef0123456789abc")), - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef0123456789abc")), OP_READ_OK(PKT_VOID) } @@ -960,7 +966,7 @@ main(void) INPUT( .chunk_size = 35, .op_list = { - OP_WRITE(PKT_IO_STR(0, 0, true, + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef0123456789abcdef")), OP_FLUSH }, @@ -968,8 +974,8 @@ main(void) OUTPUT( .io_size = 16, .op_list = { - OP_READ_OK(PKT_IO_STR(0, 0, true, "0123456789abcdef")), - OP_READ_OK(PKT_IO_STR(0, 0, true, "0123456789abcdef")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef")), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef")), OP_READ_OK(PKT_VOID) } ) @@ -979,8 +985,8 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), - OP_WRITE(PKT_IO_STR(0, 0, true, + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234" "0123456789abcdef01234")), OP_FLUSH @@ -989,10 +995,10 @@ main(void) OUTPUT( .io_size = 58, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234")), - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234")), OP_READ_OK(PKT_VOID) } @@ -1003,11 +1009,11 @@ main(void) INPUT( .chunk_size = 32, .op_list = { - OP_WRITE(PKT_WINDOW(0, 0, 100, 200)), - OP_WRITE(PKT_IO_STR(0, 0, true, + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234")), - OP_WRITE(PKT_WINDOW(0, 0, 200, 300)), - OP_WRITE(PKT_IO_STR(0, 0, true, + OP_WRITE(PKT_WINDOW(0, 0, 0, 0, 200, 300)), + OP_WRITE(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234")), OP_FLUSH }, @@ -1015,11 +1021,11 @@ main(void) OUTPUT( .io_size = 58, .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234")), - OP_READ_OK(PKT_WINDOW(0, 0, 200, 300)), - OP_READ_OK(PKT_IO_STR(0, 0, true, + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 200, 300)), + OP_READ_OK(PKT_IO_STR(0, 0, 0, 0, true, "0123456789abcdef01234")), OP_READ_OK(PKT_VOID) } diff --git a/src/tltest/tltest-json-sink.c b/src/tltest/tltest-json-sink.c index ec867dce..fad994e0 100644 --- a/src/tltest/tltest-json-sink.c +++ b/src/tltest/tltest-json-sink.c @@ -30,6 +30,8 @@ main(void) { bool passed = true; +#define TLOG_DELAY_MAX_AS_EPOCH_STR "2147483647.999" + #define OP_WRITE(_pkt) TLTEST_JSON_SINK_OP_WRITE(_pkt) #define OP_FLUSH TLTEST_JSON_SINK_OP_FLUSH #define OP_CUT TLTEST_JSON_SINK_OP_CUT @@ -40,11 +42,12 @@ main(void) #define OP_WRITE_IO(_pkt_io_args...) \ OP_WRITE(TLOG_PKT_IO(_pkt_io_args)) -#define MSG(_id_tkn, _pos, _timing, \ +#define MSG(_id_tkn, _pos, _time, _timing, \ _in_txt, _in_bin, _out_txt, _out_bin) \ - "{\"ver\":\"2.2\",\"host\":\"localhost\",\"rec\":\"rec-1\"," \ + "{\"ver\":\"2.3\",\"host\":\"localhost\",\"rec\":\"rec-1\"," \ "\"user\":\"user\",\"term\":\"xterm\",\"session\":1," \ "\"id\":" #_id_tkn ",\"pos\":" _pos "," \ + "\"time\":" _time "," \ "\"timing\":\"" _timing "\"," \ "\"in_txt\":\"" _in_txt "\",\"in_bin\":[" _in_bin "]," \ "\"out_txt\":\"" _out_txt "\",\"out_bin\":[" _out_bin "]" \ @@ -84,96 +87,96 @@ main(void) TEST(window_unflushed, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200) + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200) }), OUTPUT("") ); TEST(window_cut, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), OP_CUT }), OUTPUT("") ); TEST(window_flushed, - INPUT(.op_list = {OP_WRITE_WINDOW(0, 0, 100, 200), OP_FLUSH}), - OUTPUT(MSG(1, "0", "=100x200", "", "", "", "")) + INPUT(.op_list = {OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), OP_FLUSH}), + OUTPUT(MSG(1, "0", "0.000", "=100x200", "", "", "", "")) ); TEST(window_cut_flushed, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x200", "", "", "", "")) ); TEST(window_flushed_cut, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), OP_FLUSH, OP_CUT }), - OUTPUT(MSG(1, "0", "=100x200", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x200", "", "", "", "")) ); TEST(min_window, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 0, 0), + OP_WRITE_WINDOW(0, 0, 0, 0, 0, 0), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=0x0", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=0x0", "", "", "", "")) ); TEST(max_window, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, USHRT_MAX, USHRT_MAX), + OP_WRITE_WINDOW(0, 0, 0, 0, USHRT_MAX, USHRT_MAX), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=65535x65535", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=65535x65535", "", "", "", "")) ); TEST(three_windows, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), - OP_WRITE_WINDOW(0, 0, 200, 200), - OP_WRITE_WINDOW(0, 0, 300, 300), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 0, 0, 0, 200, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 300, 300), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=100x100=200x200=300x300", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x100=200x200=300x300", "", "", "", "")) ); TEST(delay_between_windows, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), - OP_WRITE_WINDOW(0, 100000000, 200, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 100000000, 0, 0, 200, 200), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=100x100+100=200x200", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x100+100=200x200", "", "", "", "")) ); TEST(window_chunk_overflow, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 10001, 10001), - OP_WRITE_WINDOW(0, 0, 10002, 10002), - OP_WRITE_WINDOW(0, 0, 10003, 10003), - OP_WRITE_WINDOW(0, 0, 10004, 10004), - OP_WRITE_WINDOW(0, 0, 10005, 10005), - OP_WRITE_WINDOW(0, 0, 10006, 10006), - OP_WRITE_WINDOW(0, 0, 10007, 10007), - OP_WRITE_WINDOW(0, 0, 10008, 10008), - OP_WRITE_WINDOW(0, 0, 10009, 10009), - OP_WRITE_WINDOW(0, 0, 10010, 10010), + OP_WRITE_WINDOW(0, 0, 0, 0, 10001, 10001), + OP_WRITE_WINDOW(0, 0, 0, 0, 10002, 10002), + OP_WRITE_WINDOW(0, 0, 0, 0,10003, 10003), + OP_WRITE_WINDOW(0, 0, 0, 0, 10004, 10004), + OP_WRITE_WINDOW(0, 0, 0, 0, 10005, 10005), + OP_WRITE_WINDOW(0, 0, 0, 0, 10006, 10006), + OP_WRITE_WINDOW(0, 0, 0, 0, 10007, 10007), + OP_WRITE_WINDOW(0, 0, 0, 0, 10008, 10008), + OP_WRITE_WINDOW(0, 0, 0, 0, 10009, 10009), + OP_WRITE_WINDOW(0, 0, 0, 0, 10010, 10010), OP_FLUSH, }), - OUTPUT(MSG(1, "0", + OUTPUT(MSG(1, "0", "0.000", "=10001x10001=10002x10002=10003x10003" "=10004x10004=10005x10005", "", "", "", "") - MSG(2, "0", + MSG(2, "0", "0.000", "=10006x10006=10007x10007=10008x10008" "=10009x10009=10010x10010", "", "", "", "")) @@ -181,107 +184,107 @@ main(void) TEST(window_merging, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), - OP_WRITE_WINDOW(0, 1000000, 100, 100), - OP_WRITE_WINDOW(0, 2000000, 200, 200), - OP_WRITE_WINDOW(0, 3000000, 200, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 1000000, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 2000000, 0, 0, 200, 200), + OP_WRITE_WINDOW(0, 3000000, 0, 0, 200, 200), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=100x100+2=200x200", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x100+2=200x200", "", "", "", "")) ); TEST(window_not_merging, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), - OP_WRITE_WINDOW(0, 1000000, 200, 200), - OP_WRITE_WINDOW(0, 2000000, 100, 100), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 1000000, 0, 0, 200, 200), + OP_WRITE_WINDOW(0, 2000000, 0, 0, 100, 100), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=100x100+1=200x200+1=100x100", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x100+1=200x200+1=100x100", "", "", "", "")) ); TEST(window_merging_over_chars, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "A", 1), - OP_WRITE_WINDOW(0, 0, 10, 10), - OP_WRITE_IO(0, 0, true, "B", 1), - OP_WRITE_WINDOW(0, 0, 10, 10), - OP_WRITE_IO(0, 0, true, "C", 1), - OP_WRITE_WINDOW(0, 0, 20, 20), - OP_WRITE_IO(0, 0, true, "D", 1), - OP_WRITE_WINDOW(0, 0, 20, 20), - OP_WRITE_IO(0, 0, true, "E", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "A", 1), + OP_WRITE_WINDOW(0, 0, 0, 0, 10, 10), + OP_WRITE_IO(0, 0, 0, 0, true, "B", 1), + OP_WRITE_WINDOW(0, 0, 0, 0, 10, 10), + OP_WRITE_IO(0, 0, 0, 0, true, "C", 1), + OP_WRITE_WINDOW(0, 0, 0, 0, 20, 20), + OP_WRITE_IO(0, 0, 0, 0, true, "D", 1), + OP_WRITE_WINDOW(0, 0, 0, 0, 20, 20), + OP_WRITE_IO(0, 0, 0, 0, true, "E", 1), OP_FLUSH, }), - OUTPUT(MSG(1, "0", ">1=10x10>2=20x20>2", "", "", "ABCDE", "")) + OUTPUT(MSG(1, "0", "0.000", ">1=10x10>2=20x20>2", "", "", "ABCDE", "")) ); TEST(window_merging_in_chars, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 10, 10), - OP_WRITE_IO(0, 1000000, true, "\xf0\x9d", 2), - OP_WRITE_WINDOW(0, 2000000, 10, 10), - OP_WRITE_IO(0, 3000000, true, "\x84\x9e", 2), + OP_WRITE_WINDOW(0, 0, 0, 0, 10, 10), + OP_WRITE_IO(0, 1000000, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_WINDOW(0, 2000000, 0, 0, 10, 10), + OP_WRITE_IO(0, 3000000, 0, 0, true, "\x84\x9e", 2), OP_FLUSH, }), - OUTPUT(MSG(1, "0", "=10x10+3>1", "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, "0", "0.000", "=10x10+3>1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(char_io_merging, INPUT(.op_list = { - OP_WRITE_IO(0, 1000000, true, "\xf0", 1), - OP_WRITE_IO(0, 2000000, true, "\x9d", 1), - OP_WRITE_IO(0, 3000000, true, "\x84", 1), - OP_WRITE_IO(0, 4000000, true, "\x9e", 1), + OP_WRITE_IO(0, 1000000, 0, 0, true, "\xf0", 1), + OP_WRITE_IO(0, 2000000, 0, 0, true, "\x9d", 1), + OP_WRITE_IO(0, 3000000, 0, 0, true, "\x84", 1), + OP_WRITE_IO(0, 4000000, 0, 0, true, "\x9e", 1), OP_FLUSH, }), - OUTPUT(MSG(1, "3", ">1", "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, "3", "0.003", ">1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(one_byte, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "A", 1) + OP_WRITE_IO(0, 0, 0, 0, true, "A", 1) }), OUTPUT("") ); TEST(one_byte_cut, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "A", 1), OP_CUT }), OUTPUT("") ); TEST(one_byte_flushed, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "A", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", ">1", "", "", "A", "")) + OUTPUT(MSG(1, "0", "0.000", ">1", "", "", "A", "")) ); TEST(one_byte_flushed_cut, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "A", 1), OP_FLUSH, OP_CUT }), - OUTPUT(MSG(1, "0", ">1", "", "", "A", "")) + OUTPUT(MSG(1, "0", "0.000", ">1", "", "", "A", "")) ); TEST(one_byte_cut_flushed, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "A", 1), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "0", ">1", "", "", "A", "")) + OUTPUT(MSG(1, "0", "0.000", ">1", "", "", "A", "")) ); TEST(input_overflow_flush, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcd", 62), }), - OUTPUT(MSG(1, "0", "<61", + OUTPUT(MSG(1, "0", "0.000", "<61", "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abc", "", "", "")) @@ -289,41 +292,41 @@ main(void) TEST(output_overflow_flush, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, + OP_WRITE_IO(0, 0, 0, 0, true, "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcd", 62), }), - OUTPUT(MSG(1, "0", ">61", "", "", + OUTPUT(MSG(1, "0", "0.000", ">61", "", "", "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abc", "")) ); TEST(both_overflow_flush, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef", 32), - OP_WRITE_IO(0, 0, true, + OP_WRITE_IO(0, 0, 0, 0, true, "0123456789abcdef0123456789a", 27), }), - OUTPUT(MSG(1, "0", "<32>26", + OUTPUT(MSG(1, "0", "0.000", "<32>26", "0123456789abcdef0123456789abcdef", "", "0123456789abcdef0123456789", "")) ); TEST(no_window_no_window_repeat, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abc" "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abc", (64 - 3) * 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<61", + OUTPUT(MSG(1, "0", "0.000", "<61", "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abc", "", "", "") - MSG(2, "0", "<61", + MSG(2, "0", "0.000", "<61", "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abc", "", "", "")) @@ -331,15 +334,15 @@ main(void) TEST(no_write_no_window_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234" "\xf0\x9d", 32 + 16 + 5 + 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -347,8 +350,8 @@ main(void) TEST(window_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234" "0123456789abcdef0123456789abcdef" @@ -356,11 +359,11 @@ main(void) (32 + 16 + 5) * 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "0", "=100x200<53", + MSG(2, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -368,22 +371,22 @@ main(void) TEST(window_repeat_after_delay, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", (32 + 16 + 5)), - OP_WRITE_IO(1, 0, false, + OP_WRITE_IO(1, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", (32 + 16 + 5)), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "1000", "=100x200<53", + MSG(2, "1000", "1.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -391,20 +394,20 @@ main(void) TEST(window_repeat_non_initial, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "0123456789abcdef0123456789abcdef", 32), - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef", 32), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef01" "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", (16 + 2 + 32 + 16 + 5)), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<32=100x200<18", + OUTPUT(MSG(1, "0", "0.000", "<32=100x200<18", "0123456789abcdef0123456789abcdef" "0123456789abcdef01", "", "", "") - MSG(2, "0", "=100x200<53", + MSG(2, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -412,23 +415,23 @@ main(void) TEST(window_change_no_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), - OP_WRITE_WINDOW(0, 0, 300, 400), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 300, 400), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "0", "=300x400<53", + MSG(2, "0", "0.000", "=300x400<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -436,23 +439,23 @@ main(void) TEST(window_delayed_change, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), - OP_WRITE_WINDOW(0, 1000000, 300, 400), - OP_WRITE_IO(0, 1000000, false, + OP_WRITE_WINDOW(0, 1000000, 0, 0, 300, 400), + OP_WRITE_IO(0, 1000000, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "1", "=300x400<53", + MSG(2, "1", "0.001", "=300x400<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -460,23 +463,23 @@ main(void) TEST(window_same_no_double_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "0", "=100x200<53", + MSG(2, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -484,24 +487,24 @@ main(void) TEST(window_double_same_no_double_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", 32 + 16 + 5), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "0", "=100x200<53", + MSG(2, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "")) @@ -509,104 +512,104 @@ main(void) TEST(window_change_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcdef", 64), - OP_WRITE_WINDOW(0, 0, 300, 400), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 300, 400), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcde", 31), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "0", "=100x200<11=300x400<31", + MSG(2, "0", "0.000", "=100x200<11=300x400<31", "56789abcdef0123456789abcdef0123456789abcde", "", "", "")) ); TEST(window_delayed_change_repeat, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, false, + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcdef", 64), - OP_WRITE_WINDOW(0, 1000000, 300, 400), - OP_WRITE_IO(0, 1000000, false, + OP_WRITE_WINDOW(0, 1000000, 0, 0, 300, 400), + OP_WRITE_IO(0, 1000000, 0, 0, false, "0123456789abcdef0123456789abc", 29), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200<53", + OUTPUT(MSG(1, "0", "0.000", "=100x200<53", "0123456789abcdef0123456789abcdef" "0123456789abcdef01234", "", "", "") - MSG(2, "0", "=100x200<11+1=300x400<29", + MSG(2, "0", "0.000", "=100x200<11+1=300x400<29", "56789abcdef0123456789abcdef0123456789abc", "", "", "")) ); TEST(incomplete, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d\x84", 3) + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d\x84", 3) }), OUTPUT("") ); TEST(invalid_byte, INPUT(.op_list = { - OP_WRITE_IO(1, 0, true, "\xff", 1), + OP_WRITE_IO(1, 0, 0, 0, true, "\xff", 1), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "0", "]1/1", + OUTPUT(MSG(1, "0", "0.000", "]1/1", "", "", "\xef\xbf\xbd", "255")) ); TEST(invalid_byte_after_window, INPUT(.op_list = { - OP_WRITE_WINDOW(1, 0, 100, 100), - OP_WRITE_IO(2, 0, true, "\xff", 1), + OP_WRITE_WINDOW(1, 0, 0, 0, 100, 100), + OP_WRITE_IO(2, 0, 0, 0, true, "\xff", 1), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x100+1000]1/1", + OUTPUT(MSG(1, "0", "0.000", "=100x100+1000]1/1", "", "", "\xef\xbf\xbd", "255")) ); TEST(late_character_termination, INPUT(.op_list = { - OP_WRITE_IO(1, 0, false, "\xf0\x9d", 2), - OP_WRITE_IO(2, 0, true, "x", 1), - OP_WRITE_IO(3, 0, false, "\xff", 1), + OP_WRITE_IO(1, 0, 0, 0, false, "\xf0\x9d", 2), + OP_WRITE_IO(2, 0, 0, 0, true, "x", 1), + OP_WRITE_IO(3, 0, 0, 0, false, "\xff", 1), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "1000", "[1/2>1+1000[1/1", + OUTPUT(MSG(1, "1000", "1.000", "[1/2>1+1000[1/1", "\xef\xbf\xbd\xef\xbf\xbd", "240,157,255", "x", "")) ); TEST(late_character_cut, INPUT(.op_list = { - OP_WRITE_IO(1, 0, false, "\xf0\x9d", 2), - OP_WRITE_IO(2, 0, true, "x", 1), + OP_WRITE_IO(1, 0, 0, 0, false, "\xf0\x9d", 2), + OP_WRITE_IO(2, 0, 0, 0, true, "x", 1), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "1000", "[1/2>1", + OUTPUT(MSG(1, "1000", "1.000", "[1/2>1", "\xef\xbf\xbd", "240,157", "x", "")) ); TEST(incomplete_flushed, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d\x84", 3), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d\x84", 3), OP_FLUSH }), OUTPUT("") @@ -614,7 +617,7 @@ main(void) TEST(incomplete_cut, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d\x84", 3), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d\x84", 3), OP_CUT }), OUTPUT("") @@ -622,211 +625,212 @@ main(void) TEST(incomplete_cut_flushed, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d\x84", 3), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d\x84", 3), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "0", "]1/3", "", "", "�", "240,157,132")) + OUTPUT(MSG(1, "0", "0.000", "]1/3", "", "", "�", "240,157,132")) ); TEST(split_valid, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), - OP_WRITE_IO(0, 0, true, "\x84\x9e", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\x84\x9e", 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", ">1", "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, "0", "0.000", ">1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(split_before_invalid, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), - OP_WRITE_IO(0, 0, true, "\x84X", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\x84X", 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", "]1/3>1", "", "", "�X", "240,157,132")) + OUTPUT(MSG(1, "0", "0.000", "]1/3>1", "", "", "�X", "240,157,132")) ); TEST(split_on_invalid, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d\x84", 3), - OP_WRITE_IO(0, 0, true, "X", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d\x84", 3), + OP_WRITE_IO(0, 0, 0, 0, true, "X", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "]1/3>1", "", "", "�X", "240,157,132")) + OUTPUT(MSG(1, "0", "0.000", "]1/3>1", "", "", "�X", "240,157,132")) ); TEST(split_incomplete, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), - OP_WRITE_IO(0, 0, true, "\x84", 1), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\x84", 1), OP_CUT, OP_FLUSH }), - OUTPUT(MSG(1, "0", "]1/3", "", "", "�", "240,157,132")) + OUTPUT(MSG(1, "0", "0.000", "]1/3", "", "", "�", "240,157,132")) ); TEST(delay_inside_char, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), - OP_WRITE_IO(0, 1100000, true, "\x84\x9e", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_IO(0, 1100000, 0, 0, true, "\x84\x9e", 2), OP_FLUSH }), - OUTPUT(MSG(1, "1", ">1", "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, "1", "0.001", ">1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(delay_between_chars, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "A", 1), - OP_WRITE_IO(0, 1100000, true, "B", 1), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), + OP_WRITE_IO(0, 1100000, 0, 0, true, "B", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<1+1>1", "A", "", "B", "")) + OUTPUT(MSG(1, "0", "0.000", "<1+1>1", "A", "", "B", "")) ); TEST(delay_between_messages, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), OP_FLUSH, - OP_WRITE_IO(0, 1100000, true, "B", 1), + OP_WRITE_IO(0, 1100000, 0, 0, true, "B", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<1", "A", "", "", "") \ - MSG(2, "1", ">1", "", "", "B", "")) + OUTPUT(MSG(1, "0", "0.000", "<1", "A", "", "", "") \ + MSG(2, "1", "0.001", ">1", "", "", "B", "")) ); TEST(min_delay_between_windows, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), - OP_WRITE_WINDOW(0, 1000000, 200, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 1000000, 0, 0, 200, 200), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x100+1=200x200", "", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x100+1=200x200", "", "", "", "")) ); TEST(max_delay_between_windows, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), OP_WRITE_WINDOW(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - 200, 200), + 0, 0, 200, 200), OP_FLUSH }), - OUTPUT(MSG(1, "0", + OUTPUT(MSG(1, "0", "0.000", "=100x100+" TLOG_DELAY_MAX_MS_STR "=200x200", "", "", "", "")) ); TEST(min_delay_inside_char, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), - OP_WRITE_IO(0, 1000000, true, "\x84\x9e", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_IO(0, 1000000, 0, 0, true, "\x84\x9e", 2), OP_FLUSH }), - OUTPUT(MSG(1, "1", ">1", "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, "1", "0.001", ">1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(max_delay_inside_char, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), OP_WRITE_IO(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "\x84\x9e", 2), + 0, 0, true, "\x84\x9e", 2), OP_FLUSH }), - OUTPUT(MSG(1, TLOG_DELAY_MAX_MS_STR, ">1", - "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, TLOG_DELAY_MAX_MS_STR, TLOG_DELAY_MAX_AS_EPOCH_STR, + ">1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(min_delay_between_chars, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "A", 1), - OP_WRITE_IO(0, 1000000, true, "B", 1), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), + OP_WRITE_IO(0, 1000000, 0, 0, true, "B", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<1+1>1", "A", "", "B", "")) + OUTPUT(MSG(1, "0", "0.000", "<1+1>1", "A", "", "B", "")) ); TEST(max_delay_between_chars, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), OP_WRITE_IO(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "B", 1), + 0, 0, true, "B", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<1+" TLOG_DELAY_MAX_MS_STR ">1", + OUTPUT(MSG(1, "0", "0.000", "<1+" TLOG_DELAY_MAX_MS_STR ">1", "A", "", "B", "")) ); TEST(max_delay_between_messages, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "A", 1), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), OP_FLUSH, OP_WRITE_IO(TLOG_DELAY_MAX_TIMESPEC_SEC, TLOG_DELAY_MAX_TIMESPEC_NSEC, - true, "B", 1), + 0, 0, true, "B", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<1", "A", "", "", "") \ - MSG(2, TLOG_DELAY_MAX_MS_STR, ">1", "", "", "B", "")) + OUTPUT(MSG(1, "0", "0.000", "<1", "A", "", "", "") \ + MSG(2, TLOG_DELAY_MAX_MS_STR, TLOG_DELAY_MAX_AS_EPOCH_STR, + ">1", "", "", "B", "")) ); TEST(window_between_chars, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, "A", 1), - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, true, "B", 1), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, true, "B", 1), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<1=100x200>1", "A", "", "B", "")) + OUTPUT(MSG(1, "0", "0.000", "<1=100x200>1", "A", "", "B", "")) ); TEST(char_between_windows, INPUT(.op_list = { - OP_WRITE_WINDOW(0, 0, 100, 100), - OP_WRITE_IO(0, 0, false, "A", 1), - OP_WRITE_WINDOW(0, 0, 200, 200), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 100), + OP_WRITE_IO(0, 0, 0, 0, false, "A", 1), + OP_WRITE_WINDOW(0, 0, 0, 0, 200, 200), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x100<1=200x200", "A", "", "", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x100<1=200x200", "A", "", "", "")) ); TEST(window_inside_char, INPUT(.op_list = { - OP_WRITE_IO(0, 0, true, "\xf0\x9d", 2), - OP_WRITE_WINDOW(0, 0, 100, 200), - OP_WRITE_IO(0, 0, true, "\x84\x9e", 2), + OP_WRITE_IO(0, 0, 0, 0, true, "\xf0\x9d", 2), + OP_WRITE_WINDOW(0, 0, 0, 0, 100, 200), + OP_WRITE_IO(0, 0, 0, 0, true, "\x84\x9e", 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", "=100x200>1", "", "", "\xf0\x9d\x84\x9e", "")) + OUTPUT(MSG(1, "0", "0.000", "=100x200>1", "", "", "\xf0\x9d\x84\x9e", "")) ); TEST(windows_chars_and_delays, INPUT(.op_list = { - OP_WRITE_IO(0, 10000000, true, "S", 1), - OP_WRITE_WINDOW(0, 30000000, 100, 100), - OP_WRITE_WINDOW(0, 60000000, 200, 200), - OP_WRITE_IO(0, 100000000, true, "E", 1), + OP_WRITE_IO(0, 10000000, 0, 0, true, "S", 1), + OP_WRITE_WINDOW(0, 30000000, 0, 0, 100, 100), + OP_WRITE_WINDOW(0, 60000000, 0, 0, 200, 200), + OP_WRITE_IO(0, 100000000, 0, 0, true, "E", 1), OP_FLUSH, }), - OUTPUT(MSG(1, "0", ">1+20=100x100+30=200x200+40>1", + OUTPUT(MSG(1, "0", "0.000", ">1+20=100x100+30=200x200+40>1", "", "", "SE", "")) ); TEST(incomplete_char_backoff, INPUT(.op_list = { - OP_WRITE_IO(0, 0, false, + OP_WRITE_IO(0, 0, 0, 0, false, "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789a\xf0\x9d", 61), - OP_WRITE_IO(0, 0, false, "\x84\x9e", 2), + OP_WRITE_IO(0, 0, 0, 0, false, "\x84\x9e", 2), OP_FLUSH }), - OUTPUT(MSG(1, "0", "<59", + OUTPUT(MSG(1, "0", "0.000", "<59", "0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789a", "", "", "") - MSG(2, "0", "<1", + MSG(2, "0", "0.000", "<1", "\xf0\x9d\x84\x9e", "", "", "")) ); diff --git a/src/tltest/tltest-json-source.c b/src/tltest/tltest-json-source.c index ed8f4711..942606d5 100644 --- a/src/tltest/tltest-json-source.c +++ b/src/tltest/tltest-json-source.c @@ -28,19 +28,108 @@ #include #include +#define TLTEST_MSG_MAX_SIZE 3072 +#define TLTEST_MSG_MAX_COMBINED_SIZE 3072*3 + +void +tltest_json_source_fmt_msg(size_t id, + const char *pos, + const char *timing, + const char *in_txt, + const char *in_bin, + const char *out_txt, + const char *out_bin, + bool latest_version, + char *_msg) + +{ + char msg[TLTEST_MSG_MAX_SIZE]; + + /* https://github.com/Scribery/tlog/blob/master/doc/log_format.md + * version 2.3 */ + if (latest_version) { + snprintf( + msg, TLTEST_MSG_MAX_SIZE, + "{" + "\"ver\":" "\"1\"," + "\"host\":" "\"%s\"," + "\"rec\":" "\"%s\"," + "\"user\":" "\"%s\"," + "\"term\":" "\"%s\"," + "\"session\":" "%u," + "\"id\":" "%zu," + "\"pos\":" "%s," + "\"time\":" "%f," + "\"timing\":" "\"%s\"," + "\"in_txt\":" "\"%s\"," + "\"in_bin\":" "[%s]," + "\"out_txt\":" "\"%s\"," + "\"out_bin\":" "[%s]" + "}\n", + "host", "5d24f15", "user", "xterm", 1, + id, pos, 1600710269.999, timing, in_txt, in_bin, + out_txt, out_bin); + /* version 2.2 */ + } else { + snprintf( + msg, TLTEST_MSG_MAX_SIZE, + "{" + "\"ver\":" "\"1\"," + "\"host\":" "\"%s\"," + "\"user\":" "\"%s\"," + "\"term\":" "\"%s\"," + "\"session\":" "%u," + "\"id\":" "%zu," + "\"pos\":" "%s," + "\"timing\":" "\"%s\"," + "\"in_txt\":" "\"%s\"," + "\"in_bin\":" "[%s]," + "\"out_txt\":" "\"%s\"," + "\"out_bin\":" "[%s]" + "}\n", + "host", "user", "xterm", 1, + id, pos, timing, in_txt, in_bin, + out_txt, out_bin); + } + + strcpy(_msg, msg); +} + +void +tltest_json_source_cat_msg(const char *msg1, + const char *msg2, + const char *msg3, + char *_msg) +{ + + char msg[TLTEST_MSG_MAX_COMBINED_SIZE]; + strcpy(msg, msg1); + strcat(msg, msg2); + strcat(msg, msg3); + + strcpy(_msg, msg); +} + int main(void) { bool passed = true; + bool curr_version = false; #define PKT_VOID \ TLOG_PKT_VOID -#define PKT_WINDOW(_tv_sec, _tv_nsec, _width, _height) \ - TLOG_PKT_WINDOW(_tv_sec, _tv_nsec, _width, _height) -#define PKT_IO(_tv_sec, _tv_nsec, _output, _buf, _len) \ - TLOG_PKT_IO(_tv_sec, _tv_nsec, _output, _buf, _len) -#define PKT_IO_STR(_tv_sec, _tv_nsec, _output, _buf) \ - TLOG_PKT_IO_STR(_tv_sec, _tv_nsec, _output, _buf) +#define PKT_WINDOW(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _width, _height) \ + TLOG_PKT_WINDOW(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _width, _height) +#define PKT_IO(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf, _len) \ + TLOG_PKT_IO(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf, _len) +#define PKT_IO_STR(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf) \ + TLOG_PKT_IO_STR(_tv_sec, _tv_nsec, _real_sec, _real_nsec, \ + _output, _buf) #define OP_LOC_GET(_exp_loc) \ TLTEST_JSON_SOURCE_OP_LOC_GET(_exp_loc) @@ -92,1004 +181,1116 @@ main(void) (struct tltest_json_source){_struct_init_args} \ ) && passed - TEST(null, - INPUT(""), - OUTPUT( - .io_size = 4, - .op_list = { - } - ) - ); - - TEST(null_eof, - INPUT(""), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(null_repeat_eof, - INPUT(""), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window, - INPUT(MSG_DUMMY(1, "1000", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)) - } - ) - ); - - TEST(window_eof, - INPUT(MSG_DUMMY(1, "1000", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(two_windows, - INPUT(MSG_DUMMY(1, "1000", "=110x120=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ_OK(PKT_WINDOW(1, 0, 210, 220)) - } - ) - ); - - TEST(two_windows_eof, - INPUT(MSG_DUMMY(1, "1000", "=100x200=300x400", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_WINDOW(1, 0, 300, 400)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(loc_null, - INPUT(""), - OUTPUT( - .io_size = 4, - .op_list = { - OP_LOC_GET(1) - } - ) - ); - - TEST(loc_null_after_eof, - INPUT(""), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_VOID), - OP_LOC_GET(1) - } - ) - ); - - TEST(loc_after_window, - INPUT(MSG_DUMMY(1, "1000", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_LOC_GET(2) - } - ) - ); - - TEST(loc_after_two_windows, - INPUT(MSG_DUMMY(1, "1000", "=100x200=300x400", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_WINDOW(1, 0, 300, 400)), - OP_LOC_GET(2) - } - ) - ); - - TEST(pos_0, - INPUT(MSG_DUMMY(1, "0", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)) - } - ) - ); - - TEST(pos_1ms, - INPUT(MSG_DUMMY(1, "1", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(0, 1000000, 100, 200)) - } - ) - ); - - TEST(pos_999ms, - INPUT(MSG_DUMMY(1, "999", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(0, 999000000, 100, 200)) - } - ) - ); - - TEST(pos_1s, - INPUT(MSG_DUMMY(1, "1000", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)) - } - ) - ); - - TEST(pos_max, - INPUT(MSG_DUMMY(1, TLOG_DELAY_MAX_MS_STR, - "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_OK, - PKT_WINDOW(TLOG_DELAY_MAX_TIMESPEC_SEC, - TLOG_DELAY_MAX_TIMESPEC_NSEC, - 100, 200)) - } - ) - ); - - TEST(pos_overflow, - INPUT(MSG_DUMMY(1, "1" TLOG_DELAY_MAX_MS_STR, - "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_POS, PKT_VOID) - } - ) - ); - - TEST(pos_underflow, - INPUT(MSG_DUMMY(1, "-1", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_POS, PKT_VOID) - } - ) - ); - - TEST(pos_min, - INPUT(MSG_DUMMY(1, "0", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_OK, PKT_WINDOW(0, 0, 100, 200)) - } - ) - ); - - TEST(syntax_error, - INPUT(MSG_DUMMY(aaa, "bbb", "", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_GRC_FROM(json, json_tokener_error_parse_unexpected), - PKT_VOID) - } - ) - ); - - TEST(loc_after_syntax_error, - INPUT(MSG_DUMMY(aaa, "bbb", "", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_GRC_FROM(json, json_tokener_error_parse_unexpected), - PKT_VOID), - OP_LOC_GET(2) - } - ) - ); - - TEST(syntax_error_recovery, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(aaa, "bbb", "", "", "", "", "") - MSG_DUMMY(2, "2000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_GRC_FROM(json, json_tokener_error_parse_unexpected), - PKT_VOID), - OP_READ_OK(PKT_WINDOW(2, 0, 210, 220)) - } - ) - ); - - TEST(schema_error_recovery, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - "{\"abc\": \"def\"}\n" - MSG_DUMMY(2, "2000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_MSG_FIELD_MISSING, PKT_VOID), - OP_READ_OK(PKT_WINDOW(2, 0, 210, 220)) - } - ) - ); - - TEST(type_error_recovery, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY("0", "0", "", "", "", "", "") - MSG_DUMMY(2, "2000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_TYPE, PKT_VOID), - OP_READ_OK(PKT_WINDOW(2, 0, 210, 220)) - } - ) - ); - - TEST(value_error_recovery, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(2, "2000", "=65536x0", "", "", "", "") - MSG_DUMMY(3, "3000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_TIMING, - PKT_VOID), - OP_READ_OK(PKT_WINDOW(3, 0, 210, 220)) - } - ) - ); - - TEST(window_repeat_eof, - INPUT(MSG_DUMMY(1, "1000", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_null, - INPUT(MSG_DUMMY(1, "1000", "", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_1_txt1, - INPUT(MSG_DUMMY(1, "1000", "<1", "X", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_out_1_txt1, - INPUT(MSG_DUMMY(1, "1000", ">1", "", "", "X", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, true, "X")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_mixed_txt, - INPUT(MSG_DUMMY(1, "1000", "<1>1<1>1", "AC", "", "BD", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "A")), - OP_READ_OK(PKT_IO_STR(1, 0, true, "B")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "C")), - OP_READ_OK(PKT_IO_STR(1, 0, true, "D")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_spaced_timing, - INPUT(MSG_DUMMY(1, "1", " <1 +1 >1 +1 <1 +1 >1 ", - "AC", "", "BD", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(0, 1000000, false, "A")), - OP_READ_OK(PKT_IO_STR(0, 2000000, true, "B")), - OP_READ_OK(PKT_IO_STR(0, 3000000, false, "C")), - OP_READ_OK(PKT_IO_STR(0, 4000000, true, "D")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_mixed_bin, - INPUT(MSG_DUMMY(1, "1000", "[0/1]0/1[0/1]0/1", - "", "65,67", "", "66,68")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "A")), - OP_READ_OK(PKT_IO_STR(1, 0, true, "B")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "C")), - OP_READ_OK(PKT_IO_STR(1, 0, true, "D")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_2_txt1, - INPUT(MSG_DUMMY(1, "1000", "<2", "XY", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "XY")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_out_2_txt1, - INPUT(MSG_DUMMY(1, "1000", ">2", "", "", "XY", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, true, "XY")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_1_txt2, - INPUT(MSG_DUMMY(1, "1000", "<1", "\xd0\x90", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xd0\x90")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_1_txt3, - INPUT(MSG_DUMMY(1, "1000", "<1", "\xe5\x96\x9c", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xe5\x96\x9c")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_1_txt4, - INPUT(MSG_DUMMY(1, "1000", "<1", "\xf0\x9d\x84\x9e", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x84\x9e")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_txt_split, - INPUT(MSG_DUMMY(1, "1000", "<3", - "\xf0\x9d\x85\x9d" - "\xf0\x9d\x85\x9e" - "\xf0\x9d\x85\x9f", - "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x85\x9d")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x85\x9e")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x85\x9f")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_txt_split_uneven, - INPUT(MSG_DUMMY(1, "1000", "<7", - "12345" - "\xf0\x9d\x85\x9d" - "\xf0\x9d\x85\x9e", - "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "1234")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "5")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x85\x9d")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x85\x9e")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_txt, - INPUT(MSG_DUMMY(1, "1000", "<1<2<3", "ABCXYZ", "", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "ABCXYZ")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_bin, - INPUT(MSG_DUMMY(1, "1000", "[0/1[0/2[0/3", - "", "49,50,51,52,53,54", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "123456")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_mixed, - INPUT(MSG_DUMMY(1, "1000", "<1[0/1<1[0/2<1", - "136", "50,52,53", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "123456")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_zero_delay, - INPUT(MSG_DUMMY(1, "1000", "<1+0<1", "AB", "", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "AB")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_zero_out, - INPUT(MSG_DUMMY(1, "1000", "<1>0<1", "AB", "", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "AB")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_break_out, - INPUT(MSG_DUMMY(1, "1000", "<1>1<1", "AC", "", "B", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "A")), - OP_READ_OK(PKT_IO_STR(1, 0, true, "B")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "C")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_merge_break_delay, - INPUT(MSG_DUMMY(1, "1000", "<1+1000<1", "AB", "", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "A")), - OP_READ_OK(PKT_IO_STR(2, 0, false, "B")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_0_txt_1_bin, - INPUT(MSG_DUMMY(1, "1000", "[0/1<1", "Y", "88", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "XY")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_0_txt_2_bin, - INPUT(MSG_DUMMY(1, "1000", "[0/2<1", "Z", "88, 89", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "XYZ")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_1_txt1_1_bin, - INPUT(MSG_DUMMY(1, "1000", "[1/1", "X", "89", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "Y")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_1_txt1_1_bin, - INPUT(MSG_DUMMY(1, "1000", "[1/1", "X", "89", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "Y")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_2_txt1_1_bin, - INPUT(MSG_DUMMY(1, "1000", "[2/1", "XY", "90", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "Z")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_delay_on_boundary, - INPUT(MSG_DUMMY(1, "1000", "<4+1000<4", "12345678", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "1234")), - OP_READ_OK(PKT_IO_STR(2, 0, false, "5678")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_delay_before_uneven_boundary, - INPUT(MSG_DUMMY(1, "1000", "<1+1000<2", - "X\xf0\x9d\x85\x9dY", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_IO_STR(2, 0, false, "\xf0\x9d\x85\x9d")), - OP_READ_OK(PKT_IO_STR(2, 0, false, "Y")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_delay_after_uneven_boundary, - INPUT(MSG_DUMMY(1, "1000", "<2+1000<1", - "X\xf0\x9d\x85\x9dY", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "\xf0\x9d\x85\x9d")), - OP_READ_OK(PKT_IO_STR(2, 0, false, "Y")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_short_char, - INPUT(MSG_DUMMY(1, "1000", "<1", "\xf0\x9d\x85", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_TXT, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_short_bin, - INPUT(MSG_DUMMY(1, "1000", "[0/2", "", "48", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_bin_not_int, - INPUT(MSG_DUMMY(1, "1000", "[0/1", "", "3.14", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_bin_void, - INPUT(MSG_DUMMY(1, "1000", "[0/0", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_txt_too_short, - INPUT(MSG_DUMMY(1, "1000", "<1", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_TXT, PKT_VOID) - } - ) - ); - - TEST(io_in_txt_too_long_0, - INPUT(MSG_DUMMY(1, "1000", "", "X", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_txt_too_long_1, - INPUT(MSG_DUMMY(1, "1000", "<1", "XY", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")) - } - ) - ); - - TEST(io_in_bin_min, - INPUT(MSG_DUMMY(1, "1000", "[0/1", "", "0", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO(1, 0, false, "\0", 1)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_bin_max, - INPUT(MSG_DUMMY(1, "1000", "[0/1", "", "255", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO(1, 0, false, "\xff", 1)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_bin_too_small, - INPUT(MSG_DUMMY(1, "1000", "[0/1", "", "-1", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_bin_too_big, - INPUT(MSG_DUMMY(1, "1000", "[0/1", "", "256", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_in_txt_zero_char, - INPUT(MSG_DUMMY(1, "1000", "<3", "X\\u0000Y", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO(1, 0, false, "X\0Y", 3)) - } - ) - ); - - TEST(io_everything, - INPUT(MSG_DUMMY(1, "1000", "<1[1/1+234>1]1/1", - "1.", "50", "3.", "52")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "12")), - OP_READ_OK(PKT_IO_STR(1, 234000000, true, "34")) - } - ) - ); - - TEST(id_repeat, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(1, "2000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_SOURCE_MSG_ID_OUT_OF_ORDER, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(id_backwards, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(0, "2000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_SOURCE_MSG_ID_OUT_OF_ORDER, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(id_gap, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(3, "2000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_SOURCE_MSG_ID_OUT_OF_ORDER, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(ts_repeat, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(2, "1000", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ_OK(PKT_WINDOW(1, 0, 210, 220)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(ts_backwards, - INPUT(MSG_DUMMY(1, "1000", "=110x120", "", "", "", "") - MSG_DUMMY(2, "500", "=210x220", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(1, 0, 110, 120)), - OP_READ(TLOG_RC_JSON_SOURCE_PKT_TS_OUT_OF_ORDER, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_ts_null_no_overlap, - INPUT(MSG_DUMMY(1, "1000", "", "", "", "", "") - MSG_DUMMY(2, "1000", "<1", "X", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_ts_hanging_no_overlap, - INPUT(MSG_DUMMY(1, "1000", "<1+1", "X", "", "", "") - MSG_DUMMY(2, "1000", "<1", "Y", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_IO_STR(1, 0, false, "Y")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_ts_repeat, - INPUT(MSG_DUMMY(1, "1000", "<1+1<1", "XY", "", "", "") - MSG_DUMMY(2, "1000", "<1", "Z", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_IO_STR(1, 1000000, false, "Y")), - OP_READ(TLOG_RC_JSON_SOURCE_PKT_TS_OUT_OF_ORDER, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_ts_overlap, - INPUT(MSG_DUMMY(1, "1000", "<1+2<1", "XY", "", "", "") - MSG_DUMMY(2, "1001", "<1", "Z", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_IO_STR(1, 2000000, false, "Y")), - OP_READ(TLOG_RC_JSON_SOURCE_PKT_TS_OUT_OF_ORDER, PKT_VOID), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(io_ts_no_gap, - INPUT(MSG_DUMMY(1, "1000", "<1+2<1", "XY", "", "", "") - MSG_DUMMY(2, "1002", "<1", "Z", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "X")), - OP_READ_OK(PKT_IO_STR(1, 2000000, false, "Y")), - OP_READ_OK(PKT_IO_STR(1, 2000000, false, "Z")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(delays_and_windows, - INPUT(MSG_DUMMY(1, "1000", "+1000=110x120+1000=210x220", - "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(2, 0, 110, 120)), - OP_READ_OK(PKT_WINDOW(3, 0, 210, 220)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window_between_chars, - INPUT(MSG_DUMMY(1, "1000", "<1=100x200<1", "AB", "", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "A")), - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(1, 0, false, "B")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window_between_strings, - INPUT(MSG_DUMMY(1, "1000", "<3=100x200<3", - "ABCXYZ", "", "", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "ABC")), - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(1, 0, false, "XYZ")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window_between_streams, - INPUT(MSG_DUMMY(1, "1000", "<3=100x200>3", "ABC", "", "XYZ", "")), - OUTPUT( - .io_size = 6, - .op_list = { - OP_READ_OK(PKT_IO_STR(1, 0, false, "ABC")), - OP_READ_OK(PKT_WINDOW(1, 0, 100, 200)), - OP_READ_OK(PKT_IO_STR(1, 0, true, "XYZ")), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window_suppression_in_message, - INPUT(MSG_DUMMY(1, "0", "=100x200+100=100x200", - "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window_suppression_between_messages, - INPUT(MSG_DUMMY(1, "0", "=100x200", "", "", "", "") - MSG_DUMMY(2, "0", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_VOID) - } - ) - ); - - TEST(window_suppression_between_messages_with_delay, - INPUT(MSG_DUMMY(1, "0", "=100x200", "", "", "", "") - MSG_DUMMY(2, "100", "=100x200", "", "", "", "")), - OUTPUT( - .io_size = 4, - .op_list = { - OP_READ_OK(PKT_WINDOW(0, 0, 100, 200)), - OP_READ_OK(PKT_VOID) - } - ) - ); + char msg[TLTEST_MSG_MAX_SIZE]; + char msg2[TLTEST_MSG_MAX_SIZE]; + char msg3[TLTEST_MSG_MAX_SIZE]; + char combined_msg[TLTEST_MSG_MAX_COMBINED_SIZE]; + + + /* Tests are all executed twice, once with the latest message format, + * and again with the previous format to ensure we remain backwards + * compatible when the message format changes */ + do { + curr_version = !curr_version; + + TEST(null, + INPUT(""), + OUTPUT( + .io_size = 4, + .op_list = { + } + ) + ); + + TEST(null_eof, + INPUT(""), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_VOID) + } + ) + ); + + TEST(null_repeat_eof, + INPUT(""), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200", "", "", "", "", curr_version, msg); + TEST(window, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200", "", "", "", "", curr_version, msg); + TEST(window_eof, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120=210x220", "", "", "", "", curr_version, msg); + TEST(two_windows, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 210, 220)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200=300x400", "", "", "", "", curr_version, msg); + TEST(two_windows_eof, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 300, 400)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + TEST(loc_null, + INPUT(""), + OUTPUT( + .io_size = 4, + .op_list = { + OP_LOC_GET(1) + } + ) + ); + + TEST(loc_null_after_eof, + INPUT(""), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_VOID), + OP_LOC_GET(1) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200", "", "", "", "", curr_version, msg); + TEST(loc_after_window, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_LOC_GET(2) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200=300x400", "", "", "", "", curr_version, msg); + TEST(loc_after_two_windows, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 300, 400)), + OP_LOC_GET(2) + } + ) + ); + + tltest_json_source_fmt_msg(1, "0", "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_0, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1", "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_1ms, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(0, 1000000, 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "999", "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_999ms, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(0, 999000000, 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_1s, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, TLOG_DELAY_MAX_MS_STR, + "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_max, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_OK, + PKT_WINDOW(TLOG_DELAY_MAX_TIMESPEC_SEC, + TLOG_DELAY_MAX_TIMESPEC_NSEC, + 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1" TLOG_DELAY_MAX_MS_STR, + "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_overflow, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_POS, PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "-1", "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_underflow, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_POS, PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "0", "=100x200", "", "", "", "", curr_version, msg); + TEST(pos_min, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_OK, PKT_WINDOW(0, 0, 0, 0, 100, 200)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "id\":\"bbb", "", "", "", "", "", curr_version, msg); + TEST(syntax_error, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_GRC_FROM(json, json_tokener_error_parse_unexpected), + PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "id\":\"bbb", "", "", "", "", "", curr_version, msg); + TEST(loc_after_syntax_error, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_GRC_FROM(json, json_tokener_error_parse_unexpected), + PKT_VOID), + OP_LOC_GET(2) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(1, "id\":\"bbb", "", "", "", "", "", curr_version, msg2); + tltest_json_source_fmt_msg(2, "2000", "=210x220", "", "", "", "", curr_version, msg3); + tltest_json_source_cat_msg(msg, msg2, msg3, combined_msg); + + TEST(syntax_error_recovery, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_GRC_FROM(json, json_tokener_error_parse_unexpected), + PKT_VOID), + OP_READ_OK(PKT_WINDOW(2, 0, 0, 0, 210, 220)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "2000", "=210x220", "", "", "", "", curr_version, msg3); + tltest_json_source_cat_msg(msg, "{\"abc\": \"def\"}\n", msg3, combined_msg); + + TEST(schema_error_recovery, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_MSG_FIELD_MISSING, PKT_VOID), + OP_READ_OK(PKT_WINDOW(2, 0, 0, 0, 210, 220)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "2000", "=210x220", "", "", "", "", curr_version, msg3); + /* First field generates string "0" id */ + tltest_json_source_cat_msg(msg, MSG_DUMMY("0", "0", "", "", "", "", ""), msg3, combined_msg); + + TEST(type_error_recovery, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_TYPE, PKT_VOID), + OP_READ_OK(PKT_WINDOW(2, 0, 0, 0, 210, 220)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "2000", "=655536x0", "", "", "", "", curr_version, msg2); + tltest_json_source_fmt_msg(3, "3000", "=210x220", "", "", "", "", curr_version, msg3); + tltest_json_source_cat_msg(msg, msg2, msg3, combined_msg); + + TEST(value_error_recovery, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_TIMING, + PKT_VOID), + OP_READ_OK(PKT_WINDOW(3, 0, 0, 0, 210, 220)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=100x200", "", "", "", "", curr_version, msg); + TEST(window_repeat_eof, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "", "", "", "", "", curr_version, msg); + TEST(io_null, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "X", "", "", "", curr_version, msg); + TEST(io_in_1_txt1, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", ">1", "", "", "X", "", curr_version, msg); + TEST(io_out_1_txt1, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "X")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1>1<1>1", "AC", "", "BD", "", curr_version, msg); + TEST(io_mixed_txt, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "A")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "B")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "C")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "D")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1", " <1 +1 >1 +1 <1 +1 >1 ", + "AC", "", "BD", "", curr_version, msg); + TEST(io_spaced_timing, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(0, 1000000, 0, 0, false, "A")), + OP_READ_OK(PKT_IO_STR(0, 2000000, 0, 0, true, "B")), + OP_READ_OK(PKT_IO_STR(0, 3000000, 0, 0, false, "C")), + OP_READ_OK(PKT_IO_STR(0, 4000000, 0, 0, true, "D")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1]0/1[0/1]0/1", + "", "65,67", "", "66,68", curr_version, msg); + TEST(io_mixed_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "A")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "B")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "C")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "D")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<2", "XY", "", "", "", curr_version, msg); + TEST(io_in_2_txt1, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "XY")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", ">2", "", "", "XY", "", curr_version, msg); + TEST(io_out_2_txt1, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "XY")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "\xd0\x90", "", "", "", curr_version, msg); + TEST(io_in_1_txt2, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xd0\x90")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "\xe5\x96\x9c", "", "", "", curr_version, msg); + TEST(io_in_1_txt3, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xe5\x96\x9c")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "\xf0\x9d\x84\x9e", "", "", "", curr_version, msg); + TEST(io_in_1_txt4, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x84\x9e")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<3", + "\xf0\x9d\x85\x9d" + "\xf0\x9d\x85\x9e" + "\xf0\x9d\x85\x9f", + "", "", "", curr_version, msg); + TEST(io_in_txt_split, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x85\x9d")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x85\x9e")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x85\x9f")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<7", + "12345" + "\xf0\x9d\x85\x9d" + "\xf0\x9d\x85\x9e", + "", "", "", curr_version, msg); + TEST(io_in_txt_split_uneven, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "1234")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "5")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x85\x9d")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x85\x9e")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1<2<3", "ABCXYZ", "", "", "", curr_version, msg); + TEST(io_in_merge_txt, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "ABCXYZ")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1[0/2[0/3", + "", "49,50,51,52,53,54", "", "", curr_version, msg); + TEST(io_in_merge_bin, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "123456")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1[0/1<1[0/2<1", + "136", "50,52,53", "", "", curr_version, msg); + TEST(io_in_merge_mixed, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "123456")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+0<1", "AB", "", "", "", curr_version, msg); + TEST(io_in_merge_zero_delay, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "AB")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1>0<1", "AB", "", "", "", curr_version, msg); + TEST(io_in_merge_zero_out, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "AB")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1>1<1", "AC", "", "B", "", curr_version, msg); + TEST(io_in_merge_break_out, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "A")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "B")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "C")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+1000<1", "AB", "", "", "", curr_version, msg); + TEST(io_in_merge_break_delay, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "A")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, false, "B")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1<1", "Y", "88", "", "", curr_version, msg); + TEST(io_in_0_txt_1_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "XY")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/2<1", "Z", "88, 89", "", "", curr_version, msg); + TEST(io_in_0_txt_2_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "XYZ")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[1/1", "X", "89", "", "", curr_version, msg); + TEST(io_in_1_txt1_1_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "Y")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[1/1", "X", "89", "", "", curr_version, msg); + TEST(io_in_1_txt1_1_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "Y")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[2/1", "XY", "90", "", "", curr_version, msg); + TEST(io_in_2_txt1_1_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "Z")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<4+1000<4", "12345678", "", "", "", curr_version, msg); + TEST(io_in_delay_on_boundary, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "1234")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, false, "5678")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+1000<2", + "X\xf0\x9d\x85\x9dY", "", "", "", curr_version, msg); + TEST(io_in_delay_before_uneven_boundary, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, false, "\xf0\x9d\x85\x9d")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, false, "Y")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<2+1000<1", + "X\xf0\x9d\x85\x9dY", "", "", "", curr_version, msg); + TEST(io_in_delay_after_uneven_boundary, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "\xf0\x9d\x85\x9d")), + OP_READ_OK(PKT_IO_STR(2, 0, 0, 0, false, "Y")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "\xf0\x9d\x85", "", "", "", curr_version, msg); + TEST(io_in_short_char, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_TXT, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/2", "", "48", "", "", curr_version, msg); + TEST(io_in_short_bin, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1", "", "3.14", "", "", curr_version, msg); + TEST(io_in_bin_not_int, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/0", "", "", "", "", curr_version, msg); + TEST(io_in_bin_void, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "", "", "", "", curr_version, msg); + TEST(io_in_txt_too_short, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_TXT, PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "", "X", "", "", "", curr_version, msg); + TEST(io_in_txt_too_long_0, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1", "XY", "", "", "", curr_version, msg); + TEST(io_in_txt_too_long_1, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1", "", "0", "", "", curr_version, msg); + TEST(io_in_bin_min, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO(1, 0, 0, 0, false, "\0", 1)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1", "", "255", "", "", curr_version, msg); + TEST(io_in_bin_max, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO(1, 0, 0, 0, false, "\xff", 1)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1", "", "-1", "", "", curr_version, msg); + TEST(io_in_bin_too_small, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "[0/1", "", "256", "", "", curr_version, msg); + TEST(io_in_bin_too_big, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ(TLOG_RC_JSON_MSG_FIELD_INVALID_VALUE_BIN, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<3", "X\\u0000Y", "", "", "", curr_version, msg); + TEST(io_in_txt_zero_char, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO(1, 0, 0, 0, false, "X\0Y", 3)) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1[1/1+234>1]1/1", + "1.", "50", "3.", "52", curr_version, msg); + TEST(io_everything, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "12")), + OP_READ_OK(PKT_IO_STR(1, 234000000, 0, 0, true, "34")) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(1, "2000", "=210x220", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(id_repeat, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_SOURCE_MSG_ID_OUT_OF_ORDER, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(0, "2000", "=210x220", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(id_backwards, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_SOURCE_MSG_ID_OUT_OF_ORDER, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(3, "2000", "=210x220", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(id_gap, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_SOURCE_MSG_ID_OUT_OF_ORDER, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "1000", "=210x220", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(ts_repeat, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 210, 220)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "=110x120", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "500", "=210x220", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(ts_backwards, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 110, 120)), + OP_READ(TLOG_RC_JSON_SOURCE_PKT_TS_OUT_OF_ORDER, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "1000", "<1", "X", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(io_ts_null_no_overlap, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+1", "X", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "1000", "<1", "Y", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(io_ts_hanging_no_overlap, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "Y")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+1<1", "XY", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "1000", "<1", "Z", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(io_ts_repeat, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_IO_STR(1, 1000000, 0, 0, false, "Y")), + OP_READ(TLOG_RC_JSON_SOURCE_PKT_TS_OUT_OF_ORDER, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+2<1", "XY", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "1001", "<1", "Z", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(io_ts_overlap, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_IO_STR(1, 2000000, 0, 0, false, "Y")), + OP_READ(TLOG_RC_JSON_SOURCE_PKT_TS_OUT_OF_ORDER, PKT_VOID), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1+2<1", "XY", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "1002", "<1", "Z", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(io_ts_no_gap, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "X")), + OP_READ_OK(PKT_IO_STR(1, 2000000, 0, 0, false, "Y")), + OP_READ_OK(PKT_IO_STR(1, 2000000, 0, 0, false, "Z")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "+1000=110x120+1000=210x220", + "", "", "", "", curr_version, msg); + TEST(delays_and_windows, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(2, 0, 0, 0, 110, 120)), + OP_READ_OK(PKT_WINDOW(3, 0, 0, 0, 210, 220)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<1=100x200<1", "AB", "", "", "", curr_version, msg); + TEST(window_between_chars, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "A")), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "B")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<3=100x200<3", + "ABCXYZ", "", "", "", curr_version, msg); + TEST(window_between_strings, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "ABC")), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "XYZ")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "1000", "<3=100x200>3", "ABC", "", "XYZ", "", curr_version, msg); + TEST(window_between_streams, + INPUT(msg), + OUTPUT( + .io_size = 6, + .op_list = { + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, false, "ABC")), + OP_READ_OK(PKT_WINDOW(1, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_IO_STR(1, 0, 0, 0, true, "XYZ")), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "0", "=100x200+100=100x200", + "", "", "", "", curr_version, msg); + TEST(window_suppression_in_message, + INPUT(msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "0", "=100x200", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "0", "=100x200", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(window_suppression_between_messages, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + tltest_json_source_fmt_msg(1, "0", "=100x200", "", "", "", "", curr_version, msg); + tltest_json_source_fmt_msg(2, "100", "=100x200", "", "", "", "", curr_version, msg2); + tltest_json_source_cat_msg(msg, msg2, "", combined_msg); + TEST(window_suppression_between_messages_with_delay, + INPUT(combined_msg), + OUTPUT( + .io_size = 4, + .op_list = { + OP_READ_OK(PKT_WINDOW(0, 0, 0, 0, 100, 200)), + OP_READ_OK(PKT_VOID) + } + ) + ); + + } while (curr_version); return !passed; }