. "$BST_LIB" # BST-TIMEOUT: 3600 # EIGHT python3 starts, and they are the whole cost. # # # # FOUR are taken directly here: a bare `import'; a second # # import whose STDERR is the assertion (`import-quiet'); the # # probe, which takes ONE start for eighty-six measurements; # # and one run of the shipped simplejson.tool over a fixture, # # which is a separate process by nature -- the point of the # # case is that the CLI resolves its own import. # # # # The other FOUR are one call: `upstream-run' starts the # # interpreter once to run the 146 tests the # # python3-simplejson-tests sub-package ships, and THREE of # # those tests (simplejson.tests.test_tool) spawn # # `python3 -m simplejson.tool' as a subprocess of their own. # # That is the most expensive single case in this file and # # the reason the bound is 3600 rather than the 1200 a # # pure-Python port of this size would take. # # # # 3600 is 450s per start, against the ~60s a python3 start # # has measured at on this arm -- the same per-start margin # # 99-python3-cbor2 carries at 2400 for five. # # # # NOTHING HERE IS QUADRATIC IN ANYTHING. Every fixture is a # # few dozen bytes; the largest is the 100-byte tool fixture. # # The one unbounded recursion simplejson can be made to # # perform -- `check_circular=False' over a self-referential # # list -- is DELIBERATELY NOT EXERCISED, here or in the # # probe: see the probe's `circular_refused' comment. # # # # NOT MEASURED ON TARGET YET: this port's first on-target # # run is the batch verify, and the measured elapsed replaces # # this note in the test plan rather than in this comment, # # which would cost an image build to keep the shipped suite # # byte-identical. # # python3-simplejson 3.19.2 (meta-openembedded/meta-python # recipes-devtools/python/python3-simplejson_3.19.2.bb, `inherit pypi # setuptools3', PyPI sdist, no patches) on the wasm32-hwjs glibc image. # # ============================================================================ # WHAT THE PACKAGE DOES. # ============================================================================ # # simplejson is the JSON implementation the standard library's `json' module # was DERIVED FROM, still maintained separately and still ahead of it. Everything # `json' does it does, with the same call names, plus the four things it is # actually installed for: # # * DECIMAL ROUND-TRIPPING. `json' turns a Decimal into a float and loses the # value; simplejson carries the digits through both directions. # * DETERMINISTIC KEY ORDER, by key (`sort_keys') or by an arbitrary callable # over the (key, value) pair (`item_sort_key'). # * ENCODING RULES FOR TYPES `json' REFUSES -- namedtuples as objects, # arbitrary iterables as arrays, an object naming its own encoding through # `for_json', pre-encoded text through RawJSON. # * THE JAVASCRIPT-CONSUMER KNOBS -- `bigint_as_string' for integers past a # double's mantissa, `ignore_nan' to rewrite NaN and Infinity as `null', # and JSONEncoderForHTML for output embedded in a ' exactly as it found it. check_eq $P/encode-for-html '"\u003c/script\u003e"' "$(pv encode_for_html)" check_eq $P/encode-for-html-sep '"\u2028\u2029"' "$(pv encode_for_html_sep)" check_eq $P/encode-plain-html '""' "$(pv encode_plain_html)" check_eq $P/raw-json '{"a": [1,2,3]}' "$(pv raw_json)" check_eq $P/object-pairs-hook "OrderedDict({'b': 1, 'a': 2})" "$(pv object_pairs_hook)" # `ensure_ascii' IS ON BY DEFAULT, so U+6C34 leaves as the SEVEN ASCII # characters \u6c34 and this file can carry the expectation verbatim. Turned # off it leaves as UTF-8, which no console under the C locale can be trusted to # render -- so the probe reports those bytes as hex: 22, the three-byte encoding # of U+6C34, 22. check_eq $P/ensure-ascii-on '"\u6c34"' "$(pv ensure_ascii_on)" check_eq $P/ensure-ascii-off-hex '22e6b0b422' "$(pv ensure_ascii_off_hex)" check_eq $P/unicode-roundtrip "yes" "$(pv unicode_roundtrip)" # A CODEPOINT ABOVE THE BMP IS EMITTED AS A SURROGATE PAIR, which is what JSON # requires and what the decoder on the other side has to recombine. U+1D120 is # \ud834\udd20. check_eq $P/surrogate-pair '"\ud834\udd20"' "$(pv surrogate_pair)" check_eq $P/iterable-as-array '[1, 2, 3]' "$(pv iterable_as_array)" check_eq $P/iterable-default "TypeError" "$(pv iterable_default)" check_eq $P/circular-refused "ValueError" "$(pv circular_refused)" check_eq $P/circular-marker-cleared '[[1], [1]]' "$(pv circular_marker_cleared)" # ----------------------------------------------------- the UPSTREAM suite ---- # THE SUBSTANCE OF THE PORT: the 146 tests the python3-simplejson-tests # sub-package ships, run in-process against the shipped module. This is the most # expensive case in the file -- one interpreter start plus three more that # simplejson.tests.test_tool spawns as subprocesses -- so it gets the larger # half of the suite's budget. if [ ! -f "$UPSTREAM" ]; then bst_notok $P/upstream-present "upstream runner missing at $UPSTREAM" else bst_ok $P/upstream-present fi bst_probe $P/upstream-run "$W/up" 2400 python3 "$UPSTREAM" UOUT="$W/up" uv() { grep "^$1=" "$UOUT" 2>/dev/null | head -n 1 | cut -d= -f2-; } # GATED, AND THE GATE IS THE POINT. `upstream-clean' below asserts that the set # of failing test ids is EMPTY -- which is also exactly what a run that never # started produces. So the three cases here come FIRST and are what make it # meaningful: the runner reached its last line, it ran the expected number of # tests, and it said so itself (BRINTOS-2081). check_eq $P/upstream-done "yes" "$(uv upstream_done)" check_eq $P/upstream-ran "146" "$(uv upstream_ran)" check_eq $P/upstream-ok "yes" "$(uv upstream_ok)" check_eq $P/upstream-failures "0" "$(uv upstream_failures)" check_eq $P/upstream-errors "0" "$(uv upstream_errors)" check_eq $P/upstream-clean "" "$(uv upstream_bad_ids)" # THE SKIPS ARE THE ACCELERATOR'S SHADOW, and they are asserted by NAME rather # than by count. Seven test_speedups cases skip because `encoder.c_make_encoder' # is None, and `TestMissingSpeedups' is added by the harness for the same # reason. A run where this list SHRANK would mean the bbappend had stopped # taking -- which is the one way this suite could go green while measuring the # wrong code -- and a run where it GREW would mean a test had started skipping # for some reason nobody has named. check_eq $P/upstream-skipped "8" "$(uv upstream_skipped)" check_eq $P/upstream-skip-ids \ "simplejson.tests.TestMissingSpeedups.runTest,simplejson.tests.test_speedups.TestDecode.test_bad_bool_args,simplejson.tests.test_speedups.TestDecode.test_make_scanner,simplejson.tests.test_speedups.TestEncode.test_bad_bool_args,simplejson.tests.test_speedups.TestEncode.test_bad_encoding,simplejson.tests.test_speedups.TestEncode.test_bad_str_encoder,simplejson.tests.test_speedups.TestEncode.test_int_as_string_bitcount_overflow,simplejson.tests.test_speedups.TestEncode.test_make_encoder" \ "$(uv upstream_skip_ids)" check_eq $P/upstream-version "3.19.2" "$(uv upstream_version)" check_eq $P/upstream-tests-file "$PKG/tests/__init__.py" "$(uv upstream_tests_file)" # ------------------------------------------------------------------ the CLI -- # THE SHIPPED COMMAND-LINE DRIVER, IN ITS OWN PROCESS. simplejson/tool.py comes # from the -tests sub-package and is reached as `python3 -m simplejson.tool', # because this project declares no console script. The case measures something # the probe structurally cannot: that the module is runnable as a program and # resolves its own import of the package. # # THE FIXTURE IS READ BY PATH, NOT REDIRECTED. tool.py opens argv[1] itself, so # there is no stdin redirect and none of the dup2(2)-returns-513 trap a redirect # from the virtiofs root falls into. # # AND THE EXPECTED OUTPUT IS THE DECIMAL CLAIM MADE THROUGH THE CLI. tool.py # runs `use_decimal=True' both ways over `sort_keys=True, indent=" "', so # 1.100000000000000000001 must come back with all twenty-two digits -- a float # path would print 1.1 -- while the keys come out sorted and the layout is the # four-space one. Newlines are folded to `|' by `tr' inside a command # substitution, which forks, so nothing here redirects in this shell. check $P/tool-fixture-present test -s "$TOOLFIX" check_eq $P/tool-output \ '{| "alpha": [| 1,| {| "a": null,| "z": true| }| ],| "beta": 1.100000000000000000001,| "gamma": 12345678901234567890|}|' \ "$(python3 -m simplejson.tool "$TOOLFIX" 2>&1 | tr '\n' '|')" rm -rf "$W"