Annotate

tests/test_util_json.sh @ 8006:be374a5778f3

net.server_epoll: Log if there's a connection without listeners
author Kim Alvefur <zash@zash.se>
date Mon, 27 Mar 2017 03:40:24 +0200
parent 7237:472736b583fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7237
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 #!/bin/bash
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 export LUA_PATH="../?.lua;;"
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 export LUA_CPATH="../?.so;;"
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 #set -x
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 if ! which "$RUNWITH"; then
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 echo "Unable to find interpreter $RUNWITH";
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 exit 1;
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 fi
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 if ! $RUNWITH -e 'assert(require"util.json")' 2>/dev/null; then
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 echo "Unable to find util.json";
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 exit 1;
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 fi
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 FAIL=0
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 for f in json/pass*.json; do
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 if ! $RUNWITH -e 'local j=require"util.json" assert(j.decode(io.read("*a"))~=nil)' <"$f" 2>/dev/null; then
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 echo "Failed to decode valid JSON: $f";
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 FAIL=1
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 fi
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 done
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 for f in json/fail*.json; do
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 if ! $RUNWITH -e 'local j=require"util.json" assert(j.decode(io.read("*a"))==nil)' <"$f" 2>/dev/null; then
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 echo "Invalid JSON decoded without error: $f";
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 FAIL=1
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 fi
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 done
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 if [ "$FAIL" == "1" ]; then
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 echo "JSON tests failed"
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 exit 1;
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 fi
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38
472736b583fb tests: Add extra tests for util.json
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 exit 0;