Merge JSON5 support into 7.0

This commit is contained in:
Andrew Johnson
2021-01-05 21:39:15 -06:00
38 changed files with 1591 additions and 528 deletions
+22 -8
View File
@@ -10,6 +10,7 @@
newline "\n"
backslash "\\"
singlequote "'"
doublequote "\""
comment "#"
whitespace [ \t\r\n]
@@ -18,17 +19,30 @@ stringchar [^"\n\\]
bareword [a-zA-Z0-9_\-+:.\[\]<>;]
punctuation [:,\[\]{}]
normalchar [^"\\\0-\x1f]
normalchar [^"'\\\0-\x1f]
barechar [a-zA-Z0-9_\-+.]
escapedchar ({backslash}["\\/bfnrt])
escapedchar ({backslash}[^ux1-9])
hexdigit [0-9a-fA-F]
latinchar ({backslash}"x"{hexdigit}{2})
unicodechar ({backslash}"u"{hexdigit}{4})
jsonchar ({normalchar}|{escapedchar}|{unicodechar})
jsondqstr ({doublequote}{jsonchar}*{doublequote})
int ("-"?([0-9]|[1-9][0-9]+))
jsondqchar ({normalchar}|{singlequote}|{escapedchar}|{latinchar}|{unicodechar})
jsondqstr ({doublequote}{jsondqchar}*{doublequote})
jsonsqchar ({normalchar}|{doublequote}|{escapedchar}|{latinchar}|{unicodechar})
jsonsqstr ({singlequote}{jsonsqchar}*{singlequote})
jsonstr ({jsondqstr}|{jsonsqstr})
sign ([+-]?)
int ({sign}([0-9]|[1-9][0-9]+))
frac ("."[0-9]+)
exp ([eE][+-]?[0-9]+)
number ({int}{frac}?{exp}?)
exp ([eE]{sign}[0-9]+)
jsonnum ({int}{frac}?{exp}?)
intexp ({int}"."{exp}?)
fracexp ({sign}{frac}{exp}?)
specialnum ("NaN"|{sign}"Infinity")
zerox ("0x"|"0X")
hexint ({sign}{zerox}{hexdigit}+)
number ({jsonnum}|{intexp}|{fracexp}|{specialnum}|{hexint})
%{
#undef YY_INPUT
@@ -97,7 +111,7 @@ static int yyreset(void)
<JSON>{punctuation} return yytext[0];
<JSON>{jsondqstr} {
<JSON>{jsonstr} {
yylval.Str = dbmfStrdup((char *) yytext);
return jsonSTRING;
}
@@ -1172,12 +1172,14 @@ static void dbRecordField(char *name,char *value)
yyerror(NULL);
return;
}
if (*value == '"') {
if (*value == '"' || *value == '\'') {
/* jsonSTRING values still have their quotes */
value++;
value[strlen(value) - 1] = 0;
dbTranslateEscape(value, value); /* in-place; safe & legal */
}
dbTranslateEscape(value, value); /* in-place; safe & legal */
status = dbPutString(pdbentry,value);
if (status) {
char msg[128];
@@ -1203,12 +1205,14 @@ static void dbRecordInfo(char *name, char *value)
if (duplicate) return;
ptempListNode = (tempListNode *)ellFirst(&tempList);
pdbentry = ptempListNode->item;
if (*value == '"') {
if (*value == '"' || *value == '\'') {
/* jsonSTRING values still have their quotes */
value++;
value[strlen(value) - 1] = 0;
dbTranslateEscape(value, value); /* in-place; safe & legal */
}
dbTranslateEscape(value, value); /* yuck: in-place, but safe */
status = dbPutInfo(pdbentry,name,value);
if (status) {
epicsPrintf("Can't set \"%s\" info \"%s\" to \"%s\"\n",
+14 -3
View File
@@ -32,8 +32,8 @@ static int yyAbort = 0;
%token jsonNULL jsonTRUE jsonFALSE
%token <Str> jsonNUMBER jsonSTRING jsonBARE
%type <Str> json_value json_object json_array
%type <Str> json_members json_pair json_elements json_string
%type <Str> json_value json_string json_object json_array
%type <Str> json_members json_pair json_key json_elements
%%
@@ -299,13 +299,24 @@ json_members: json_pair
if (dbStaticDebug>2) printf("json %s\n", $$);
};
json_pair: json_string ':' json_value
json_pair: json_key ':' json_value
{
$$ = dbmfStrcat3($1, ":", $3);
dbmfFree($1); dbmfFree($3);
if (dbStaticDebug>2) printf("json %s\n", $$);
};
json_key: jsonSTRING
| jsonBARE
{
/* A key containing any of these characters must be quoted for YAJL */
if (strcspn($1, "+-.") < strlen($1)) {
$$ = dbmfStrcat3("\"", $1, "\"");
dbmfFree($1);
}
if (dbStaticDebug>2) printf("json %s\n", $$);
};
json_string: jsonSTRING
| jsonBARE
{
+42 -42
View File
@@ -612,7 +612,7 @@ MAIN(chfPluginTest)
/* tag i */
e1 = e_alloc; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"alloc-fail\":{\"i\":1}}")),
"x.{'alloc-fail':{i:1}}")),
"create channel for alloc-fail: allocPvt returning NULL");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
@@ -627,7 +627,7 @@ MAIN(chfPluginTest)
/* tag D (t and d) and f */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"strict-tagged\":{\"D\":1.2e15,\"f\":false}}")),
"x.{'strict-tagged':{D:1.2e15,f:false}}")),
"create channel for strict-tagged parsing: D (t and d) and f");
testOk(checkValues(puser1, 3, 12, 0, 1.2e15, "hello", 0, 4),
"guards intact, values correct");
@@ -641,7 +641,7 @@ MAIN(chfPluginTest)
/* tag D2 (t and d) and f */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"strict-tagged\":{\"D2\":1.2e15,\"f\":false}}")),
"x.{'strict-tagged':{D2:1.2e15,f:false}}")),
"create channel for strict-tagged parsing: D2 (t and d) and f");
testOk(checkValues(puser1, 4, 12, 0, 1.2e15, "hello", 0, 4),
"guards intact, values correct");
@@ -655,7 +655,7 @@ MAIN(chfPluginTest)
/* tag F: (t and f), d missing) */
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict-tagged\":{\"F\":false}}")),
"x.{'strict-tagged':{F:false}}")),
"create channel for strict-tagged parsing: F (t and f), d missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
@@ -663,7 +663,7 @@ MAIN(chfPluginTest)
/* tag I: (t and i) and f, d missing) */
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict-tagged\":{\"I\":1,\"f\":false}}")),
"x.{'strict-tagged':{I:1,f:false}}")),
"create channel for strict-tagged parsing: I (t and i) and f, d missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
@@ -676,7 +676,7 @@ MAIN(chfPluginTest)
/* tag i */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"sloppy-tagged\":{\"I\":1}}")),
"x.{'sloppy-tagged':{I:1}}")),
"create channel for sloppy-tagged parsing: I");
testOk(checkValues(puser1, 1, 1, 1, 1.234e5, "hello", 0, 4),
"guards intact, values correct");
@@ -690,7 +690,7 @@ MAIN(chfPluginTest)
/* tag f */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"sloppy-tagged\":{\"F\":false}}")),
"x.{'sloppy-tagged':{F:false}}")),
"create channel for sloppy-tagged parsing: F");
testOk(checkValues(puser1, 2, 12, 0, 1.234e5, "hello", 0, 4),
"guards intact, values correct");
@@ -704,7 +704,7 @@ MAIN(chfPluginTest)
/* tag d */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"sloppy-tagged\":{\"D\":1.2e15}}")),
"x.{'sloppy-tagged':{D:1.2e15}}")),
"create channel for sloppy-tagged parsing: D");
testOk(checkValues(puser1, 3, 12, 1, 1.2e15, "hello", 0, 4),
"guards intact, values correct");
@@ -718,7 +718,7 @@ MAIN(chfPluginTest)
/* tag s */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"sloppy-tagged\":{\"S\":\"bar\"}}")),
"x.{'sloppy-tagged':{S:'bar'}}")),
"create channel for sloppy-tagged parsing: S");
testOk(checkValues(puser1, 4, 12, 1, 1.234e5, "bar", 0, 4),
"guards intact, values correct");
@@ -732,7 +732,7 @@ MAIN(chfPluginTest)
/* tag c */
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"sloppy-tagged\":{\"C\":\"R\"}}")),
"x.{'sloppy-tagged':{C:'R'}}")),
"create channel for sloppy-tagged parsing: C");
testOk(checkValues(puser1, 5, 12, 1, 1.234e5, "hello", 0, 1),
"guards intact, values correct");
@@ -749,7 +749,7 @@ MAIN(chfPluginTest)
/* All perfect */
testHead("STRICT parsing: all ok");
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate("x.{\"strict\":{\"i\":1,\"f\":false,\"d\":1.2e15,\"s\":\"bar\",\"c\":\"R\"}}")),
testOk(!!(pch = dbChannelCreate("x.{strict:{i:1,f:false,d:1.2e15,s:'bar',c:'R'}}")),
"create channel for strict parsing: JSON correct");
testOk(checkValues(puser1, 99, 1, 0, 1.2e15, "bar", 0, 1),
"guards intact, values correct");
@@ -765,35 +765,35 @@ MAIN(chfPluginTest)
testHead("STRICT parsing: any missing parameter must fail");
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict\":{\"i\":1,\"f\":false,\"d\":1.2e15,\"s\":\"bar\"}}")),
"x.{strict:{i:1,f:false,d:1.2e15,s:'bar'}}")),
"create channel for strict parsing: c missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
testDiag("expected %#x - called %#x", e1, c1);
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict\":{\"f\":false,\"i\":1,\"d\":1.2e15,\"c\":\"R\"}}")),
"x.{strict:{f:false,i:1,d:1.2e15,c:'R'}}")),
"create channel for strict parsing: s missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
testDiag("expected %#x - called %#x", e1, c1);
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict\":{\"i\":1,\"c\":\"R\",\"f\":false,\"s\":\"bar\"}}")),
"x.{strict:{i:1,c:'R',f:false,s:'bar'}}")),
"create channel for strict parsing: d missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
testDiag("expected %#x - called %#x", e1, c1);
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict\":{\"d\":1.2e15,\"c\":\"R\",\"i\":1,\"s\":\"bar\"}}")),
"x.{strict:{d:1.2e15,c:'R',i:1,s:'bar'}}")),
"create channel for strict parsing: f missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
testDiag("expected %#x - called %#x", e1, c1);
e1 = e_alloc | e_error | e_free; c1 = 0;
testOk(!(pch = dbChannelCreate(
"x.{\"strict\":{\"c\":\"R\",\"s\":\"bar\",\"f\":false,\"d\":1.2e15}}")),
"x.{strict:{c:'R',s:'bar',f:false,d:1.2e15}}")),
"create channel for strict parsing: i missing");
testOk(!puser1, "user part cleaned up");
if (!testOk(c1 == e1, "all expected calls happened"))
@@ -805,7 +805,7 @@ MAIN(chfPluginTest)
testHead("NOCONV parsing: missing parameters get default value");
e1 = e_alloc | e_ok; c1 = 0;
testOk(!!(pch = dbChannelCreate(
"x.{\"noconv\":{\"i\":1,\"f\":false,\"d\":1.2e15,\"s\":\"bar\"}}")),
"x.{noconv:{i:1,f:false,d:1.2e15,s:'bar'}}")),
"create channel for noconv parsing: c missing");
testOk(checkValues(puser1, 99, 1, 0, 1.2e15, "bar", 0, 4),
"guards intact, values correct");
@@ -819,28 +819,28 @@ MAIN(chfPluginTest)
e1 = e_any;
testOk(!!(pch = dbChannelCreate(
"x.{\"noconv\":{\"i\":1,\"f\":false,\"d\":1.2e15,\"c\":\"R\"}}")),
"x.{noconv:{i:1,f:false,d:1.2e15,c:'R'}}")),
"create channel for noconv parsing: s missing");
testOk(checkValues(puser1, 99, 1, 0, 1.2e15, "hello", 0, 1),
"guards intact, values correct");
if (pch) dbChannelDelete(pch);
testOk(!!(pch = dbChannelCreate(
"x.{\"noconv\":{\"i\":1,\"f\":false,\"s\":\"bar\",\"c\":\"R\"}}")),
"x.{noconv:{i:1,f:false,s:'bar',c:'R'}}")),
"create channel for noconv parsing: d missing");
testOk(checkValues(puser1, 99, 1, 0, 1.234e5, "bar", 0, 1),
"guards intact, values correct");
if (pch) dbChannelDelete(pch);
testOk(!!(pch = dbChannelCreate(
"x.{\"noconv\":{\"i\":1,\"d\":1.2e15,\"s\":\"bar\",\"c\":\"R\"}}")),
"x.{noconv:{i:1,d:1.2e15,s:'bar',c:'R'}}")),
"create channel for noconv parsing: f missing");
testOk(checkValues(puser1, 99, 1, 1, 1.2e15, "bar", 0, 1),
"guards intact, values correct");
if (pch) dbChannelDelete(pch);
testOk(!!(pch = dbChannelCreate(
"x.{\"noconv\":{\"f\":false,\"d\":1.2e15,\"s\":\"bar\",\"c\":\"R\"}}")),
"x.{noconv:{f:false,d:1.2e15,s:'bar',c:'R'}}")),
"create channel for noconv parsing: i missing");
testOk(checkValues(puser1, 99, 12, 0, 1.2e15, "bar", 0, 1),
"guards intact, values correct");
@@ -849,7 +849,7 @@ MAIN(chfPluginTest)
/* Reject wrong types */
#define WRONGTYPETEST(Var, Val, Typ) \
e1 = e_alloc | e_error | e_free; c1 = 0; \
testOk(!(pch = dbChannelCreate("x.{\"noconv\":{\""#Var"\":"#Val"}}")), \
testOk(!(pch = dbChannelCreate("x.{noconv:{'"#Var"':"#Val"}}")), \
"create channel for noconv parsing: wrong type "#Typ" for "#Var); \
testOk(!puser1, "user part cleaned up"); \
if (!testOk(c1 == e1, "all expected calls happened")) \
@@ -877,8 +877,8 @@ MAIN(chfPluginTest)
#define CONVTESTGOOD(Var, Val, Typ, Ival, Fval, Dval, Sval1, Sval2, Cval) \
e1 = e_alloc | e_ok; c1 = 0; \
testDiag("Calling dbChannelCreate x.{\"sloppy\":{\""#Var"\":"#Val"}}"); \
testOk(!!(pch = dbChannelCreate("x.{\"sloppy\":{\""#Var"\":"#Val"}}")), \
testDiag("Calling dbChannelCreate x.{sloppy:{"#Var":"#Val"}}"); \
testOk(!!(pch = dbChannelCreate("x.{sloppy:{"#Var":"#Val"}}")), \
"create channel for sloppy parsing: "#Typ" (good) for "#Var); \
testOk(checkValues(puser1, 99, Ival, Fval, Dval, Sval1, Sval2, Cval), \
"guards intact, values correct"); \
@@ -892,8 +892,8 @@ MAIN(chfPluginTest)
#define CONVTESTBAD(Var, Val, Typ) \
e1 = e_alloc | e_error | e_free; c1 = 0; \
testDiag("Calling dbChannelCreate x.{\"sloppy\":{\""#Var"\":"#Val"}}"); \
testOk(!(pch = dbChannelCreate("x.{\"sloppy\":{\""#Var"\":"#Val"}}")), \
testDiag("Calling dbChannelCreate x.{sloppy:{"#Var":"#Val"}}"); \
testOk(!(pch = dbChannelCreate("x.{sloppy:{"#Var":"#Val"}}")), \
"create channel for sloppy parsing: "#Typ" (bad) for "#Var); \
testOk(!puser1, "user part cleaned up"); \
if (!testOk(c1 == e1, "create channel: all expected calls happened")) \
@@ -1018,36 +1018,36 @@ MAIN(chfPluginTest)
if (!testOk(c1 == e1, "delete channel (1): all expected calls happened")) testDiag("expected %#x - called %#x", e1, c1); \
if (!testOk(c2 == e2, "delete channel (2): all expected calls happened")) testDiag("expected %#x - called %#x", e2, c2);
CHAINTEST1("1 pre", "{\"pre\":{}}", e_reg_pre, e_pre | e_dtor, 1); /* One filter, pre chain */
CHAINTEST1("1 post", "{\"post\":{}}", e_reg_post, e_post | e_dtor, 1); /* One filter, post chain */
CHAINTEST1("1 both", "{\"sloppy\":{}}", e_reg_pre | e_reg_post, e_pre | e_post | e_dtor, 2); /* One, both chains */
CHAINTEST2("2 pre", "{\"pre\":{},\"pre\":{}}", e_reg_pre, e_pre | e_dtor, e_reg_pre, e_pre, 2); /* Two filters, pre chain */
CHAINTEST2("2 post", "{\"post\":{},\"post\":{}}", e_reg_post, e_post | e_dtor, e_reg_post, e_post, 2); /* Two filters, post chain */
CHAINTEST2("2 both", "{\"sloppy\":{},\"sloppy\":{}}", /* Two, both chains */
CHAINTEST1("1 pre", "{pre:{}}", e_reg_pre, e_pre | e_dtor, 1); /* One filter, pre chain */
CHAINTEST1("1 post", "{post:{}}", e_reg_post, e_post | e_dtor, 1); /* One filter, post chain */
CHAINTEST1("1 both", "{sloppy:{}}", e_reg_pre | e_reg_post, e_pre | e_post | e_dtor, 2); /* One, both chains */
CHAINTEST2("2 pre", "{pre:{},pre:{}}", e_reg_pre, e_pre | e_dtor, e_reg_pre, e_pre, 2); /* Two filters, pre chain */
CHAINTEST2("2 post", "{post:{},post:{}}", e_reg_post, e_post | e_dtor, e_reg_post, e_post, 2); /* Two filters, post chain */
CHAINTEST2("2 both", "{sloppy:{},sloppy:{}}", /* Two, both chains */
e_reg_pre | e_reg_post, e_pre | e_post | e_dtor, e_reg_pre | e_reg_post, e_pre | e_post, 4);
CHAINTEST2("1 pre, 1 post", "{\"pre\":{},\"post\":{}}", e_reg_pre, e_pre | e_dtor, e_reg_post, e_post, 2); /* Two, pre then post */
CHAINTEST2("1 post, 1 pre", "{\"post\":{},\"pre\":{}}", e_reg_post, e_post, e_reg_pre, e_pre | e_dtor, 2); /* Two, post then pre */
CHAINTEST2("1 pre, 1 both", "{\"pre\":{},\"sloppy\":{}}", /* Two, pre then both */
CHAINTEST2("1 pre, 1 post", "{pre:{},post:{}}", e_reg_pre, e_pre | e_dtor, e_reg_post, e_post, 2); /* Two, pre then post */
CHAINTEST2("1 post, 1 pre", "{post:{},pre:{}}", e_reg_post, e_post, e_reg_pre, e_pre | e_dtor, 2); /* Two, post then pre */
CHAINTEST2("1 pre, 1 both", "{pre:{},sloppy:{}}", /* Two, pre then both */
e_reg_pre, e_pre | e_dtor, e_reg_pre | e_reg_post, e_pre | e_post, 3);
CHAINTEST2("1 both, 1 pre", "{\"sloppy\":{},\"pre\":{}}", /* Two, both then pre */
CHAINTEST2("1 both, 1 pre", "{sloppy:{},pre:{}}", /* Two, both then pre */
e_reg_pre | e_reg_post, e_pre | e_post | e_dtor, e_reg_pre, e_pre, 3);
CHAINTEST2("1 post, 1 both", "{\"post\":{},\"sloppy\":{}}", /* Two, post then both */
CHAINTEST2("1 post, 1 both", "{post:{},sloppy:{}}", /* Two, post then both */
e_reg_post, e_post, e_reg_pre | e_reg_post, e_pre | e_post | e_dtor, 3);
CHAINTEST2("1 both, 1 post", "{\"sloppy\":{},\"post\":{}}", /* Two, both then post */
CHAINTEST2("1 both, 1 post", "{sloppy:{},post:{}}", /* Two, both then post */
e_reg_pre | e_reg_post, e_pre | e_post | e_dtor, e_reg_post, e_post, 3);
/* Plugins dropping updates */
drop = 0;
CHAINTEST2("2 both (drop at 0)", "{\"sloppy\":{},\"sloppy\":{}}", /* Two, both chains, drop at filter 0 */
CHAINTEST2("2 both (drop at 0)", "{sloppy:{},sloppy:{}}", /* Two, both chains, drop at filter 0 */
e_reg_pre | e_reg_post, e_pre, e_reg_pre | e_reg_post, 0, -1);
drop = 1;
CHAINTEST2("2 both (drop at 1)", "{\"sloppy\":{},\"sloppy\":{}}", /* Two, both chains, drop at filter 1 */
CHAINTEST2("2 both (drop at 1)", "{sloppy:{},sloppy:{}}", /* Two, both chains, drop at filter 1 */
e_reg_pre | e_reg_post, e_pre, e_reg_pre | e_reg_post, e_pre, -1);
drop = 2;
CHAINTEST2("2 both (drop at 2)", "{\"sloppy\":{},\"sloppy\":{}}", /* Two, both chains, drop at filter 2 */
CHAINTEST2("2 both (drop at 2)", "{sloppy:{},sloppy:{}}", /* Two, both chains, drop at filter 2 */
e_reg_pre | e_reg_post, e_pre | e_post, e_reg_pre | e_reg_post, e_pre, -1);
drop = 3;
CHAINTEST2("2 both (drop at 3)", "{\"sloppy\":{},\"sloppy\":{}}", /* Two, both chains, drop at filter 3 */
CHAINTEST2("2 both (drop at 3)", "{sloppy:{},sloppy:{}}", /* Two, both chains, drop at filter 3 */
e_reg_pre | e_reg_post, e_pre | e_post, e_reg_pre | e_reg_post, e_pre | e_post, -1);
drop = -1;
+11 -11
View File
@@ -183,7 +183,7 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
/* dbChannelTest() allows but ignores field modifiers */
testOk1(!dbChannelTest("x.NAME$"));
testOk1(!dbChannelTest("x.{}"));
testOk1(!dbChannelTest("x.VAL{\"json\":true}"));
testOk1(!dbChannelTest("x.VAL{json:true}"));
/* dbChannelCreate() accepts field modifiers */
testOk1(!!(pch = dbChannelCreate("x.{}")));
@@ -212,34 +212,34 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
testOk(!dbChannelCreate("x.NOFIELD"), "Create, bad field");
testOk(!dbChannelCreate("x.{not-json}"), "Create, bad JSON");
eltc(0);
testOk(!dbChannelCreate("x.{\"none\":null}"), "Create, bad filter");
testOk(!dbChannelCreate("x.{none:null}"), "Create, bad filter");
eltc(1);
dbRegisterFilter("any", &testIf, NULL);
/* Parser event rejection by filter */
e = e_start;
testOk1(!dbChannelCreate("x.{\"any\":null}"));
testOk1(!dbChannelCreate("x.{any:null}"));
r = e_start;
e = e_start | e_null | e_abort;
testOk1(!dbChannelCreate("x.{\"any\":null}"));
testOk1(!dbChannelCreate("x.{any:null}"));
r = e_start | e_null;
e = e_start | e_null | e_end;
testOk1(!dbChannelCreate("x.{\"any\":null}"));
testOk1(!dbChannelCreate("x.{any:null}"));
/* Successful parsing... */
r = r_any;
e = e_start | e_null | e_end;
testOk1(!!(pch = dbChannelCreate("x.{\"any\":null}")));
testOk1(!!(pch = dbChannelCreate("x.{any:null}")));
e = e_close;
if (pch) dbChannelDelete(pch);
dbRegisterFilter("scalar", &testIf, NULL);
e = e_start | e_null | e_end;
testOk1(!!(pch = dbChannelCreate("x.{\"scalar\":null}")));
testOk1(!!(pch = dbChannelCreate("x.{scalar:null}")));
e = e_report;
dbChannelShow(pch, 2, 2);
@@ -249,23 +249,23 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
e = e_start | e_start_array | e_boolean | e_integer | e_end_array
| e_end;
testOk1(!!(pch = dbChannelCreate("x.{\"any\":[true,1]}")));
testOk1(!!(pch = dbChannelCreate("x.{any:[true,1]}")));
e = e_close;
if (pch) dbChannelDelete(pch);
e = e_start | e_start_map | e_map_key | e_double | e_string | e_end_map
| e_end;
testOk1(!!(pch = dbChannelCreate("x.{\"any\":{\"a\":2.7183,\"b\":\"c\"}}")));
testOk1(!!(pch = dbChannelCreate("x.{any:{a:2.7183,b:'c'}}")));
e = e_close;
if (pch) dbChannelDelete(pch);
/* More event rejection */
r = r_scalar;
e = e_start | e_start_array | e_abort;
testOk1(!dbChannelCreate("x.{\"scalar\":[null]}"));
testOk1(!dbChannelCreate("x.{scalar:[null]}"));
e = e_start | e_start_map | e_abort;
testOk1(!dbChannelCreate("x.{\"scalar\":{}}"));
testOk1(!dbChannelCreate("x.{scalar:{}}"));
testIocShutdownOk();
testdbCleanup();
+9 -6
View File
@@ -67,6 +67,7 @@ static const struct testParseDataT {
{" #B111 C112 N113 @cparam", {CAMAC_IO, "cparam", 0, "BCN", {111, 112, 113}}},
{" @hello world ", {INST_IO, "hello world", 0, "", /*{}*/}},
{" {\"x\":true} ", {JSON_LINK, "{\"x\":true}", 0, "", /*{}*/}},
{" {'x':true} ", {JSON_LINK, "{'x':true}", 0, "", /*{}*/}},
{NULL}
};
@@ -255,7 +256,7 @@ typedef struct {
} testHWDataT;
static const testHWDataT testHWData[] = {
{"rJSON_LINK", JSON_LINK, "{\"x\":true}", {0}, "{\"x\":true}"},
{"rJSON_LINK", JSON_LINK, "{x:true}", {0}, "{x:true}"},
{"rVME_IO", VME_IO, "#C100 S101 @parm VME_IO", {100, 101}, "parm VME_IO"},
{"rCAMAC_IO", CAMAC_IO, "#B11 C12 N13 A14 F15 @parm CAMAC_IO", {11, 12, 13, 14, 15}, "parm CAMAC_IO"},
{"rAB_IO", AB_IO, "#L21 A22 C23 S24 @parm AB_IO", {21, 22, 23, 24}, "parm AB_IO"},
@@ -585,9 +586,11 @@ void testJLink(void)
testdbPutFieldOk("j2.PROC", DBF_LONG, 1);
testdbPutFieldOk("j3.PROC", DBF_LONG, 1);
testdbGetFieldEqual("j1.INP", DBF_STRING, "{\"z\":{\"good\":1}}");
testdbGetFieldEqual("j1.INP", DBF_STRING, "{z:{good:1}}");
testdbGetFieldEqual("j1.VAL", DBF_LONG, 1);
testdbGetFieldEqual("j2.INP", DBF_STRING, "{\"z\":{'good':2}}");
testdbGetFieldEqual("j2.VAL", DBF_LONG, 2);
testdbGetFieldEqual("j2.TSEL", DBF_STRING, "j1.TIME NPP NMS");
testdbGetFieldEqual("j3.VAL", DBF_LONG, 3);
testNumZ(6);
@@ -596,7 +599,7 @@ void testJLink(void)
testdbPutFieldOk("j1.PROC", DBF_LONG, 1);
testdbGetFieldEqual("j1.VAL", DBF_LONG, 4);
testdbPutFieldOk("j2.TSEL", DBF_STRING, "{\"z\":{\"good\":0}}");
testdbPutFieldOk("j2.TSEL", DBF_STRING, "{'z':{good:0}}");
testdbPutFieldOk("j2.PROC", DBF_LONG, 1);
testNumZ(7);
@@ -611,8 +614,8 @@ void testJLink(void)
testNumZ(7);
/* Check SDIS using a JSON link prevents processing */
testdbPutFieldOk("j1.SDIS", DBF_STRING, "{\"z\":{\"good\":1}}");
testdbPutFieldOk("j1.INP", DBF_STRING, "{\"z\":{\"good\":1}}");
testdbPutFieldOk("j1.SDIS", DBF_STRING, "{z:{good:1}}");
testdbPutFieldOk("j1.INP", DBF_STRING, "{z:{good:1}}");
testdbPutFieldOk("j1.PROC", DBF_LONG, 1);
testdbGetFieldEqual("j1.VAL", DBF_LONG, 4);
@@ -697,7 +700,7 @@ void testTSEL(void)
MAIN(dbPutLinkTest)
{
testPlan(337);
testPlan(342);
testLinkParse();
testLinkFailParse();
testCADBSet();
@@ -7,8 +7,8 @@ record(x, "j1") {
}
record(x, "j2") {
field(INP, {z:{good:2}})
field(TSEL, "j1.TIME")
field(INP, {"z":{'good':2}})
field(TSEL, 'j1.TIME')
}
record(x, "j3") {
+106 -5
View File
@@ -148,27 +148,128 @@ static void testDbVerify(const char *record)
if (dbFindRecord(&entry, record) != 0)
testAbort("Can't find record '%s'", record);
dbFindField(&entry, "UDF");
dbFindField(&entry, "C8");
verify(&entry, "0", NULL);
verify(&entry, "-128", NULL);
verify(&entry, "127", NULL);
verify(&entry, "128", "Number too large for field type");
verify(&entry, "0x7f", NULL);
verify(&entry, "0x80", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "U8");
verify(&entry, "0", NULL);
verify(&entry, "128", NULL);
verify(&entry, "255", NULL);
verify(&entry, "256", "Number too large for field type");
verify(&entry, "0xff", NULL);
verify(&entry, "0x100", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "PHAS");
dbFindField(&entry, "I16");
verify(&entry, "0", NULL);
verify(&entry, "-32768", NULL);
verify(&entry, "-32769", "Number too large for field type");
verify(&entry, "0x7fff", NULL);
verify(&entry, "32768", "Number too large for field type");
verify(&entry, "-0x8000", NULL);
verify(&entry, "0x7fff", NULL);
verify(&entry, "0x8000", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "VAL");
dbFindField(&entry, "U16");
verify(&entry, "0", NULL);
verify(&entry, "-32768", NULL);
verify(&entry, "-65535", NULL);
verify(&entry, "-65536", "Number too large for field type");
verify(&entry, "65535", NULL);
verify(&entry, "0xffff", NULL);
verify(&entry, "0x10000", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "I32");
verify(&entry, "0", NULL);
verify(&entry, "-123456789", NULL);
verify(&entry, "123456789", NULL);
verify(&entry, "-0x80000000", NULL);
verify(&entry, "-0x80000001", "Number too large for field type");
verify(&entry, "0x1234FEDC", NULL);
verify(&entry, "0x7fffffff", NULL);
verify(&entry, "0x100000000", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "U32");
verify(&entry, "0", NULL);
verify(&entry, "-123456789", NULL);
verify(&entry, "123456789", NULL);
verify(&entry, "-0xffffffff", NULL);
verify(&entry, "-0x100000000", "Number too large for field type");
verify(&entry, "0x1234FEDC", NULL);
verify(&entry, "0xffffffff", NULL);
verify(&entry, "0x100000000", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "I64");
verify(&entry, "0", NULL);
verify(&entry, "-1234567890123456789", NULL);
verify(&entry, "1234567890123456789", NULL);
verify(&entry, "-0x8000000000000000", NULL);
verify(&entry, "-0x8000000000000001", "Number too large for field type");
verify(&entry, "0x123456780FEDCBA9", NULL);
verify(&entry, "0x7fffffffffffffff", NULL);
verify(&entry, "0x10000000000000000", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "U64");
verify(&entry, "0", NULL);
verify(&entry, "-1234567890123456789", NULL);
verify(&entry, "1234567890123456789", NULL);
verify(&entry, "-0xffffffffffffffff", NULL);
verify(&entry, "-0x10000000000000000", "Number too large for field type");
verify(&entry, "0x123456780FEDCBA9", NULL);
verify(&entry, "0x7fffffffffffffff", NULL);
verify(&entry, "0x10000000000000000", "Number too large for field type");
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2345", "Extraneous characters after number");
dbFindField(&entry, "F32");
verify(&entry, "0", NULL);
verify(&entry, "1.2345", NULL);
verify(&entry, ".12345", NULL);
verify(&entry, "-.12345", NULL);
verify(&entry, "+.12345", NULL);
verify(&entry, "1.e23", NULL);
verify(&entry, "1.e-23", NULL);
verify(&entry, "Infinity", NULL);
verify(&entry, "-Infinity", NULL);
verify(&entry, "+Infinity", NULL);
verify(&entry, "Nan", NULL);
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2e-345", "Number too small for field type");
verify(&entry, "1.2e345", "Number too large for field type");
dbFindField(&entry, "F64");
verify(&entry, "0", NULL);
verify(&entry, "1.2345", NULL);
verify(&entry, ".12345", NULL);
verify(&entry, "-.12345", NULL);
verify(&entry, "+.12345", NULL);
verify(&entry, "1.e234", NULL);
verify(&entry, "1.e-234", NULL);
verify(&entry, "Infinity", NULL);
verify(&entry, "-Infinity", NULL);
verify(&entry, "+Infinity", NULL);
verify(&entry, "Nan", NULL);
verify(&entry, "None", "Not a valid integer");
verify(&entry, "1.2e-345", "Number too small for field type");
verify(&entry, "1.2e345", "Number too large for field type");
dbFindField(&entry, "DESC");
verify(&entry, "", NULL);
verify(&entry, "abcdefghijklmnopqrstuvwxyz", NULL);
@@ -193,7 +294,7 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
MAIN(dbStaticTest)
{
testPlan(223);
testPlan(310);
testdbPrepare();
testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);
@@ -6,3 +6,82 @@ record(x, "testrec") {
alias("testrec", "testalias2")
alias("testalias2", "testalias3")
# New number formats allowed in JSON5, show dbLex/dbYacc parsing
record(x, "t1") {
field( C8, +12)
field( U8, +123)
field(I16, +1234)
field(U16, +12345)
field(I32, +123456)
field(U32, +1234567)
field(I64, +12345678)
field(U64, +123456789)
field( C8, 0x1)
field( U8, 0x12)
field(I16, 0x123)
field(U16, 0x1234)
field(I32, 0x12345)
field(U32, 0x123456)
field(I64, 0x1234567)
field(U64, 0x12345678)
field( C8, +0x1)
field( U8, -0x12)
field(I16, +0x123)
field(U16, -0x1234)
field(I32, +0x12345)
field(U32, -0x123456)
field(I64, +0x1234567)
field(U64, -0x12345678)
field( C8, 0x7f)
field( U8, 0xff)
field(I16, 0x7fff)
field(I16, -0x8000)
field(U16, 0xffff)
field(I32, 0x7fffffff)
field(I32, -0x80000000)
field(U32, 0xffffffff)
field(I64, 0x7fffffffffffffff)
field(I64, -0x8000000000000000)
field(U64, 0xffffffffffffffff)
field(F32, .123)
field(F64, .123)
field(F32, 123.)
field(F64, 123.)
field(F32, +.123)
field(F64, +.123)
field(F32, +123.)
field(F64, +123.)
field(F32, -.123)
field(F64, -.123)
field(F32, -123.)
field(F64, -123.)
field(F32, .123e4)
field(F64, .123e4)
field(F32, 123.e4)
field(F64, 123.e4)
field(F32, 123.e+4)
field(F64, 123.e+4)
field(F32, 123.e-4)
field(F64, 123.e-4)
field(F32, +.123e4)
field(F64, +.123e4)
field(F32, +123.e4)
field(F64, +123.e4)
field(F32, -.123e4)
field(F64, -.123e4)
field(F32, -123.e4)
field(F64, -123.e4)
field(F32, Infinity)
field(F64, Infinity)
field(F32, +Infinity)
field(F64, +Infinity)
field(F32, -Infinity)
field(F64, -Infinity)
field(F32, Nan)
field(F64, Nan)
info(i1, {x:0, +x:1, -x:2, .x:3})
info(i2, Bare-word_string)
}
+30
View File
@@ -5,6 +5,36 @@ recordtype(x) {
field(VAL, DBF_LONG) {
prompt("Value")
}
field(C8, DBF_CHAR) {
prompt("Char")
}
field(U8, DBF_UCHAR) {
prompt("Byte")
}
field(I16, DBF_SHORT) {
prompt("Short")
}
field(U16, DBF_USHORT) {
prompt("UShort")
}
field(I32, DBF_LONG) {
prompt("Integer")
}
field(U32, DBF_ULONG) {
prompt("Unsigned")
}
field(I64, DBF_INT64) {
prompt("Long")
}
field(U64, DBF_UINT64) {
prompt("ULong")
}
field(F32, DBF_FLOAT) {
prompt("Float")
}
field(F64, DBF_DOUBLE) {
prompt("Double")
}
field(LNK, DBF_INLINK) {
prompt("Link")
}
@@ -178,7 +178,7 @@ static void check(short dbr_type) {
/* Default: should not change anything */
testHead("Ten %s elements from rec, increment 1, full size (default)", typname);
createAndOpen(valname, "{\"arr\":{}}", "(default)", &pch, 1);
createAndOpen(valname, "{arr:{}}", "(default)", &pch, 1);
testOk(pch->final_type == valaddr.field_type,
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type);
testOk(pch->final_no_elements == valaddr.no_elements,
@@ -188,7 +188,7 @@ static void check(short dbr_type) {
dbChannelDelete(pch);
testHead("Ten %s elements from rec, increment 1, out-of-bound start parameter", typname);
createAndOpen(valname, "{\"arr\":{\"s\":-500}}", "out-of-bound start", &pch, 1);
createAndOpen(valname, "{arr:{s:-500}}", "out-of-bound start", &pch, 1);
testOk(pch->final_type == valaddr.field_type,
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type);
testOk(pch->final_no_elements == valaddr.no_elements,
@@ -197,7 +197,7 @@ static void check(short dbr_type) {
dbChannelDelete(pch);
testHead("Ten %s elements from rec, increment 1, out-of-bound end parameter", typname);
createAndOpen(valname, "{\"arr\":{\"e\":500}}", "out-of-bound end", &pch, 1);
createAndOpen(valname, "{arr:{e:500}}", "out-of-bound end", &pch, 1);
testOk(pch->final_type == valaddr.field_type,
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type);
testOk(pch->final_no_elements == valaddr.no_elements,
@@ -206,7 +206,7 @@ static void check(short dbr_type) {
dbChannelDelete(pch);
testHead("Ten %s elements from rec, increment 1, zero increment parameter", typname);
createAndOpen(valname, "{\"arr\":{\"i\":0}}", "zero increment", &pch, 1);
createAndOpen(valname, "{arr:{i:0}}", "zero increment", &pch, 1);
testOk(pch->final_type == valaddr.field_type,
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type);
testOk(pch->final_no_elements == valaddr.no_elements,
@@ -215,7 +215,7 @@ static void check(short dbr_type) {
dbChannelDelete(pch);
testHead("Ten %s elements from rec, increment 1, invalid increment parameter", typname);
createAndOpen(valname, "{\"arr\":{\"i\":-30}}", "invalid increment", &pch, 1);
createAndOpen(valname, "{arr:{i:-30}}", "invalid increment", &pch, 1);
testOk(pch->final_type == valaddr.field_type,
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type);
testOk(pch->final_no_elements == valaddr.no_elements,
@@ -225,7 +225,7 @@ static void check(short dbr_type) {
#define TEST5(Incr, Left, Right, Type) \
testHead("Five %s elements from rec, increment " #Incr ", " Type " addressing", typname); \
createAndOpen(valname, "{\"arr\":{\"s\":" #Left ",\"e\":" #Right ",\"i\":" #Incr "}}", \
createAndOpen(valname, "{arr:{s:" #Left ",e:" #Right ",i:" #Incr "}}", \
"(" #Left ":" #Incr ":" #Right ")", &pch, 1); \
testOk(pch->final_type == valaddr.field_type, \
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type); \
@@ -262,7 +262,7 @@ static void check(short dbr_type) {
#define TEST5B(Incr, Left, Right, Type) \
testHead("Five %s elements from buffer, increment " #Incr ", " Type " addressing", typname); \
createAndOpen(valname, "{\"arr\":{},\"arr\":{\"s\":" #Left ",\"e\":" #Right ",\"i\":" #Incr "}}", \
createAndOpen(valname, "{arr:{},arr:{s:" #Left ",e:" #Right ",i:" #Incr "}}", \
"(" #Left ":" #Incr ":" #Right ")", &pch, 2); \
testOk(pch->final_type == valaddr.field_type, \
"final type unchanged (%d->%d)", valaddr.field_type, pch->final_type); \
+4 -4
View File
@@ -148,7 +148,7 @@ MAIN(dbndTest)
testOk(!!(plug = dbFindFilter(dbnd, strlen(dbnd))), "plugin dbnd registered correctly");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dbnd\":{}}")), "dbChannel with plugin dbnd (delta=0) created");
testOk(!!(pch = dbChannelCreate("x.VAL{dbnd:{}}")), "dbChannel with plugin dbnd (delta=0) created");
testOk((ellCount(&pch->filters) == 1), "channel has one plugin");
/* Start the free-list */
@@ -202,7 +202,7 @@ MAIN(dbndTest)
/* Delta = -1: pass any update */
testHead("Delta = -1: pass any update");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dbnd\":{\"d\":-1.0}}")), "dbChannel with plugin dbnd (delta=-1) created");
testOk(!!(pch = dbChannelCreate("x.VAL{dbnd:{d:-1.0}}")), "dbChannel with plugin dbnd (delta=-1) created");
testOk(!(dbChannelOpen(pch)), "dbChannel with plugin dbnd opened");
pfl2 = db_create_read_log(pch);
@@ -220,7 +220,7 @@ MAIN(dbndTest)
/* Delta = absolute */
testHead("Delta = absolute");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dbnd\":{\"d\":3}}")), "dbChannel with plugin dbnd (delta=3) created");
testOk(!!(pch = dbChannelCreate("x.VAL{dbnd:{d:3}}")), "dbChannel with plugin dbnd (delta=3) created");
testOk(!(dbChannelOpen(pch)), "dbChannel with plugin dbnd opened");
pfl2 = db_create_read_log(pch);
@@ -254,7 +254,7 @@ MAIN(dbndTest)
/* Delta = relative */
testHead("Delta = relative");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dbnd\":{\"m\":\"rel\",\"d\":50}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{dbnd:{m:'rel',d:50}}")),
"dbChannel with plugin dbnd (mode=rel, delta=50) created");
testOk(!(dbChannelOpen(pch)), "dbChannel with plugin dbnd opened");
+8 -8
View File
@@ -149,20 +149,20 @@ MAIN(decTest)
"plugin '%s' registered correctly", myname);
/* N < 1 */
testOk(!(pch = dbChannelCreate("x.VAL{\"dec\":{\"n\":-1}}")),
testOk(!(pch = dbChannelCreate("x.VAL{dec:{n:-1}}")),
"dbChannel with dec (n=-1) failed");
testOk(!(pch = dbChannelCreate("x.VAL{\"dec\":{\"n\":0}}")),
testOk(!(pch = dbChannelCreate("x.VAL{dec:{n:0}}")),
"dbChannel with dec (n=0) failed");
/* Bad parms */
testOk(!(pch = dbChannelCreate("x.VAL{\"dec\":{}}")),
testOk(!(pch = dbChannelCreate("x.VAL{dec:{}}")),
"dbChannel with dec (no parm) failed");
testOk(!(pch = dbChannelCreate("x.VAL{\"dec\":{\"x\":true}}")),
testOk(!(pch = dbChannelCreate("x.VAL{dec:{x:true}}")),
"dbChannel with dec (x=true) failed");
/* No Decimation (N=1) */
testHead("No Decimation (n=1)");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dec\":{\"n\":1}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{dec:{n:1}}")),
"dbChannel with plugin dec (n=1) created");
/* Start the free-list */
@@ -192,7 +192,7 @@ MAIN(decTest)
/* Decimation (N=2) */
testHead("Decimation (n=2)");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dec\":{\"n\":2}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{dec:{n:2}}")),
"dbChannel with plugin dec (n=2) created");
checkAndOpenChannel(pch, plug);
@@ -222,7 +222,7 @@ MAIN(decTest)
/* Decimation (N=3) */
testHead("Decimation (n=3)");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dec\":{\"n\":3}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{dec:{n:3}}")),
"dbChannel with plugin dec (n=3) created");
checkAndOpenChannel(pch, plug);
@@ -252,7 +252,7 @@ MAIN(decTest)
/* Decimation (N=4) */
testHead("Decimation (n=4)");
testOk(!!(pch = dbChannelCreate("x.VAL{\"dec\":{\"n\":4}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{dec:{n:4}}")),
"dbChannel with plugin dec (n=4) created");
checkAndOpenChannel(pch, plug);
+9 -9
View File
@@ -225,19 +225,19 @@ MAIN(syncTest)
testOk(!!(red = dbStateCreate("red")), "state 'red' created successfully");
/* nonexisting state */
testOk(!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"while\",\"s\":\"blue\"}}")),
testOk(!(pch = dbChannelCreate("x.VAL{sync:{m:'while',s:'blue'}}")),
"dbChannel with sync (m='while' s='blue') (nonex state) failed");
/* missing state */
testOk(!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"while\"}}")),
testOk(!(pch = dbChannelCreate("x.VAL{sync:{m:'while'}}")),
"dbChannel with sync (m='while') (no state) failed");
/* missing mode */
testOk(!(pch = dbChannelCreate("x.VAL{\"sync\":{\"s\":\"red\"}}")),
testOk(!(pch = dbChannelCreate("x.VAL{sync:{s:'red'}}")),
"dbChannel with sync (s='red') (no mode) failed");
/* mode WHILE */
testHead("Mode WHILE (m='while', s='red')");
testOk(!!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"while\",\"s\":\"red\"}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{sync:{m:'while',s:'red'}}")),
"dbChannel with plugin sync (m='while' s='red') created");
/* Start the free-list */
@@ -274,7 +274,7 @@ MAIN(syncTest)
/* mode UNLESS */
testHead("Mode UNLESS (m='unless', s='red')");
testOk(!!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"unless\",\"s\":\"red\"}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{sync:{m:'unless',s:'red'}}")),
"dbChannel with plugin sync (m='unless' s='red') created");
checkAndOpenChannel(pch, plug);
@@ -306,7 +306,7 @@ MAIN(syncTest)
/* mode BEFORE */
testHead("Mode BEFORE (m='before', s='red')");
testOk(!!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"before\",\"s\":\"red\"}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{sync:{m:'before',s:'red'}}")),
"dbChannel with plugin sync (m='before' s='red') created");
checkAndOpenChannel(pch, plug);
@@ -340,7 +340,7 @@ MAIN(syncTest)
/* mode FIRST */
testHead("Mode FIRST (m='first', s='red')");
testOk(!!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"first\",\"s\":\"red\"}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{sync:{m:'first',s:'red'}}")),
"dbChannel with plugin sync (m='first' s='red') created");
checkAndOpenChannel(pch, plug);
@@ -373,7 +373,7 @@ MAIN(syncTest)
/* mode LAST */
testHead("Mode LAST (m='last', s='red')");
testOk(!!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"last\",\"s\":\"red\"}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{sync:{m:'last',s:'red'}}")),
"dbChannel with plugin sync (m='last' s='red') created");
checkAndOpenChannel(pch, plug);
@@ -407,7 +407,7 @@ MAIN(syncTest)
/* mode AFTER */
testHead("Mode AFTER (m='after', s='red')");
testOk(!!(pch = dbChannelCreate("x.VAL{\"sync\":{\"m\":\"after\",\"s\":\"red\"}}")),
testOk(!!(pch = dbChannelCreate("x.VAL{sync:{m:'after',s:'red'}}")),
"dbChannel with plugin sync (m='after' s='red') created");
checkAndOpenChannel(pch, plug);
+1 -1
View File
@@ -74,7 +74,7 @@ MAIN(tsTest)
testOk(!!(plug = dbFindFilter(ts, strlen(ts))), "plugin ts registered correctly");
testOk(!!(pch = dbChannelCreate("x.VAL{\"ts\":{}}")), "dbChannel with plugin ts created");
testOk(!!(pch = dbChannelCreate("x.VAL{ts:{}}")), "dbChannel with plugin ts created");
testOk((ellCount(&pch->filters) == 1), "channel has one plugin");
memset(&fl, PATTERN, sizeof(fl));
+14 -14
View File
@@ -53,9 +53,9 @@ static void testCalc()
{
dbStateId red;
testPutLongStr("io.INPUT", "{\"calc\":{"
"\"expr\":\"a\","
"\"args\":[{\"state\":\"red\"}]"
testPutLongStr("io.INPUT", "{calc:{"
"expr:'a',"
"args:[{state:'red'}]"
"}}");
if (testOk1(pinp->type == JSON_LINK))
testDiag("Link was set to '%s'", pinp->value.json.string);
@@ -78,11 +78,11 @@ static void testCalc()
dbStateId minor = dbStateCreate("minor");
epicsEnum16 stat, sevr;
testPutLongStr("io.INPUT", "{\"calc\":{"
"\"expr\":\"0\","
"\"major\":\"A\","
"\"minor\":\"B\","
"\"args\":[{\"state\":\"major\"},{\"state\":\"minor\"}]"
testPutLongStr("io.INPUT", "{calc:{"
"expr:'0',"
"major:'A',"
"minor:'B',"
"args:[{state:'major'},{state:'minor'}]"
"}}");
if (testOk1(pinp->type == JSON_LINK))
testDiag("Link was set to '%s'", pinp->value.json.string);
@@ -114,12 +114,12 @@ static void testCalc()
dbStateId red = dbStateFind("red");
dbStateId out = dbStateCreate("out");
testPutLongStr("io.OUTPUT", "{\"calc\":{"
"\"expr\":\"!a\","
"\"out\":{\"state\":\"out\"},"
"\"args\":[{\"state\":\"red\"}],"
"\"units\":\"things\","
"\"prec\":3"
testPutLongStr("io.OUTPUT", "{calc:{"
"expr:'!a',"
"out:{state:'out'},"
"args:[{state:'red'}],"
"units:'things',"
"prec:3"
"}}");
if (testOk1(pout->type == JSON_LINK))
testDiag("Link was set to '%s'", pout->value.json.string);
@@ -50,7 +50,7 @@ static void testState()
red = dbStateFind("red");
testOk(!red, "No state red exists");
testdbPutFieldOk("io.INPUT", DBF_STRING, "{\"state\":\"red\"}");
testdbPutFieldOk("io.INPUT", DBF_STRING, "{state:'red'}");
if (testOk1(pinp->type == JSON_LINK))
testDiag("Link was set to '%s'", pinp->value.json.string);
red = dbStateFind("red");
@@ -64,7 +64,7 @@ static void testState()
testOk(!status, "dbGetLink succeeded (status = %ld)", status);
testOk(i16, "Got TRUE");
testdbPutFieldOk("io.INPUT", DBF_STRING, "{\"state\":\"!red\"}");
testdbPutFieldOk("io.INPUT", DBF_STRING, "{state:'!red'}");
if (testOk1(pinp->type == JSON_LINK))
testDiag("Link was set to '%s'", pinp->value.json.string);
@@ -72,7 +72,7 @@ static void testState()
testOk(!status, "dbGetLink succeeded (status = %ld)", status);
testOk(!i16, "Got FALSE");
testdbPutFieldOk("io.OUTPUT", DBF_STRING, "{\"state\":\"red\"}");
testdbPutFieldOk("io.OUTPUT", DBF_STRING, "{state:'red'}");
if (testOk1(pout->type == JSON_LINK))
testDiag("Link was set to '%s'", pout->value.json.string);
@@ -106,7 +106,7 @@ static void testState()
testOk(!status, "dbPutLink %g succeeded (status = %ld)", f64, status);
testOk(dbStateGet(red), "state was set");
testdbPutFieldOk("io.OUTPUT", DBF_STRING, "{\"state\":\"!red\"}");
testdbPutFieldOk("io.OUTPUT", DBF_STRING, "{state:'!red'}");
if (testOk1(pout->type == JSON_LINK))
testDiag("Link was set to '%s'", pout->value.json.string);
@@ -180,7 +180,7 @@ MAIN(analogMonitorTest)
for (irec = 0; irec < NO_OF_RECORD_TYPES; irec++) {
strcpy(cval, t_Record[irec]);
strcpy(chan, cval);
strcat(chan, ".VAL{\"test\":{}}");
strcat(chan, ".VAL{test:{}}");
if ((strcmp(t_Record[irec], "sel") == 0)
|| (strcmp(t_Record[irec], "calc") == 0)
|| (strcmp(t_Record[irec], "calcout") == 0)) {
@@ -18,7 +18,7 @@ record(stringout, "rec:link2") {
record(ai, "rec:j1") {
field(INP, {calc:{
expr:"A+5",
expr:'A+5',
args:5
}})
field(PINI, "YES")
@@ -75,18 +75,18 @@ static void testRetargetJLink(void)
testdbGetFieldEqual("rec:j1", DBF_DOUBLE, 10.0);
/* minimal args */
testLongStrEq("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":5}}");
testLongStrEq("rec:j1.INP$", "{calc:{expr:'A+5',args:5}}");
/* with [] */
testPutLongStr("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[7]}}");
testPutLongStr("rec:j1.INP$", "{calc:{expr:'A+5',args:[7]}}");
testdbPutFieldOk("rec:j1.PROC", DBF_LONG, 1);
/* with const */
testPutLongStr("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[{\"const\":7}]}}");
testPutLongStr("rec:j1.INP$", "{calc:{expr:'A+5',args:[{const:7}]}}");
testdbPutFieldOk("rec:j1.PROC", DBF_LONG, 1);
testdbGetFieldEqual("rec:j1", DBF_DOUBLE, 12.0);
testLongStrEq("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[{\"const\":7}]}}");
testLongStrEq("rec:j1.INP$", "{calc:{expr:'A+5',args:[{const:7}]}}");
}
MAIN(linkRetargetLinkTest)
+1 -3
View File
@@ -71,7 +71,7 @@ void testArrayLength1(void)
}
/*
* https://bugs.launchpad.net/epics-base/+bug/1699445
* https://bugs.launchpad.net/epics-base/+bug/1699445 and 1887981
*/
static
void testHexConstantLinks(void)
@@ -81,7 +81,6 @@ void testHexConstantLinks(void)
testdbGetFieldEqual("ai1", DBR_LONG, 0x10);
testdbGetFieldEqual("li1", DBR_LONG, 0x10);
testdbGetFieldEqual("mi1", DBR_LONG, 0x10);
testTodoBegin("Needs JSON5 for hex arrays");
testdbGetFieldEqual("as1.A", DBR_LONG, 0x10);
testdbGetFieldEqual("as1.B", DBR_LONG, 0x10);
testdbGetFieldEqual("as1.C", DBR_LONG, 0x10);
@@ -90,7 +89,6 @@ void testHexConstantLinks(void)
testdbGetFieldEqual("as1.F", DBR_LONG, 0x10);
testdbGetFieldEqual("as1.G", DBR_LONG, 0x10);
testdbGetFieldEqual("as1.H", DBR_LONG, 0x10);
testTodoEnd();
testIocShutdownOk();
testdbCleanup();