102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
(define test-path "tests/test1")
(define disk-path #f)
(test "get-best-disk" #t (string? (file-exists? (let ((d (get-best-disk *configdat*)))
(set! disk-path d)
d))))
(test "create-work-area" #t (symbolic-link? (car (create-work-area 1 rinfo keyvals 1 test-path disk-path "test1" '()))))
(test #f "" (item-list->path '()))
(test "launch-test" #t
(string?
(file-exists?
;; (launch-test test-id run-id run-info keyvals runname test-conf test-name test-path itemdat params)
(launch-test 30001 1 rinfo keyvals "run1" tconfig "test1" test-path '() (make-hash-table)))))
;; (test "Run a test" #t (general-run-call
;; "-runtests"
;; "run a test"
;; (lambda (target runname keys keyvallst)
;; (let ((test-patts "test%"))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
(define test-path "tests/test1")
(define disk-path #f)
(test "get-best-disk" #t (string? (file-exists? (let ((d (get-best-disk *configdat*)))
(set! disk-path d)
d))))
(test "create-work-area" #t (symbolic-link? (car (create-work-area 1 rinfo keyvals 1 test-path disk-path "test1" '()))))
(test #f "" (item-list->path '()))
;;======================================================================
;; Create a test with multiple items and verify that rollup logic works
;;======================================================================
(rmt:register-test 1 "rollup" "") ;; toplevel test
(for-each
(lambda (itempath)
(rmt:register-test 1 "rollup" itempath)
(let ((test-id (rmt:get-test-id 1 "rollup" itempath))
(comment (conc "This is a comment for itempath " itempath)))
;; (rmt:test-set-state-status-by-id run-id test-id "COMPLETED" "PASS" comment)
(tests:test-set-status! 1 test-id "COMPLETED" "PASS" comment #f))) ;; #!key (work-area #f))
'("item/1" "item/2" "item/3" "item/4" "item/5"))
(test #f #t (number? (rmt:get-test-id 1 "rollup" "item/4")))
(define (get-state-status run-id testname itempath)
(let ((tdat (rmt:get-test-info-by-id 1 (rmt:get-test-id run-id testname itempath))))
(list (db:test-get-state tdat)
(db:test-get-status tdat))))
(test "Rollup PASS" '("COMPLETED" "PASS") (get-state-status 1 "rollup" ""))
(let ((test-id (rmt:get-test-id 1 "rollup" "item/4"))
(top-id (rmt:get-test-id 1 "rollup" "")))
(for-each
(lambda (state status rup-state rup-status)
;; reset to COMPLETED/PASS
(tests:test-set-status! 1 test-id "COMPLETED" "PASS" #f #f)
(test "Top reset to COMPLETED/PASS" '("COMPLETED" "PASS")(get-state-status 1 "rollup" ""))
(tests:test-set-status! 1 test-id state status #f #f)
(test (conc "Item set to " state "/" status)
(list state status)
(get-state-status 1 "rollup" "item/4"))
(test (conc "Rollup of " state "/" status " correct")
(list rup-state rup-status)
(get-state-status 1 "rollup" "")))
'("COMPLETED" "COMPLETED" "INCOMPLETE" "INCOMPLETE" "RUNNING" "RUNNING" "COMPLETED")
'("ABORT" "FAIL" "PASS" "FAIL" "PASS" "FAIL" "BLAH")
'("COMPLETED" "COMPLETED" "COMPLETED" "COMPLETED" "RUNNING" "RUNNING" "COMPLETED")
'("FAIL" "FAIL" "FAIL" "FAIL" "PASS" "FAIL" "FAIL")))
(test "launch-test" #t
(string?
(file-exists?
;; (launch-test test-id run-id run-info keyvals runname test-conf test-name test-path itemdat params)
(launch-test 30001 1 rinfo keyvals "run1" tconfig "test1" test-path '() (make-hash-table)))))
(exit 1)
;; (test "Run a test" #t (general-run-call
;; "-runtests"
;; "run a test"
;; (lambda (target runname keys keyvallst)
;; (let ((test-patts "test%"))
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
;; (test "cache is coherent" #t (let ((cached-info (db:get-test-info-cached-by-id db 2))
;; (non-cached (db:get-test-info-not-cached-by-id db 2)))
;; (print "\nCached: " cached-info)
;; (print "Noncached: " non-cached)
;; (equal? cached-info non-cached)))
(change-directory test-work-dir)
(test "Add a step" #t
(begin
(db:teststep-set-status! db 2 "step1" "start" 0 "This is a comment" "mylogfile.html")
(sleep 2)
(db:teststep-set-status! db 2 "step1" "end" "pass" "This is a different comment" "finallogfile.html")
(set! test-id (db:test-get-id (car (cdb:remote-run db:get-tests-for-run #f 1 "test1" '() '()))))
(number? test-id)))
(test "Get rundir" #t (let ((rundir (cdb:remote-run db:test-get-rundir-from-test-id #f test-id)))
(print "Rundir " rundir)
(system (conc "mkdir -p " rundir))
(string? rundir)))
(test #f #t (sqlite3#database? (open-test-db "./")))
|
>
|
|
|
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
;; (test "cache is coherent" #t (let ((cached-info (db:get-test-info-cached-by-id db 2))
;; (non-cached (db:get-test-info-not-cached-by-id db 2)))
;; (print "\nCached: " cached-info)
;; (print "Noncached: " non-cached)
;; (equal? cached-info non-cached)))
(change-directory test-work-dir)
(test #f #t (> (length (mt:get-tests-for-run 1 "test1" '() '())) 0))
(test "Add a step" #t
(begin
(rmt:teststep-set-status! 1 30002 "step1" "start" 0 "This is a comment" "mylogfile.html")
(sleep 2)
(rmt:teststep-set-status! 1 30002 "step1" "end" "pass" "This is a different comment" "finallogfile.html")
(set! test-id (db:test-get-id (car (mt:get-tests-for-run 1 "test1" '() '()))))
(number? test-id)))
(test "Get rundir" #t (let ((rundir (cdb:remote-run db:test-get-rundir-from-test-id #f test-id)))
(print "Rundir " rundir)
(system (conc "mkdir -p " rundir))
(string? rundir)))
(test #f #t (sqlite3#database? (open-test-db "./")))
|