simdjson/scripts/testjson2json.sh

100 lines
2.3 KiB
Bash
Raw Normal View History

2018-12-07 06:22:22 +08:00
#!/bin/bash
2018-12-07 06:36:41 +08:00
TMPDIR1=$(mktemp -d -t simdjsonXXXXXXXX)
TMPDIR2=$(mktemp -d -t simdjsonXXXXXXXX)
2018-12-10 09:47:02 +08:00
TMPDIR3=$(mktemp -d -t simdjsonXXXXXXXX)
TMPDIR4=$(mktemp -d -t simdjsonXXXXXXXX)
2018-12-07 06:22:22 +08:00
trap "exit 1" HUP INT PIPE QUIT TERM
2018-12-10 09:47:02 +08:00
trap "rm -rf $TMPDIR1 $TMPDIR2 $TMPDIR3 $TMPDIR4" EXIT
2018-12-07 06:22:22 +08:00
function founderror() {
echo "code is wrong"
exit 1
}
make minify json2json
for i in `cd jsonexamples && ls -1 *.json`; do
echo $i
./json2json jsonexamples/$i > $TMPDIR1/$i
2018-12-10 09:47:02 +08:00
./json2json -a jsonexamples/$i > $TMPDIR3/$i
2018-12-07 06:22:22 +08:00
./json2json $TMPDIR1/$i > $TMPDIR2/$i
2018-12-10 09:47:02 +08:00
./json2json -a $TMPDIR3/$i > $TMPDIR4/$i
2018-12-07 06:22:22 +08:00
cmp $TMPDIR1/$i $TMPDIR2/$i
retVal=$?
if [ $retVal -ne 0 ]; then
founderror
fi
2018-12-10 09:47:02 +08:00
cmp $TMPDIR3/$i $TMPDIR4/$i
retVal=$?
if [ $retVal -ne 0 ]; then
founderror
fi
2018-12-07 06:22:22 +08:00
./minify $TMPDIR1/$i > $TMPDIR1/minify$i
./minify $TMPDIR2/$i > $TMPDIR2/minify$i
2018-12-10 09:47:02 +08:00
./minify $TMPDIR3/$i > $TMPDIR3/minify$i
./minify $TMPDIR4/$i > $TMPDIR4/minify$i
2018-12-07 06:22:22 +08:00
cmp $TMPDIR1/minify$i $TMPDIR2/minify$i
retVal=$?
if [ $retVal -ne 0 ]; then
founderror
fi
2018-12-10 09:47:02 +08:00
cmp $TMPDIR3/minify$i $TMPDIR4/minify$i
retVal=$?
if [ $retVal -ne 0 ]; then
founderror
fi
2018-12-07 06:22:22 +08:00
./json2json $TMPDIR1/minify$i > $TMPDIR2/bisminify$i
cmp $TMPDIR1/$i $TMPDIR2/bisminify$i
retVal=$?
if [ $retVal -ne 0 ]; then
founderror
fi
done
2018-12-10 09:47:02 +08:00
for i in `cd jsonchecker && ls -1 pass*.json`; do
echo $i
./json2json jsonchecker/$i > $TMPDIR1/$i
./json2json -a jsonchecker/$i > $TMPDIR3/$i
./json2json $TMPDIR1/$i > $TMPDIR2/$i
./json2json -a $TMPDIR3/$i > $TMPDIR4/$i
cmp $TMPDIR1/$i $TMPDIR2/$i
retVal=$?
if [ $retVal -ne 0 ]; then
echo "reg failure"
founderror
fi
cmp $TMPDIR3/$i $TMPDIR4/$i
retVal=$?
if [ $retVal -ne 0 ]; then
echo "-a failure"
founderror
fi
./minify $TMPDIR1/$i > $TMPDIR1/minify$i
./minify $TMPDIR2/$i > $TMPDIR2/minify$i
./minify $TMPDIR3/$i > $TMPDIR3/minify$i
./minify $TMPDIR4/$i > $TMPDIR4/minify$i
cmp $TMPDIR1/minify$i $TMPDIR2/minify$i
retVal=$?
if [ $retVal -ne 0 ]; then
echo "reg failure, step 2"
founderror
fi
cmp $TMPDIR3/minify$i $TMPDIR4/minify$i
retVal=$?
if [ $retVal -ne 0 ]; then
echo "-a failure, step 2"
founderror
fi
./json2json $TMPDIR1/minify$i > $TMPDIR2/bisminify$i
cmp $TMPDIR1/$i $TMPDIR2/bisminify$i
retVal=$?
if [ $retVal -ne 0 ]; then
founderror
fi
done
2018-12-07 06:22:22 +08:00
echo "test successful"
exit 0