]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-21i/failure-controls.lisp
test: prove CTM/XTM anyType equivalence (slice 22T)
[topic-maps.git] / reports / slice-21i / failure-controls.lisp
1 ;; Existing executor guards use excluded resourceData datatypes for Unsupported.
2 ;; Each fault targets one real Case Record in a disposable fresh ASDF process.
3 (require :asdf)
4 (assert (string= "2.5.4" (lisp-implementation-version)))
5 (setf *compile-verbose* nil *load-verbose* nil)
6 (asdf:load-asd (merge-pathnames "../../topic-maps.asd" *load-truename*))
7 (asdf:load-system "topic-maps/xtm/tests")
8 (let* ((family (uiop:getenv "TOPIC_MAPS_21I_FAMILY")) (mode (uiop:getenv "TOPIC_MAPS_21I_FAULT"))
9 (target (cond ((string= family "positive") "xtm2/in/empty.xtm")
10 ((string= family "negative") "xtm2/invalid/id-invalid.xtm")
11 ((string= family "name") "xtm2/in/name.xtm")
12 ((string= family "scope") "xtm2/in/name-scope.xtm")
13 ((string= family "iid") "xtm2/in/itemid-name.xtm")
14 ((string= family "variant") "xtm2/in/variant.xtm")
15 ((string= family "variant-negative") "xtm2/invalid/variant-missing-scope-duplicate.xtm")
16 ((string= family "merge-variant") "xtm2/in/merge-itemid-with-variants.xtm")
17 ((string= family "resource-ref") "xtm2/in/variant-resourceref.xtm")
18 ((string= family "resource-ref-relative") "xtm2/in/variant-resourceref-relative.xtm")
19 (t (error "Unknown control family ~S" family)))))
20 (if (string= mode "mismatch")
21 (let ((saved (symbol-function 'topic-maps.cxtm:canonicalize-octets))
22 (iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" target)))
23 (setf (symbol-function 'topic-maps.cxtm:canonicalize-octets)
24 (lambda (map &rest args)
25 (let ((actual (apply saved map args)))
26 (if (equal iri (getf args :base-locator))
27 (let ((changed (copy-seq actual))) (setf (aref changed 0) (logxor 1 (aref changed 0))) changed)
28 actual)))))
29 (let* ((saved (symbol-function 'topic-maps.xtm:deserialize-octets))
30 (source (cond ((string= mode "xml") "<a><b></a>")
31 ((string= mode "unsupported") (topic-maps.xtm.tests::document "<topic id='a'><name><value>N</value><variant><scope><topicRef href='#s'/></scope><resourceData datatype='http://www.w3.org/2001/XMLSchema#anyURI'>urn:excluded</resourceData></variant></name></topic>"))
32 ((string= mode "tmdm") (topic-maps.xtm.tests::document "<itemIdentity href='#a'/><topic id='a'/>"))
33 ((string= mode "xtm") (topic-maps.xtm.tests::document "<topic id='2bad'/>"))
34 ((string= mode "wrong-cause") (topic-maps.xtm.tests::document
35 (if (string= family "variant-negative")
36 "<topic id='a'><name><scope><topicRef href='#base'/></scope><value>N</value><variant><scope><topicRef href='#extra'/></scope><resourceData>V</resourceData></variant></name></topic><topic id='base'><itemIdentity href='#extra'/></topic>"
37 "<topic/>")))
38 ((string= mode "accepted") (topic-maps.xtm.tests::document "<topic id='valid'/>"))
39 (t (error "Unknown control mode ~S" mode)))))
40 (setf (symbol-function 'topic-maps.xtm:deserialize-octets)
41 (lambda (raw &rest args)
42 (apply saved (if (equal target (getf args :source-key)) (topic-maps.xtm.tests::bytes source) raw) args)))))
43 (asdf:test-system "topic-maps/xtm"))
44 (error "Fault injection did not cause the required ASDF failure.")