. "$BST_LIB" require perl libxml-namespacesupport-perl/present # XML::NamespaceSupport is pure Perl, so the whole port is @INC content: the # module has to be found, loaded, and answer correctly. It is a namespace STACK # -- a SAX driver pushes a context per element start, declares the xmlns # attributes it saw, resolves names against the top of the stack, and pops at # element end -- so what is measured here is SCOPE: what a nested context # inherits, what it shadows, and what survives the pop. # # The payload does the measuring and prints one tagged line per value; this file # names and compares them, so a single wrong answer is one red case rather than # one red suite. Every expectation below was first measured against a native # x86-64 perl carrying the identical XML::NamespaceSupport 1.12 -- the same # single .pm this recipe ships, which is why a host control is legitimate here # and was not for libjson-perl (no XS anywhere in this distribution). # ------------------------- 1. what the port SHIPS: filesystem facts ---------- # Asserted before anything starts perl, so the deliverable is measured even on a # boot where the interpreter cannot load a module at all (section 1a). These are # packaging facts and hold either way. MOD=$(ls /usr/lib/perl5/vendor_perl/*/XML/NamespaceSupport.pm 2>/dev/null | head -1) if [ -n "$MOD" ]; then bst_ok libxml-namespacesupport-perl/module-installed else bst_notok libxml-namespacesupport-perl/module-installed \ "no XML/NamespaceSupport.pm under /usr/lib/perl5/vendor_perl"; fi check libxml-namespacesupport-perl/payload-installed \ test -f "$BST_DATA/libxml-namespacesupport-perl-selftest.pl" # ------------------ 1a. can perl LOAD a module on this boot at all? ---------- # BRINTOS-WORKAROUND: linux-in-the-browser#154 remove -- perl aborts in glibc's # allocator while COMPILING a module, so `use XML::NamespaceSupport` dies before # a line of this port's code runs; delete this guard and the battery below runs # unconditionally again the day #154 closes. # # The abort is glibc's own -- `mremap_chunk(): invalid pointer` or `corrupted # size vs. prev_size`, rc=134 -- and is not specific to this module: measured on # the same boot, `perl -Mstrict`, `perl -Mconstant`, `perl -MJSON` and # `perl -MURI` abort identically, while `perl -Mwarnings` and `perl -Mvars` # return 0. So the two module-load cases below place the defect in the # interpreter rather than in this port, and the filesystem facts above stay # green beside them. # # This is a guard, NOT a skip of an inconvenient case: the probe is left FAILING # and attributed, so it flips green by itself when #154 closes, which is the # regression signal this suite is bought for. What it prevents is running the # 68 cases below anyway -- measured unguarded on this image: 70 reds of 70, at a # 6.0 GiB host peak, which costs every suite scheduled after this one in the # same sweep. pout=$(perl -MXML::NamespaceSupport -e 'print "XMLNS-OK\n"' 2>&1); prc=$? case "$pout" in *XMLNS-OK*) bst_ok libxml-namespacesupport-perl/import-load ;; *) bst_notok libxml-namespacesupport-perl/import-load \ "rc=$prc $(_bst_1line "$pout") -- perl cannot compile a module on this arm (linux-in-the-browser#154)" # Named rather than silent: this ticket's headline criterion is the NAMESPACE # STACK -- declare in an outer context, resolve in a nested one, gone after # the pop -- and that is exactly what could not be measured. A suite that # merely stopped here would report two greens and read as a pass. bst_notok libxml-namespacesupport-perl/namespace-stack-unverified \ "not run: perl cannot load the module (linux-in-the-browser#154) -- push/pop scope, the default-namespace rules and undeclared-prefix resolution are unverified on wasm32-hwjs" exit 0 ;; esac # ------------------------- 2. the module's own answers, at values ------------ out=$(perl "$BST_DATA/libxml-namespacesupport-perl-selftest.pl" 2>&1); rc=$? case "$out" in *ALL-XMLNS-OK*) all=1 ;; *) all=0 ;; esac if [ "$rc" -eq 0 ] && [ "$all" -eq 1 ]; then bst_ok libxml-namespacesupport-perl/all-ok else bst_notok libxml-namespacesupport-perl/all-ok "rc=$rc $(_bst_1line "$out")"; fi val() { printf '%s\n' "$out" | awk -v t="$1" '$1==t{ $1=""; sub(/^ /,""); print; exit }'; } NS_XML=http://www.w3.org/XML/1998/namespace NS_XMLNS=http://www.w3.org/2000/xmlns/ U_A=http://example.org/a U_B=http://example.org/b U_DEF=http://example.org/default # --- the module loads, from the image rather than a stray @INC dir ---------- check_eq libxml-namespacesupport-perl/version 1.12 "$(val R1-version)" case "$(val R2-inc-path)" in /usr/*) bst_ok libxml-namespacesupport-perl/installed-path ;; *) bst_notok libxml-namespacesupport-perl/installed-path "NamespaceSupport.pm resolved to $(val R2-inc-path)" ;; esac # The two namespace URIs the XML Namespaces recommendation fixes. They are # module constants, not derived, so a wrong value here means a corrupt install # rather than a logic error -- and every resolution below is compared against # them, so they are asserted first. check_eq libxml-namespacesupport-perl/ns-xml "$NS_XML" "$(val R3-ns-xml)" check_eq libxml-namespacesupport-perl/ns-xmlns "$NS_XMLNS" "$(val R4-ns-xmlns)" # --- the root context: xml is bound, nothing else is ------------------------ check_eq libxml-namespacesupport-perl/root-prefixes xml "$(val R5-root-prefixes)" check_eq libxml-namespacesupport-perl/root-default '' "$(val R7-root-default)" check_eq libxml-namespacesupport-perl/root-xml-uri "$NS_XML" "$(val R8-root-xml-uri)" # xmlns is bound only when the caller asks for it, so its absence by default is # as much a property of the port as its presence under the option. check_eq libxml-namespacesupport-perl/root-xmlns-absent '' "$(val R9-root-xmlns-uri)" check_eq libxml-namespacesupport-perl/xmlns-opt-prefixes 'xml,xmlns' "$(val R6-root-prefixes-xmlns)" check_eq libxml-namespacesupport-perl/xmlns-opt-uri "$NS_XMLNS" "$(val R9b-xmlns-uri)" # --- WHAT THE TICKET ASKS FOR: outer -> nested -> popped -------------------- # A prefix declared in an outer context resolves inside a nested one, and the # nested context's own declaration is gone after the pop while the outer one # survives. R16 is the case that fails if pop_context leaks. check_eq libxml-namespacesupport-perl/outer-declared "$U_A" "$(val R10-outer-a)" check_eq libxml-namespacesupport-perl/nested-inherits "$U_A" "$(val R11-nested-a-inherited)" check_eq libxml-namespacesupport-perl/nested-declared-empty '' "$(val R12-nested-declared-empty)" check_eq libxml-namespacesupport-perl/nested-declared "$U_B" "$(val R13-nested-b)" check_eq libxml-namespacesupport-perl/nested-prefixes 'a,b,xml' "$(val R14-nested-sees-both)" check_eq libxml-namespacesupport-perl/nested-declared-list b "$(val R14b-nested-declared)" check_eq libxml-namespacesupport-perl/outer-survives-pop "$U_A" "$(val R15-after-pop-a)" check_eq libxml-namespacesupport-perl/nested-gone-on-pop '' "$(val R16-after-pop-b)" check_eq libxml-namespacesupport-perl/prefixes-after-pop 'a,xml' "$(val R16b-after-pop-prefixes)" check_eq libxml-namespacesupport-perl/outer-gone-at-root '' "$(val R17-at-root-a)" # the same prefix rebound in a nested context: the inner binding wins, and the # outer one comes back rather than being destroyed check_eq libxml-namespacesupport-perl/shadow-inner "$U_B" "$(val R18-shadow-inner)" check_eq libxml-namespacesupport-perl/shadow-restored "$U_A" "$(val R19-shadow-restored)" # --- the default namespace, and the attribute rule -------------------------- # An unprefixed ELEMENT takes the default namespace; an unprefixed ATTRIBUTE # never does. That asymmetry is the whole of XML Namespaces section 6.2 and is # the rule a hand-rolled resolver most often gets wrong. check_eq libxml-namespacesupport-perl/default-uri "$U_DEF" "$(val R20-default-uri)" check_eq libxml-namespacesupport-perl/default-element "$U_DEF" "$(val R21-default-elem-ns)" check_eq libxml-namespacesupport-perl/default-attribute '' "$(val R22-default-attr-ns)" check_eq libxml-namespacesupport-perl/default-inherited "$U_DEF" "$(val R23-nested-default-inherited)" check_eq libxml-namespacesupport-perl/default-shadowed "$U_B" "$(val R24-default-shadow)" check_eq libxml-namespacesupport-perl/default-restored "$U_DEF" "$(val R25-default-restored)" # --- the xml prefix ----------------------------------------------------------- # It is bound in every context without being declared, cannot be rebound, and # its URI cannot be given to another prefix. The two errors are asserted by # MESSAGE, not merely as "something died": the module distinguishes the two # directions and a port that collapsed them would still die on both. check_eq libxml-namespacesupport-perl/xml-in-nested "$NS_XML" "$(val R26-xml-in-nested)" check_eq libxml-namespacesupport-perl/xml-rebind-dies \ "The xml prefix can only be bound to the $NS_XML namespace." "$(val R27-xml-rebind)" check_eq libxml-namespacesupport-perl/xml-intact-after-rebind "$NS_XML" "$(val R28-xml-still-bound)" check_eq libxml-namespacesupport-perl/xml-rebind-same-ok 1 "$(val R29-xml-same-ok)" check_eq libxml-namespacesupport-perl/nsxml-other-prefix-dies \ "the $NS_XML namespace can only be bound to the xml prefix." "$(val R30-nsxml-other-prefix)" # Every prefix beginning "xml" in any case is reserved. declare_prefix REFUSES # it with a false return instead of dying, so both halves are asserted: the # caller saw 0, AND the prefix really is unbound. A refusal that still bound # the prefix is the failure that a return-value-only check would miss. check_eq libxml-namespacesupport-perl/xmlish-refused 0 "$(val R31-xmlish-refused)" check_eq libxml-namespacesupport-perl/xmlish-unbound '' "$(val R32-xmlish-not-bound)" check_eq libxml-namespacesupport-perl/xmlish-case-refused 0 "$(val R33-XMLcase-refused)" check_eq libxml-namespacesupport-perl/xmlish-case-unbound '' "$(val R33b-XMLcase-not-bound)" check_eq libxml-namespacesupport-perl/xml-lang-resolves "$NS_XML|xml|lang" "$(val R34-xml-elem)" # --- AN UNDECLARED PREFIX IS undef, NOT THE WRONG URI ----------------------- # Measured in a context that deliberately holds a default namespace and two # other bindings, so a resolver that fell back to "something in scope" would # have three wrong answers available to return. check_eq libxml-namespacesupport-perl/undeclared-undef '' "$(val R35-undeclared-uri)" check_eq libxml-namespacesupport-perl/undeclared-dies \ 'Undeclared prefix: zzz' "$(val R36-undeclared-process)" # with fatal_errors off the same call returns NOTHING rather than a guess check_eq libxml-namespacesupport-perl/undeclared-nonfatal-count 0 "$(val R37-nonfatal-count)" check_eq libxml-namespacesupport-perl/undeclared-nonfatal-value '' "$(val R38-nonfatal-first)" # --- name processing, at values --------------------------------------------- # process_element_name returns (namespace, prefix, localname); process_name # returns (namespace, localname, qname) -- a different tuple, asserted here so # the two cannot be confused by a reader or by a future change. check_eq libxml-namespacesupport-perl/element-prefixed "$U_A|a|foo" "$(val R40-elem-prefixed)" check_eq libxml-namespacesupport-perl/attribute-prefixed "$U_A|a|bar" "$(val R41-attr-prefixed)" check_eq libxml-namespacesupport-perl/element-unprefixed '||plain' "$(val R42-elem-unprefixed)" check_eq libxml-namespacesupport-perl/process-name "$U_A|foo|a:foo" "$(val R43-process-name)" check_eq libxml-namespacesupport-perl/invalid-qname 'Invalid QName: a:b:c' "$(val R44-invalid-qname)" # --- lookup by URI, and what a context declared ----------------------------- check_eq libxml-namespacesupport-perl/prefixes-for-uri 'one,two' "$(val R45-prefixes-for-uri)" check_eq libxml-namespacesupport-perl/get-prefix-member 1 "$(val R46-get-prefix-member)" check_eq libxml-namespacesupport-perl/declared-prefixes 'one,two' "$(val R47-declared-prefixes)" check_eq libxml-namespacesupport-perl/get-prefix-unknown '' "$(val R48-get-prefix-unknown)" check_eq libxml-namespacesupport-perl/declared-at-root-dies \ 'At least one context must be pushed onto stack with push_context() before calling get_declared_prefixes()' \ "$(val R49-declared-at-root)" # --- undeclare_prefix and its scope rule ------------------------------------ check_eq libxml-namespacesupport-perl/undeclare-removes '' "$(val R50-undeclared-gone)" check_eq libxml-namespacesupport-perl/undeclare-list '' "$(val R50b-undeclared-list)" # an inherited prefix is visible but was not declared HERE, so undeclaring it # is an error and must leave the outer binding intact check_eq libxml-namespacesupport-perl/undeclare-foreign-dies \ 'prefix a not declared in this context' "$(val R51-undeclare-foreign)" check_eq libxml-namespacesupport-perl/undeclare-foreign-intact "$U_A" "$(val R51b-foreign-still-bound)" # --- XML 1.1 prefix undeclaration (xmlns_11, ON by default here) ------------ check_eq libxml-namespacesupport-perl/xmlns11-empty-ok 1 "$(val R52-xmlns11-empty-ok)" check_eq libxml-namespacesupport-perl/xmlns10-empty-dies \ 'Cannot declare prefix p' "$(val R53-xmlns10-empty)" # --- reset(), Clark notation, and the stack underflow ----------------------- check_eq libxml-namespacesupport-perl/reset-drops-context '' "$(val R54-reset-a)" check_eq libxml-namespacesupport-perl/reset-keeps-xml xml "$(val R55-reset-prefixes)" check_eq libxml-namespacesupport-perl/jclark-uri "$U_A" "$(val R56-jclark-uri)" check_eq libxml-namespacesupport-perl/jclark-local local "$(val R57-jclark-local)" check_eq libxml-namespacesupport-perl/pop-underflow-dies \ 'Trying to pop context without push context' "$(val R58-pop-underflow)" # --- the undef-prefix contract ---------------------------------------------- # declare_prefix(undef, ...) is a caller error: the module warns and refuses, # unless auto_prefix was asked for, in which case it invents 'aaa'. check_eq libxml-namespacesupport-perl/undef-prefix-refused 0 "$(val R59-undef-prefix-refused)" check_eq libxml-namespacesupport-perl/undef-prefix-warned 1 "$(val R60-undef-prefix-warned)" check_eq libxml-namespacesupport-perl/auto-prefix-accepted 1 "$(val R61-auto-prefix-accepted)" check_eq libxml-namespacesupport-perl/auto-prefix-name aaa "$(val R62-auto-prefix-name)" check_eq libxml-namespacesupport-perl/auto-prefix-uri "$U_A" "$(val R63-auto-prefix-uri)"