1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

lejp: tighten api tests

This commit is contained in:
Andy Green 2021-11-05 07:45:47 +00:00
parent a81c7cccd0
commit 9734cadf11

View file

@ -127,29 +127,359 @@ static const char * const json_tests[] = {
"{" /* SHOULD_FAIL: test 10, missing open */
"\"a\":123,\"b\":}"
"}",
"{" /* test 11: array of arrays */
"\"array1\": [[\"a\", \"b\", \"b1\"], [\"c\", \"d\", \"d1\"]],"
"\"array2\": [[\"e\", \"f\", \"f1\"], [\"g\", \"h\", \"h1\"]]"
"}"
};
struct lejp_results {
int reason;
int ipos;
int path_match;
uint16_t indexes[12];
const char *path;
const char *buf;
} r1[] = {
{ 0, 0, 0, { 0 }, "", "" },
{ 2, 0, 0, { 0 }, "", "" },
{ 16, 0, 0, { 0 }, "", "" },
{ 5, 0, 0, { 0 }, "schema", "" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "hostname", "com-warmcat-sai-builder" },
{ 11, 0, 0, { 0 }, "hostname", "" },
{ 77, 0, 0, { 0 }, "hostname", "learn" },
{ 5, 0, 0, { 0 }, "nspawn_timeout", "learn" },
{ 73, 0, 0, { 0 }, "nspawn_timeout", "1800" },
{ 5, 0, 0, { 0 }, "targets", "1800" },
{ 14, 0, 0, { 0 }, "targets[]", "1800" },
{ 16, 1, 0, { 0, }, "targets[]", "1800" },
{ 5, 1, 0, { 0, }, "targets[].name", "1800" },
{ 11, 1, 0, { 0, }, "targets[].name", "" },
{ 77, 1, 0, { 0, }, "targets[].name", "target1" },
{ 5, 1, 0, { 0, }, "targets[].someflag", "target1" },
{ 70, 1, 0, { 0, }, "targets[].someflag", "1" },
{ 17, 1, 0, { 0, }, "targets[]", "1" },
{ 16, 1, 0, { 1, }, "targets[]", "1" },
{ 5, 1, 0, { 1, }, "targets[].name", "1" },
{ 11, 1, 0, { 1, }, "targets[].name", "" },
{ 77, 1, 0, { 1, }, "targets[].name", "target2" },
{ 5, 1, 0, { 1, }, "targets[].someflag", "target2" },
{ 71, 1, 0, { 1, }, "targets[].someflag", "0" },
{ 17, 1, 0, { 1, }, "targets[]", "0" },
{ 15, 1, 0, { 1, }, "targets[]", "0" },
{ 17, 1, 0, { 1, }, "targets[]", "0" },
{ 3, 1, 0, { 1, }, "targets[]", "0" },
}, r2[] = {
{ 0, 0, 0, { 0 }, "", "0" },
{ 2, 0, 0, { 0 }, "", "0" },
{ 16, 0, 0, { 0 }, "", "0" },
{ 5, 0, 0, { 0 }, "schema", "0" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "hostname", "com-warmcat-sai-builder" },
{ 11, 0, 0, { 0 }, "hostname", "" },
{ 77, 0, 0, { 0 }, "hostname", "learn" },
{ 5, 0, 0, { 0 }, "targets", "learn" },
{ 14, 0, 0, { 0 }, "targets[]", "learn" },
{ 16, 1, 0, { 0, }, "targets[]", "learn" },
{ 5, 1, 0, { 0, }, "targets[].name", "learn" },
{ 11, 1, 0, { 0, }, "targets[].name", "" },
{ 77, 1, 0, { 0, }, "targets[].name", "target1" },
{ 17, 1, 0, { 0, }, "targets[]", "target1" },
{ 16, 1, 0, { 1, }, "targets[]", "target1" },
{ 5, 1, 0, { 1, }, "targets[].name", "target1" },
{ 11, 1, 0, { 1, }, "targets[].name", "" },
{ 77, 1, 0, { 1, }, "targets[].name", "target2" },
{ 17, 1, 0, { 1, }, "targets[]", "target2" },
{ 16, 1, 0, { 2, }, "targets[]", "target2" },
{ 5, 1, 0, { 2, }, "targets[].name", "target2" },
{ 11, 1, 0, { 2, }, "targets[].name", "" },
{ 77, 1, 0, { 2, }, "targets[].name", "target3" },
{ 17, 1, 0, { 2, }, "targets[]", "target3" },
{ 15, 1, 0, { 2, }, "targets[]", "target3" },
{ 17, 1, 0, { 2, }, "targets[]", "target3" },
{ 3, 1, 0, { 2, }, "targets[]", "target3" },
}, r3[] = {
{ 0, 0, 0, { 0 }, "", "target3" },
{ 2, 0, 0, { 0 }, "", "target3" },
{ 16, 0, 0, { 0 }, "", "target3" },
{ 5, 0, 0, { 0 }, "schema", "target3" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "hostname", "com-warmcat-sai-builder" },
{ 11, 0, 0, { 0 }, "hostname", "" },
{ 77, 0, 0, { 0 }, "hostname", "learn" },
{ 5, 0, 0, { 0 }, "nspawn_timeout", "learn" },
{ 73, 0, 0, { 0 }, "nspawn_timeout", "1800" },
{ 5, 0, 0, { 0 }, "targets", "1800" },
{ 14, 0, 0, { 0 }, "targets[]", "1800" },
{ 16, 1, 0, { 0, }, "targets[]", "1800" },
{ 5, 1, 0, { 0, }, "targets[].name", "1800" },
{ 11, 1, 0, { 0, }, "targets[].name", "" },
{ 77, 1, 0, { 0, }, "targets[].name", "target1" },
{ 5, 1, 0, { 0, }, "targets[].unrecognized", "target1" },
{ 11, 1, 0, { 0, }, "targets[].unrecognized", "" },
{ 77, 1, 0, { 0, }, "targets[].unrecognized", "xyz" },
{ 5, 1, 0, { 0, }, "targets[].child", "xyz" },
{ 16, 1, 0, { 0, }, "targets[].child", "xyz" },
{ 5, 1, 0, { 0, }, "targets[].child.somename", "xyz" },
{ 11, 1, 0, { 0, }, "targets[].child.somename", "" },
{ 77, 1, 0, { 0, }, "targets[].child.somename", "abc" },
{ 5, 1, 0, { 0, }, "targets[].child.junk", "abc" },
{ 16, 1, 0, { 0, }, "targets[].child.junk", "abc" },
{ 5, 1, 0, { 0, }, "targets[].child.junk.x", "abc" },
{ 11, 1, 0, { 0, }, "targets[].child.junk.x", "" },
{ 77, 1, 0, { 0, }, "targets[].child.junk.x", "y" },
{ 17, 1, 0, { 0, }, "targets[].child.junk", "y" },
{ 17, 1, 0, { 0, }, "targets[].child", "y" },
{ 17, 1, 0, { 0, }, "targets[]", "y" },
{ 16, 1, 0, { 1, }, "targets[]", "y" },
{ 5, 1, 0, { 1, }, "targets[].name", "y" },
{ 11, 1, 0, { 1, }, "targets[].name", "" },
{ 77, 1, 0, { 1, }, "targets[].name", "target2" },
{ 17, 1, 0, { 1, }, "targets[]", "target2" },
{ 15, 1, 0, { 1, }, "targets[]", "target2" },
{ 17, 1, 0, { 1, }, "targets[]", "target2" },
{ 3, 1, 0, { 1, }, "targets[]", "target2" },
}, r4[] = {
{ 0, 0, 0, { 0 }, "", "target2" },
{ 2, 0, 0, { 0 }, "", "target2" },
{ 16, 0, 0, { 0 }, "", "target2" },
{ 5, 0, 0, { 0 }, "schema", "target2" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "hostname", "com-warmcat-sai-builder" },
{ 11, 0, 0, { 0 }, "hostname", "" },
{ 77, 0, 0, { 0 }, "hostname", "learn" },
{ 5, 0, 0, { 0 }, "nspawn_timeout", "learn" },
{ 73, 0, 0, { 0 }, "nspawn_timeout", "1800" },
{ 17, 0, 0, { 0 }, "nspawn_timeout", "1800" },
{ 3, 0, 0, { 0 }, "nspawn_timeout", "1800" },
}, r5[] = {
{ 0, 0, 0, { 0 }, "", "1800" },
{ 2, 0, 0, { 0 }, "", "1800" },
{ 16, 0, 0, { 0 }, "", "1800" },
{ 5, 0, 0, { 0 }, "schema", "1800" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 17, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 3, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
}, r6[] = {
{ 0, 0, 0, { 0 }, "", "com-warmcat-sai-builder" },
{ 2, 0, 0, { 0 }, "", "com-warmcat-sai-builder" },
{ 16, 0, 0, { 0 }, "", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "hostname", "com-warmcat-sai-builder" },
{ 11, 0, 0, { 0 }, "hostname", "" },
{ 76, 0, 0, { 0 }, "hostname", "PYvtan6kqppjnS0KpYTCaiOLsJkc7XecAr1kcE0aCIciewYB+JcLG82mO1Vb1mJtjDwUjBxy2I6AzefzoWUWmqZbsv4MXR55j9bKlyz1liiSX63iO0x6JAwACMtE2MkgcLwR86TSWAD9D1QKIWqg5RJ/CRuVsW0DKAUMD52ql4JmPFuJpJgTq28z6PhYNzN3yI3bmQt6bzhA+A/xAsFzSBnb3MHYWzGMprr53FAP1ISo5Ec9i+2ehV40sG6Q47" },
{ 76, 0, 0, { 0 }, "hostname", "0sH3PGQZ0YRPO7Sh/SyrSQ/scONmxRc3AcXl7X/CSs417ii+CV8sq3ZgcxKNB7tNfN7idNx3upZ00G2BZy9jSy03cLKKLNaNUt0TQsxXbH55uDHzSEeZWvxJgT6zB1NoMhdC02w+oXim94M6z6COCnqT3rgkGk8PHMry9Bkh4yVpRmzIRfMmln/lEhdZgxky2+g5hhlSIGJYDCrdynD9kCfvfy6KGOpNIi1X+mhbbWn4lnL9ZKihL/RrfOV+oV" },
{ 76, 0, 0, { 0 }, "hostname", "4R26IDq+KqUiJBENeo8/GXkGLUH/87iPyzXKEMavr6fkrK0vTGto8yEYxmOyaVz8phG5rwf4jJgmYNoMbGo8gWvhqO7UAGy2g7MWv+B/t1eZZ+1euLsNrWAsFJiFbQKgdFfQT3RjB14iU8knlQ8usoy+pXssY2ddGJGVcGC21oZvstK9eu1eRZftda/wP+N5unT1Hw7kCoVzqxHieiYt47EGIOaaQ7XjZDK6qPN6O/grHnvJZm2vBkxuXgsYVk" },
{ 76, 0, 0, { 0 }, "hostname", "RQ7AuTWIecphqFsq7Wbc1YNbMW47SVU5zMD0WaCqbaaI0t4uIzRvPlD8cpiiTzFTrEHlIBTf8/uZjjEGGLhJR1jPqA9D1Ej3ChV+ye6F9JTUMlozRMsGuF8U4btDzH5xdnmvRS4Ar6LKEtAXGkj2yuyJln+v4RIWj2xOGPJovOqiXwi0FyM61f8U8gj0OiNA2/QlvrqQVDF7sMXgjvaE7iQt5vMETteZlx+z3f+jTFM/aon511W4+ZkRD+6AHw" },
{ 77, 0, 0, { 0 }, "hostname", "ucvM9BEC" },
{ 17, 0, 0, { 0 }, "hostname", "ucvM9BEC" },
{ 3, 0, 0, { 0 }, "hostname", "ucvM9BEC" },
}, r7[] = {
{ 0, 0, 0, { 0 }, "", "ucvM9BEC" },
{ 2, 0, 0, { 0 }, "", "ucvM9BEC" },
{ 16, 0, 0, { 0 }, "", "ucvM9BEC" },
{ 5, 0, 0, { 0 }, "schema", "ucvM9BEC" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-builder" },
{ 5, 0, 0, { 0 }, "targets", "com-warmcat-sai-builder" },
{ 14, 0, 0, { 0 }, "targets[]", "com-warmcat-sai-builder" },
{ 16, 1, 0, { 0, }, "targets[]", "com-warmcat-sai-builder" },
{ 5, 1, 0, { 0, }, "targets[].name", "com-warmcat-sai-builder" },
{ 11, 1, 0, { 0, }, "targets[].name", "" },
{ 76, 1, 0, { 0, }, "targets[].name", "PYvtan6kqppjnS0KpYTCaiOLsJkc7XecAr1kcE0aCIciewYB+JcLG82mO1Vb1mJtjDwUjBxy2I6AzefzoWUWmqZbsv4MXR55j9bKlyz1liiSX63iO0x6JAwACMtE2MkgcLwR86TSWAD9D1QKIWqg5RJ/CRuVsW0DKAUMD52ql4JmPFuJpJgTq28z6PhYNzN3yI3bmQt6bzhA+A/xAsFzSBnb3MHYWzGMprr53FAP1ISo5Ec9i+2ehV40sG6Q47" },
{ 76, 1, 0, { 0, }, "targets[].name", "0sH3PGQZ0YRPO7Sh/SyrSQ/scONmxRc3AcXl7X/CSs417ii+CV8sq3ZgcxKNB7tNfN7idNx3upZ00G2BZy9jSy03cLKKLNaNUt0TQsxXbH55uDHzSEeZWvxJgT6zB1NoMhdC02w+oXim94M6z6COCnqT3rgkGk8PHMry9Bkh4yVpRmzIRfMmln/lEhdZgxky2+g5hhlSIGJYDCrdynD9kCfvfy6KGOpNIi1X+mhbbWn4lnL9ZKihL/RrfOV+oV" },
{ 76, 1, 0, { 0, }, "targets[].name", "4R26IDq+KqUiJBENeo8/GXkGLUH/87iPyzXKEMavr6fkrK0vTGto8yEYxmOyaVz8phG5rwf4jJgmYNoMbGo8gWvhqO7UAGy2g7MWv+B/t1eZZ+1euLsNrWAsFJiFbQKgdFfQT3RjB14iU8knlQ8usoy+pXssY2ddGJGVcGC21oZvstK9eu1eRZftda/wP+N5unT1Hw7kCoVzqxHieiYt47EGIOaaQ7XjZDK6qPN6O/grHnvJZm2vBkxuXgsYVk" },
{ 76, 1, 0, { 0, }, "targets[].name", "RQ7AuTWIecphqFsq7Wbc1YNbMW47SVU5zMD0WaCqbaaI0t4uIzRvPlD8cpiiTzFTrEHlIBTf8/uZjjEGGLhJR1jPqA9D1Ej3ChV+ye6F9JTUMlozRMsGuF8U4btDzH5xdnmvRS4Ar6LKEtAXGkj2yuyJln+v4RIWj2xOGPJovOqiXwi0FyM61f8U8gj0OiNA2/QlvrqQVDF7sMXgjvaE7iQt5vMETteZlx+z3f+jTFM/aon511W4+ZkRD+6AHw" },
{ 77, 1, 0, { 0, }, "targets[].name", "ucvM9BEC" },
{ 17, 1, 0, { 0, }, "targets[]", "ucvM9BEC" },
{ 15, 1, 0, { 0, }, "targets[]", "ucvM9BEC" },
{ 17, 1, 0, { 0, }, "targets[]", "ucvM9BEC" },
{ 3, 1, 0, { 0, }, "targets[]", "ucvM9BEC" },
}, r8[] = {
{ 0, 0, 0, { 0 }, "", "ucvM9BEC" },
{ 2, 0, 0, { 0 }, "", "ucvM9BEC" },
{ 16, 0, 0, { 0 }, "", "ucvM9BEC" },
{ 5, 0, 0, { 0 }, "schema", "ucvM9BEC" },
{ 11, 0, 0, { 0 }, "schema", "" },
{ 77, 0, 0, { 0 }, "schema", "com-warmcat-sai-logs" },
{ 5, 0, 0, { 0 }, "task_uuid", "com-warmcat-sai-logs" },
{ 11, 0, 0, { 0 }, "task_uuid", "" },
{ 77, 0, 0, { 0 }, "task_uuid", "97fc90052506af8b3eb43b87aaa6fb76feab32bc128ede479a8a6b961e801f06" },
{ 5, 0, 0, { 0 }, "timestamp", "97fc90052506af8b3eb43b87aaa6fb76feab32bc128ede479a8a6b961e801f06" },
{ 73, 0, 0, { 0 }, "timestamp", "170366786103" },
{ 5, 0, 0, { 0 }, "channel", "170366786103" },
{ 73, 0, 0, { 0 }, "channel", "3" },
{ 5, 0, 0, { 0 }, "len", "3" },
{ 73, 0, 0, { 0 }, "len", "20" },
{ 5, 0, 0, { 0 }, "log", "20" },
{ 11, 0, 0, { 0 }, "log", "" },
{ 77, 0, 0, { 0 }, "log", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
{ 17, 0, 0, { 0 }, "log", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
{ 3, 0, 0, { 0 }, "log", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
}, r9[] = {
{ 0, 0, 0, { 0 }, "", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
{ 2, 0, 0, { 0 }, "", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
{ 16, 0, 0, { 0 }, "", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
{ 5, 0, 0, { 0 }, "a", "PnNhaWI+IE5TU1RBVEVfSU5JVAo=" },
{ 73, 0, 0, { 0 }, "a", "123" },
{ 5, 0, 0, { 0 }, "b", "123" },
{ 16, 0, 0, { 0 }, "b", "123" },
{ 17, 0, 0, { 0 }, "b", "123" },
{ 17, 0, 0, { 0 }, "b", "123" },
{ 3, 0, 0, { 0 }, "b", "123" },
}, r10[] = {
{ 0, 0, 0, { 0 }, "", "123" },
{ 2, 0, 0, { 0 }, "", "123" },
{ 16, 0, 0, { 0 }, "", "123" },
{ 5, 0, 0, { 0 }, "a", "123" },
{ 73, 0, 0, { 0 }, "a", "123" },
{ 5, 0, 0, { 0 }, "b", "123" },
{ 4, 0, 0, { 0 }, "b", "123" },
}, r11[] = {
{ 0, 0, 0, { 0 }, "", "123" },
{ 2, 0, 0, { 0 }, "", "123" },
{ 16, 0, 0, { 0 }, "", "123" },
{ 5, 0, 0, { 0 }, "array1", "123" },
{ 14, 0, 0, { 0 }, "array1[]", "123" },
{ 14, 1, 0, { 0, }, "array1[][]", "123" },
{ 11, 2, 0, { 0, 0, }, "array1[][]", "" },
{ 77, 2, 0, { 0, 0, }, "array1[][]", "a" },
{ 11, 2, 0, { 0, 1, }, "array1[][]", "" },
{ 77, 2, 0, { 0, 1, }, "array1[][]", "b" },
{ 11, 2, 0, { 0, 2, }, "array1[][]", "" },
{ 77, 2, 0, { 0, 2, }, "array1[][]", "b1" },
{ 15, 1, 0, { 0, }, "array1[]", "b1" },
{ 14, 1, 0, { 1, }, "array1[][]", "b1" },
{ 11, 2, 0, { 1, 0, }, "array1[][]", "" },
{ 77, 2, 0, { 1, 0, }, "array1[][]", "c" },
{ 11, 2, 0, { 1, 1, }, "array1[][]", "" },
{ 77, 2, 0, { 1, 1, }, "array1[][]", "d" },
{ 11, 2, 0, { 1, 2, }, "array1[][]", "" },
{ 77, 2, 0, { 1, 2, }, "array1[][]", "d1" },
{ 15, 1, 0, { 1, }, "array1[]", "d1" },
{ 15, 1, 0, { 1, }, "array1[]", "d1" },
{ 5, 1, 0, { 1, }, "array2", "d1" },
{ 14, 1, 0, { 1, }, "array2[]", "d1" },
{ 14, 2, 0, { 1, 0, }, "array2[][]", "d1" },
{ 11, 3, 0, { 1, 0, 0, }, "array2[][]", "" },
{ 77, 3, 0, { 1, 0, 0, }, "array2[][]", "e" },
{ 11, 3, 0, { 1, 0, 1, }, "array2[][]", "" },
{ 77, 3, 0, { 1, 0, 1, }, "array2[][]", "f" },
{ 11, 3, 0, { 1, 0, 2, }, "array2[][]", "" },
{ 77, 3, 0, { 1, 0, 2, }, "array2[][]", "f1" },
{ 15, 2, 0, { 1, 0, }, "array2[]", "f1" },
{ 14, 2, 0, { 1, 1, }, "array2[][]", "f1" },
{ 11, 3, 0, { 1, 1, 0, }, "array2[][]", "" },
{ 77, 3, 0, { 1, 1, 0, }, "array2[][]", "g" },
{ 11, 3, 0, { 1, 1, 1, }, "array2[][]", "" },
{ 77, 3, 0, { 1, 1, 1, }, "array2[][]", "h" },
{ 11, 3, 0, { 1, 1, 2, }, "array2[][]", "" },
{ 77, 3, 0, { 1, 1, 2, }, "array2[][]", "h1" },
{ 15, 2, 0, { 1, 1, }, "array2[]", "h1" },
{ 15, 2, 0, { 1, 1, }, "array2[]", "h1" },
{ 17, 2, 0, { 1, 1, }, "array2[]", "h1" },
{ 3, 2, 0, { 1, 1, }, "array2[]", "h1" },
};
struct lejp_results_pkg {
const struct lejp_results *r;
size_t len;
} rpkg[] = {
{ r1, LWS_ARRAY_SIZE(r1) },
{ r2, LWS_ARRAY_SIZE(r2) },
{ r3, LWS_ARRAY_SIZE(r3) },
{ r4, LWS_ARRAY_SIZE(r4) },
{ r5, LWS_ARRAY_SIZE(r5) },
{ r6, LWS_ARRAY_SIZE(r6) },
{ r7, LWS_ARRAY_SIZE(r7) },
{ r8, LWS_ARRAY_SIZE(r8) },
{ r9, LWS_ARRAY_SIZE(r9) },
{ r10, LWS_ARRAY_SIZE(r10) },
{ r11, LWS_ARRAY_SIZE(r11) },
};
static const char * const tok[] = {
"something",
};
static unsigned int m, step;
static signed char
test_cb(struct lejp_ctx *ctx, char reason)
{
lwsl_info("%s: ctx->path %s, buf %s\n", __func__, ctx->path, ctx->buf);
char i[128];
int n, t = 0;
i[0] = 0;
for (n = 0; n < ctx->ipos; n++)
t += lws_snprintf(i + t, sizeof(i) - (size_t)t - 1ul, "%d, ", ctx->i[n]);
printf("{ %d, %d, %d, { %s }, \"%s\", \"%s\" },\n", reason, ctx->ipos, ctx->path_match, i, ctx->path, ctx->buf);
if (m < LWS_ARRAY_SIZE(rpkg)) {
if (step < rpkg[m].len) {
// lwsl_notice("test %d, step %d\n", m, step);
if (reason != rpkg[m].r[step].reason) {
lwsl_err("%s: reason mismatch %d vs %d\n", __func__, reason, rpkg[m].r[step].reason);
return -1;
}
if (ctx->ipos != rpkg[m].r[step].ipos) {
lwsl_err("%s: ipos mismatch %d vs %d\n", __func__, ctx->ipos, rpkg[m].r[step].ipos);
return -1;
}
if (ctx->ipos && memcmp(ctx->i, rpkg[m].r[step].indexes, ctx->ipos)) {
lwsl_err("%s: indexes mismatch\n", __func__);
lwsl_hexdump_err(ctx->i, ctx->ipos);
lwsl_hexdump_err(rpkg[m].r[step].indexes, ctx->ipos);
return -1;
}
if (ctx->path_match != rpkg[m].r[step].path_match) {
lwsl_err("%s: path_match mismatch %d vs %d\n", __func__, ctx->path_match, rpkg[m].r[step].path_match);
return -1;
}
if (strcmp(ctx->path, rpkg[m].r[step].path)) {
lwsl_err("%s: path mismatch '%s' vs '%s'\n", __func__, ctx->path, rpkg[m].r[step].path);
return -1;
}
if (strcmp(ctx->buf, rpkg[m].r[step].buf)) {
lwsl_err("%s: buf mismatch '%s' vs '%s'\n", __func__, ctx->buf, rpkg[m].r[step].buf);
return -1;
}
} else {
lwsl_err("%s: extra steps\n", __func__);
return -1;
}
step++;
}
return 0;
}
/* authz JSON parsing */
int main(int argc, const char **argv)
{
int n, m, e = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE;
int n, e = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE;
struct lejp_ctx ctx;
const char *p;
memset(&ctx, 0, sizeof(ctx));
if ((p = lws_cmdline_option(argc, argv, "-d")))
logs = atoi(p);
@ -158,7 +488,8 @@ int main(int argc, const char **argv)
for (m = 0; m < (int)LWS_ARRAY_SIZE(json_tests); m++) {
lwsl_info("%s: ++++++++++++++++ test %d\n", __func__, m + 1);
lwsl_user("%s: ++++++++++++++++ test %d\n", __func__, m + 1);
step = 0;
lejp_construct(&ctx, test_cb, NULL, tok, LWS_ARRAY_SIZE(tok));