]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-22s/failure-controls.lisp
test: prove CTM/XTM anyType equivalence (slice 22T)
[topic-maps.git] / reports / slice-22s / failure-controls.lisp
1 ;; Slice 22S copy of the existing executor; Unsupported retargeted to an explicit unresolved mergeMap.
2 ;; All 113 controls remain; real resource-resolver-required replaces former anyType exclusion.
3 ;; Each fault targets one real Case Record in a disposable fresh ASDF process.
4 (require :asdf)
5 (assert (string= "2.5.4" (lisp-implementation-version)))
6 (setf *compile-verbose* nil *load-verbose* nil)
7 (asdf:load-asd (merge-pathnames "../../topic-maps.asd" *load-truename*))
8 (asdf:load-system "topic-maps/xtm/tests")
9 (let* ((family (uiop:getenv "TOPIC_MAPS_21O_FAMILY")) (mode (uiop:getenv "TOPIC_MAPS_21O_FAULT"))
10 (target (cond ((string= family "datatype") "xtm2/in/variant-datatype-unknown.xtm")
11 ((string= family "variant-reifier-followup") "xtm2/in/variant-duplicate-reifier2.xtm")
12 ((string= family "positive") "xtm2/in/empty.xtm")
13 ((string= family "negative") "xtm2/invalid/id-invalid.xtm")
14 ((string= family "name") "xtm2/in/name.xtm")
15 ((string= family "scope") "xtm2/in/name-scope.xtm")
16 ((string= family "iid") "xtm2/in/itemid-name.xtm")
17 ((string= family "variant") "xtm2/in/variant.xtm")
18 ((string= family "variant-negative") "xtm2/invalid/variant-missing-scope-duplicate.xtm")
19 ((string= family "merge-variant") "xtm2/in/merge-itemid-with-variants.xtm")
20 ((string= family "resource-ref") "xtm2/in/variant-resourceref.xtm")
21 ((string= family "resource-ref-relative") "xtm2/in/variant-resourceref-relative.xtm")
22 ((string= family "uri-data") "xtm2/in/variant-resourcedata-uri.xtm")
23 ((string= family "variant-iid") "xtm2/in/itemid-variant.xtm")
24 ((string= family "variant-iid-duplicate") "xtm2/in/variant-duplicate-iid.xtm")
25 ((member family '("map-reifier" "map-reifier-condition") :test #'string=) "xtm2/in/tm-reifier.xtm")
26 ((member family '("name-reifier" "name-reifier-condition") :test #'string=) "xtm2/in/name-reifier.xtm")
27 ((string= family "name-reifier-duplicate") "xtm2/in/name-duplicate-reified.xtm")
28 ((string= family "name-followup2") "xtm2/in/name-duplicate-reified2.xtm")
29 ((string= family "name-followup3") "xtm2/in/name-duplicate-reified3.xtm")
30 ((string= family "name-followup4") "xtm2/in/name-duplicate-reified4.xtm")
31 ((member family '("variant-reifier" "variant-reifier-condition") :test #'string=) "xtm2/in/variant-reifier.xtm")
32 ((string= family "variant-reifier-duplicate") "xtm2/in/variant-duplicate-reifier.xtm")
33 (t (error "Unknown control family ~S" family)))))
34 (if (member family '("map-reifier-condition" "name-reifier-condition" "variant-reifier-condition") :test #'string=)
35 (let ((saved (symbol-function 'topic-maps.xtm.tests::map-reifier-error-control)))
36 (setf (symbol-function 'topic-maps.xtm.tests::map-reifier-error-control)
37 (lambda (label source class code &optional thunk map)
38 (funcall saved label source class code
39 (if (equal label (cond ((string= family "name-reifier-condition") "name:native-reuse-reifier") ((string= family "variant-reifier-condition") "variant:native-reuse-reifier") (t "reuse-reifier")))
40 (lambda ()
41 (let* ((other (topic-maps.tmdm:make-topic-map))
42 (foreign (topic-maps.tmdm:intern-topic other :item-identifier "urn:foreign")))
43 (topic-maps.tmdm:set-item-reifier map foreign)))
44 thunk) map))))
45 (if (string= mode "mismatch")
46 (let ((saved (symbol-function 'topic-maps.cxtm:canonicalize-octets))
47 (iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" target)))
48 (setf (symbol-function 'topic-maps.cxtm:canonicalize-octets)
49 (lambda (map &rest args)
50 (let ((actual (apply saved map args)))
51 (if (equal iri (getf args :base-locator))
52 (let ((changed (copy-seq actual))) (setf (aref changed 0) (logxor 1 (aref changed 0))) changed)
53 actual)))))
54 (let* ((saved (symbol-function 'topic-maps.xtm:deserialize-octets))
55 (source (cond ((string= mode "xml") "<a><b></a>")
56 ((string= mode "unsupported") (topic-maps.xtm.tests::document "<mergeMap href='urn:22s:requires-explicit-resolver'/>"))
57 ((string= mode "tmdm") (topic-maps.xtm.tests::document
58 (cond ((member family '("name-reifier" "name-reifier-duplicate" "name-followup2" "name-followup3" "name-followup4") :test #'string=)
59 "<topic id='a'><name reifier='#r'><value>A</value></name><name reifier='#r'><value>B</value></name></topic>")
60 ((member family '("variant-reifier" "variant-reifier-duplicate" "variant-reifier-followup" "datatype") :test #'string=)
61 "<topic id='a'><name><value>N</value><variant reifier='#r'><scope><topicRef href='#s'/></scope><resourceData datatype='urn:custom:conflict'>A</resourceData></variant><variant reifier='#r'><scope><topicRef href='#s'/></scope><resourceData datatype='urn:custom:conflict'>B</resourceData></variant></name></topic>")
62 ((member family '("variant-iid" "variant-iid-duplicate") :test #'string=)
63 "<topic id='a'><name><value>N</value><variant><itemIdentity href='urn:collision'/><scope><topicRef href='#s'/></scope><resourceData>V</resourceData></variant><variant><itemIdentity href='urn:collision'/><scope><topicRef href='#s'/></scope><resourceData>W</resourceData></variant></name></topic>")
64 (t "<itemIdentity href='#a'/><topic id='a'/>"))))
65 ((string= mode "xtm") (topic-maps.xtm.tests::document "<topic id='2bad'/>"))
66 ((string= mode "wrong-cause") (topic-maps.xtm.tests::document
67 (if (string= family "variant-negative")
68 "<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>"
69 "<topic/>")))
70 ((string= mode "accepted") (topic-maps.xtm.tests::document "<topic id='valid'/>"))
71 (t (error "Unknown control mode ~S" mode)))))
72 (setf (symbol-function 'topic-maps.xtm:deserialize-octets)
73 (lambda (raw &rest args)
74 (if (and (equal target (getf args :source-key)) (string= family "map-reifier") (string= mode "tmdm"))
75 ;; Generate an actual native conflict, retaining the previous
76 ;; Map-Reification executor control.
77 (let* ((map (topic-maps.tmdm:make-topic-map))
78 (r (topic-maps.tmdm:intern-topic map :item-identifier "urn:r"))
79 (owner (topic-maps.tmdm:intern-topic map :item-identifier "urn:owner"))
80 (name (topic-maps.tmdm:add-default-name owner "N")))
81 (topic-maps.tmdm:set-item-reifier map r)
82 (topic-maps.tmdm:set-item-reifier name r))
83 (apply saved (if (equal target (getf args :source-key)) (topic-maps.xtm.tests::bytes source) raw) args)))))))
84 (asdf:test-system "topic-maps/xtm"))
85 (error "Fault injection did not cause the required ASDF failure.")