Repository: nifi-minifi-cpp Updated Branches: refs/heads/MINIFI-227 0ff00a541 -> 289ac43fe
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/fail4.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/fail4.json b/thirdparty/jsoncpp/test/jsonchecker/fail4.json new file mode 100644 index 0000000..9de168b --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/fail4.json @@ -0,0 +1 @@ +["extra comma",] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/fail5.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/fail5.json b/thirdparty/jsoncpp/test/jsonchecker/fail5.json new file mode 100644 index 0000000..ddf3ce3 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/fail5.json @@ -0,0 +1 @@ +["double extra comma",,] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/fail6.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/fail6.json b/thirdparty/jsoncpp/test/jsonchecker/fail6.json new file mode 100644 index 0000000..ed91580 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/fail6.json @@ -0,0 +1 @@ +[ , "<-- missing value"] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/fail7.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/fail7.json b/thirdparty/jsoncpp/test/jsonchecker/fail7.json new file mode 100644 index 0000000..8a96af3 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/fail7.json @@ -0,0 +1 @@ +["Comma after the close"], \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/fail8.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/fail8.json b/thirdparty/jsoncpp/test/jsonchecker/fail8.json new file mode 100644 index 0000000..b28479c --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/fail8.json @@ -0,0 +1 @@ +["Extra close"]] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/fail9.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/fail9.json b/thirdparty/jsoncpp/test/jsonchecker/fail9.json new file mode 100644 index 0000000..5815574 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/fail9.json @@ -0,0 +1 @@ +{"Extra comma": true,} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/pass1.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/pass1.json b/thirdparty/jsoncpp/test/jsonchecker/pass1.json new file mode 100644 index 0000000..70e2685 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/pass1.json @@ -0,0 +1,58 @@ +[ + "JSON Test Pattern pass1", + {"object with 1 member":["array with 1 element"]}, + {}, + [], + -42, + true, + false, + null, + { + "integer": 1234567890, + "real": -9876.543210, + "e": 0.123456789e-12, + "E": 1.234567890E+34, + "": 23456789012E66, + "zero": 0, + "one": 1, + "space": " ", + "quote": "\"", + "backslash": "\\", + "controls": "\b\f\n\r\t", + "slash": "/ & \/", + "alpha": "abcdefghijklmnopqrstuvwyz", + "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", + "digit": "0123456789", + "0123456789": "digit", + "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?", + "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", + "true": true, + "false": false, + "null": null, + "array":[ ], + "object":{ }, + "address": "50 St. James Street", + "url": "http://www.JSON.org/", + "comment": "// /* <!-- --", + "# -- --> */": " ", + " s p a c e d " :[1,2 , 3 + +, + +4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], + "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", + "quotes": "" \u0022 %22 0x22 034 "", + "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" +: "A key can be any string" + }, + 0.5 ,98.6 +, +99.44 +, + +1066, +1e1, +0.1e1, +1e-1, +1e00,2e+00,2e-00 +,"rosebud"] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/pass2.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/pass2.json b/thirdparty/jsoncpp/test/jsonchecker/pass2.json new file mode 100644 index 0000000..d3c63c7 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/pass2.json @@ -0,0 +1 @@ +[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/pass3.json ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/pass3.json b/thirdparty/jsoncpp/test/jsonchecker/pass3.json new file mode 100644 index 0000000..4528d51 --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/pass3.json @@ -0,0 +1,6 @@ +{ + "JSON Test Pattern pass3": { + "The outermost value": "must be an object or array.", + "In this test": "It is an object." + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/jsonchecker/readme.txt ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/jsonchecker/readme.txt b/thirdparty/jsoncpp/test/jsonchecker/readme.txt new file mode 100644 index 0000000..321d89d --- /dev/null +++ b/thirdparty/jsoncpp/test/jsonchecker/readme.txt @@ -0,0 +1,3 @@ +Test suite from http://json.org/JSON_checker/. + +If the JSON_checker is working correctly, it must accept all of the pass*.json files and reject all of the fail*.json files. http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/pyjsontestrunner.py ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/pyjsontestrunner.py b/thirdparty/jsoncpp/test/pyjsontestrunner.py new file mode 100644 index 0000000..7f38356 --- /dev/null +++ b/thirdparty/jsoncpp/test/pyjsontestrunner.py @@ -0,0 +1,71 @@ +# Copyright 2007 Baptiste Lepilleur +# Distributed under MIT license, or public domain if desired and +# recognized in your jurisdiction. +# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + +"""Simple implementation of a json test runner to run the test against +json-py.""" + +from __future__ import print_function +import sys +import os.path +import json +import types + +if len(sys.argv) != 2: + print("Usage: %s input-json-file", sys.argv[0]) + sys.exit(3) + +input_path = sys.argv[1] +base_path = os.path.splitext(input_path)[0] +actual_path = base_path + '.actual' +rewrite_path = base_path + '.rewrite' +rewrite_actual_path = base_path + '.actual-rewrite' + +def valueTreeToString(fout, value, path = '.'): + ty = type(value) + if ty is types.DictType: + fout.write('%s={}\n' % path) + suffix = path[-1] != '.' and '.' or '' + names = value.keys() + names.sort() + for name in names: + valueTreeToString(fout, value[name], path + suffix + name) + elif ty is types.ListType: + fout.write('%s=[]\n' % path) + for index, childValue in zip(xrange(0,len(value)), value): + valueTreeToString(fout, childValue, path + '[%d]' % index) + elif ty is types.StringType: + fout.write('%s="%s"\n' % (path,value)) + elif ty is types.IntType: + fout.write('%s=%d\n' % (path,value)) + elif ty is types.FloatType: + fout.write('%s=%.16g\n' % (path,value)) + elif value is True: + fout.write('%s=true\n' % path) + elif value is False: + fout.write('%s=false\n' % path) + elif value is None: + fout.write('%s=null\n' % path) + else: + assert False and "Unexpected value type" + +def parseAndSaveValueTree(input, actual_path): + root = json.loads(input) + fout = file(actual_path, 'wt') + valueTreeToString(fout, root) + fout.close() + return root + +def rewriteValueTree(value, rewrite_path): + rewrite = json.dumps(value) + #rewrite = rewrite[1:-1] # Somehow the string is quoted ! jsonpy bug ? + file(rewrite_path, 'wt').write(rewrite + '\n') + return rewrite + +input = file(input_path, 'rt').read() +root = parseAndSaveValueTree(input, actual_path) +rewrite = rewriteValueTree(json.write(root), rewrite_path) +rewrite_root = parseAndSaveValueTree(rewrite, rewrite_actual_path) + +sys.exit(0) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/runjsontests.py ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/runjsontests.py b/thirdparty/jsoncpp/test/runjsontests.py new file mode 100644 index 0000000..d21c02f --- /dev/null +++ b/thirdparty/jsoncpp/test/runjsontests.py @@ -0,0 +1,174 @@ +# Copyright 2007 Baptiste Lepilleur +# Distributed under MIT license, or public domain if desired and +# recognized in your jurisdiction. +# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + +from __future__ import print_function +from __future__ import unicode_literals +from io import open +from glob import glob +import sys +import os +import os.path +import optparse + +VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes ' + +def getStatusOutput(cmd): + """ + Return int, unicode (for both Python 2 and 3). + Note: os.popen().close() would return None for 0. + """ + print(cmd, file=sys.stderr) + pipe = os.popen(cmd) + process_output = pipe.read() + try: + # We have been using os.popen(). When we read() the result + # we get 'str' (bytes) in py2, and 'str' (unicode) in py3. + # Ugh! There must be a better way to handle this. + process_output = process_output.decode('utf-8') + except AttributeError: + pass # python3 + status = pipe.close() + return status, process_output +def compareOutputs(expected, actual, message): + expected = expected.strip().replace('\r','').split('\n') + actual = actual.strip().replace('\r','').split('\n') + diff_line = 0 + max_line_to_compare = min(len(expected), len(actual)) + for index in range(0,max_line_to_compare): + if expected[index].strip() != actual[index].strip(): + diff_line = index + 1 + break + if diff_line == 0 and len(expected) != len(actual): + diff_line = max_line_to_compare+1 + if diff_line == 0: + return None + def safeGetLine(lines, index): + index += -1 + if index >= len(lines): + return '' + return lines[index].strip() + return """ Difference in %s at line %d: + Expected: '%s' + Actual: '%s' +""" % (message, diff_line, + safeGetLine(expected,diff_line), + safeGetLine(actual,diff_line)) + +def safeReadFile(path): + try: + return open(path, 'rt', encoding = 'utf-8').read() + except IOError as e: + return '<File "%s" is missing: %s>' % (path,e) + +def runAllTests(jsontest_executable_path, input_dir = None, + use_valgrind=False, with_json_checker=False, + writerClass='StyledWriter'): + if not input_dir: + input_dir = os.path.join(os.getcwd(), 'data') + tests = glob(os.path.join(input_dir, '*.json')) + if with_json_checker: + test_jsonchecker = glob(os.path.join(input_dir, '../jsonchecker', '*.json')) + else: + test_jsonchecker = [] + failed_tests = [] + valgrind_path = use_valgrind and VALGRIND_CMD or '' + for input_path in tests + test_jsonchecker: + expect_failure = os.path.basename(input_path).startswith('fail') + is_json_checker_test = (input_path in test_jsonchecker) or expect_failure + print('TESTING:', input_path, end=' ') + options = is_json_checker_test and '--json-checker' or '' + options += ' --json-writer %s'%writerClass + cmd = '%s%s %s "%s"' % ( valgrind_path, jsontest_executable_path, options, + input_path) + status, process_output = getStatusOutput(cmd) + if is_json_checker_test: + if expect_failure: + if not status: + print('FAILED') + failed_tests.append((input_path, 'Parsing should have failed:\n%s' % + safeReadFile(input_path))) + else: + print('OK') + else: + if status: + print('FAILED') + failed_tests.append((input_path, 'Parsing failed:\n' + process_output)) + else: + print('OK') + else: + base_path = os.path.splitext(input_path)[0] + actual_output = safeReadFile(base_path + '.actual') + actual_rewrite_output = safeReadFile(base_path + '.actual-rewrite') + open(base_path + '.process-output', 'wt', encoding = 'utf-8').write(process_output) + if status: + print('parsing failed') + failed_tests.append((input_path, 'Parsing failed:\n' + process_output)) + else: + expected_output_path = os.path.splitext(input_path)[0] + '.expected' + expected_output = open(expected_output_path, 'rt', encoding = 'utf-8').read() + detail = (compareOutputs(expected_output, actual_output, 'input') + or compareOutputs(expected_output, actual_rewrite_output, 'rewrite')) + if detail: + print('FAILED') + failed_tests.append((input_path, detail)) + else: + print('OK') + + if failed_tests: + print() + print('Failure details:') + for failed_test in failed_tests: + print('* Test', failed_test[0]) + print(failed_test[1]) + print() + print('Test results: %d passed, %d failed.' % (len(tests)-len(failed_tests), + len(failed_tests))) + return 1 + else: + print('All %d tests passed.' % len(tests)) + return 0 + +def main(): + from optparse import OptionParser + parser = OptionParser(usage="%prog [options] <path to jsontestrunner.exe> [test case directory]") + parser.add_option("--valgrind", + action="store_true", dest="valgrind", default=False, + help="run all the tests using valgrind to detect memory leaks") + parser.add_option("-c", "--with-json-checker", + action="store_true", dest="with_json_checker", default=False, + help="run all the tests from the official JSONChecker test suite of json.org") + parser.enable_interspersed_args() + options, args = parser.parse_args() + + if len(args) < 1 or len(args) > 2: + parser.error('Must provides at least path to jsontestrunner executable.') + sys.exit(1) + + jsontest_executable_path = os.path.normpath(os.path.abspath(args[0])) + if len(args) > 1: + input_path = os.path.normpath(os.path.abspath(args[1])) + else: + input_path = None + status = runAllTests(jsontest_executable_path, input_path, + use_valgrind=options.valgrind, + with_json_checker=options.with_json_checker, + writerClass='StyledWriter') + if status: + sys.exit(status) + status = runAllTests(jsontest_executable_path, input_path, + use_valgrind=options.valgrind, + with_json_checker=options.with_json_checker, + writerClass='StyledStreamWriter') + if status: + sys.exit(status) + status = runAllTests(jsontest_executable_path, input_path, + use_valgrind=options.valgrind, + with_json_checker=options.with_json_checker, + writerClass='BuiltStyledStreamWriter') + if status: + sys.exit(status) + +if __name__ == '__main__': + main() http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/test/rununittests.py ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/test/rununittests.py b/thirdparty/jsoncpp/test/rununittests.py new file mode 100644 index 0000000..08850ec --- /dev/null +++ b/thirdparty/jsoncpp/test/rununittests.py @@ -0,0 +1,84 @@ +# Copyright 2009 Baptiste Lepilleur +# Distributed under MIT license, or public domain if desired and +# recognized in your jurisdiction. +# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + +from __future__ import print_function +from __future__ import unicode_literals +from io import open +from glob import glob +import sys +import os +import os.path +import subprocess +import optparse + +VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes' + +class TestProxy(object): + def __init__(self, test_exe_path, use_valgrind=False): + self.test_exe_path = os.path.normpath(os.path.abspath(test_exe_path)) + self.use_valgrind = use_valgrind + + def run(self, options): + if self.use_valgrind: + cmd = VALGRIND_CMD.split() + else: + cmd = [] + cmd.extend([self.test_exe_path, '--test-auto'] + options) + try: + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + except: + print(cmd) + raise + stdout = process.communicate()[0] + if process.returncode: + return False, stdout + return True, stdout + +def runAllTests(exe_path, use_valgrind=False): + test_proxy = TestProxy(exe_path, use_valgrind=use_valgrind) + status, test_names = test_proxy.run(['--list-tests']) + if not status: + print("Failed to obtain unit tests list:\n" + test_names, file=sys.stderr) + return 1 + test_names = [name.strip() for name in test_names.decode('utf-8').strip().split('\n')] + failures = [] + for name in test_names: + print('TESTING %s:' % name, end=' ') + succeed, result = test_proxy.run(['--test', name]) + if succeed: + print('OK') + else: + failures.append((name, result)) + print('FAILED') + failed_count = len(failures) + pass_count = len(test_names) - failed_count + if failed_count: + print() + for name, result in failures: + print(result) + print('%d/%d tests passed (%d failure(s))' % ( pass_count, len(test_names), failed_count)) + return 1 + else: + print('All %d tests passed' % len(test_names)) + return 0 + +def main(): + from optparse import OptionParser + parser = OptionParser(usage="%prog [options] <path to test_lib_json.exe>") + parser.add_option("--valgrind", + action="store_true", dest="valgrind", default=False, + help="run all the tests using valgrind to detect memory leaks") + parser.enable_interspersed_args() + options, args = parser.parse_args() + + if len(args) != 1: + parser.error('Must provides at least path to test_lib_json executable.') + sys.exit(1) + + exit_code = runAllTests(args[0], use_valgrind=options.valgrind) + sys.exit(exit_code) + +if __name__ == '__main__': + main() http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/travis.sh ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/travis.sh b/thirdparty/jsoncpp/travis.sh new file mode 100755 index 0000000..a9811ec --- /dev/null +++ b/thirdparty/jsoncpp/travis.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh +# This is called by `.travis.yml` via Travis CI. +# Travis supplies $TRAVIS_OS_NAME. +# http://docs.travis-ci.com/user/multi-os/ +# Our .travis.yml also defines: +# - SHARED_LIB=ON/OFF +# - STATIC_LIB=ON/OFF +# - CMAKE_PKG=ON/OFF +# - BUILD_TYPE=release/debug +# - VERBOSE_MAKE=false/true +# - VERBOSE (set or not) + +# -e: fail on error +# -v: show commands +# -x: show expanded commands +set -vex + +env | sort + +cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE . +make +cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE -DJSONCPP_USE_SECURE_MEMORY=1 . +make + +# Python is not available in Travis for osx. +# https://github.com/travis-ci/travis-ci/issues/2320 +if [ "$TRAVIS_OS_NAME" != "osx" ] +then + make jsoncpp_check + valgrind --error-exitcode=42 --leak-check=full ./src/test_lib_json/jsoncpp_test +fi http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/version ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/version b/thirdparty/jsoncpp/version new file mode 100644 index 0000000..27f9cd3 --- /dev/null +++ b/thirdparty/jsoncpp/version @@ -0,0 +1 @@ +1.8.0 http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/126c2ed5/thirdparty/jsoncpp/version.in ---------------------------------------------------------------------- diff --git a/thirdparty/jsoncpp/version.in b/thirdparty/jsoncpp/version.in new file mode 100644 index 0000000..bfc03f7 --- /dev/null +++ b/thirdparty/jsoncpp/version.in @@ -0,0 +1 @@ +@JSONCPP_VERSION@