1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#! /bin/bash
run_test ./drive_json_op get "" <<EOF
3
EOF
check_output "cannot read root number value" <<EOF
3
EOF
run_test ./drive_json_op get "" <<EOF
null
EOF
check_output "cannot read root null value" <<EOF
null
EOF
run_test ./drive_json_op get "" <<EOF
true
EOF
check_output "cannot read root bool value" <<EOF
true
EOF
run_test ./drive_json_op get "" <<EOF
"str"
EOF
check_output "cannot read root string value" <<EOF
"str"
EOF
run_test ./drive_json_op get "" <<EOF
{ "val" : 3, "other" : 2 }
EOF
check_output "cannot read root map value" <<EOF
{
"val": 3,
"other": 2
}
EOF
run_test ./drive_json_op get /val <<EOF
{ "val" : 3 }
EOF
check_output "cannot read top-level value" <<EOF
3
EOF
run_test ./drive_json_op get /val <<EOF
{ "other" : { "val" : 5 }, "val" : 3 }
EOF
check_output "read wrong value" <<EOF
3
EOF
run_test ./drive_json_op get /other <<EOF
{ "other" : { "val" : 5 }, "val" : 3 }
EOF
check_output "cannot read map" <<EOF
{
"val": 5
}
EOF
run_test ./drive_json_op get /other/val <<EOF
{ "other" : { "val" : 5 }, "val" : 3 }
EOF
check_output "cannot read nested map" <<EOF
5
EOF
run_test ./drive_json_op get "" <<EOF
[0, 1]
EOF
check_output "cannot read root array value" <<EOF
[
0,
1
]
EOF
run_test ./drive_json_op get "/6" <<EOF
[null, true, 1, "str", {"sub":[10, 11]}, [21, [33, 34], 66], 2]
EOF
check_output "cannot read array value" <<EOF
2
EOF
run_test ./drive_json_op get "/ID" <<EOF
{"ID":"P1","ProcessID":"P1","Name":"VxWorks","CanSuspend":true,"CanResume":1,"IsContainer":true,"WordSize":4,"CanTerminate":true,"CanDetach":true,"RCGroup":"P1","SymbolsGroup":"P1","CPUGroup":"P1","DiagnosticTestProcess":true}
EOF
check_output "cannot read key value" <<EOF
"P1"
EOF
run_test ./drive_json_op get "/arr/1/id" <<EOF
{"arr": [{"id": 1}, {"id": 2}]}
EOF
check_output "cannot read key value" <<EOF
2
EOF
|