;; Existing executor guards use excluded resourceData datatypes for Unsupported. ;; Each fault targets one real Case Record in a disposable fresh ASDF process. (require :asdf) (assert (string= "2.5.4" (lisp-implementation-version))) (setf *compile-verbose* nil *load-verbose* nil) (asdf:load-asd (merge-pathnames "../../topic-maps.asd" *load-truename*)) (asdf:load-system "topic-maps/xtm/tests") (let* ((family (uiop:getenv "TOPIC_MAPS_21L_FAMILY")) (mode (uiop:getenv "TOPIC_MAPS_21L_FAULT")) (target (cond ((string= family "positive") "xtm2/in/empty.xtm") ((string= family "negative") "xtm2/invalid/id-invalid.xtm") ((string= family "name") "xtm2/in/name.xtm") ((string= family "scope") "xtm2/in/name-scope.xtm") ((string= family "iid") "xtm2/in/itemid-name.xtm") ((string= family "variant") "xtm2/in/variant.xtm") ((string= family "variant-negative") "xtm2/invalid/variant-missing-scope-duplicate.xtm") ((string= family "merge-variant") "xtm2/in/merge-itemid-with-variants.xtm") ((string= family "resource-ref") "xtm2/in/variant-resourceref.xtm") ((string= family "resource-ref-relative") "xtm2/in/variant-resourceref-relative.xtm") ((string= family "uri-data") "xtm2/in/variant-resourcedata-uri.xtm") ((string= family "variant-iid") "xtm2/in/itemid-variant.xtm") ((string= family "variant-iid-duplicate") "xtm2/in/variant-duplicate-iid.xtm") ((member family '("map-reifier" "map-reifier-condition") :test #'string=) "xtm2/in/tm-reifier.xtm") (t (error "Unknown control family ~S" family))))) (if (string= family "map-reifier-condition") (let ((saved (symbol-function 'topic-maps.xtm.tests::map-reifier-error-control))) (setf (symbol-function 'topic-maps.xtm.tests::map-reifier-error-control) (lambda (label source class code &optional thunk map) (funcall saved label source class code (if (equal label "reuse-reifier") (lambda () (let* ((other (topic-maps.tmdm:make-topic-map)) (foreign (topic-maps.tmdm:intern-topic other :item-identifier "urn:foreign"))) (topic-maps.tmdm:set-item-reifier map foreign))) thunk) map)))) (if (string= mode "mismatch") (let ((saved (symbol-function 'topic-maps.cxtm:canonicalize-octets)) (iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" target))) (setf (symbol-function 'topic-maps.cxtm:canonicalize-octets) (lambda (map &rest args) (let ((actual (apply saved map args))) (if (equal iri (getf args :base-locator)) (let ((changed (copy-seq actual))) (setf (aref changed 0) (logxor 1 (aref changed 0))) changed) actual))))) (let* ((saved (symbol-function 'topic-maps.xtm:deserialize-octets)) (source (cond ((string= mode "xml") "") ((string= mode "unsupported") (topic-maps.xtm.tests::document "N42")) ((string= mode "tmdm") (topic-maps.xtm.tests::document (if (member family '("variant-iid" "variant-iid-duplicate") :test #'string=) "NVW" ""))) ((string= mode "xtm") (topic-maps.xtm.tests::document "")) ((string= mode "wrong-cause") (topic-maps.xtm.tests::document (if (string= family "variant-negative") "NV" ""))) ((string= mode "accepted") (topic-maps.xtm.tests::document "")) (t (error "Unknown control mode ~S" mode))))) (setf (symbol-function 'topic-maps.xtm:deserialize-octets) (lambda (raw &rest args) (if (and (equal target (getf args :source-key)) (string= family "map-reifier") (string= mode "tmdm")) ;; An actual native conflict; no synthetic Condition and no ;; extension of the XTM reader's excluded Name Reification. (let* ((map (topic-maps.tmdm:make-topic-map)) (r (topic-maps.tmdm:intern-topic map :item-identifier "urn:r")) (owner (topic-maps.tmdm:intern-topic map :item-identifier "urn:owner")) (name (topic-maps.tmdm:add-default-name owner "N"))) (topic-maps.tmdm:set-item-reifier map r) (topic-maps.tmdm:set-item-reifier name r)) (apply saved (if (equal target (getf args :source-key)) (topic-maps.xtm.tests::bytes source) raw) args))))))) (asdf:test-system "topic-maps/xtm")) (error "Fault injection did not cause the required ASDF failure.")