Megatest

Diff
Login

Differences From Artifact [43202ebdc8]:

To Artifact [302c3da708]:


186
187
188
189
190
191
192

193
194
195
196
197
198
199
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200







+







			"-repl"
			"-lock"
			"-unlock"
			"-list-servers"
			;; mist queries
			"-list-disks"
			"-list-targets"
			"-list-db-targets"
			;; queries
			"-test-paths" ;; get path(s) to a test, ordered by youngest first

			"-runall"    ;; run all tests
			"-remove-runs"
			"-usequeue"
			"-rebuild-db"
261
262
263
264
265
266
267
268
269
270
271
272























273












274
275
276
277






278
279
280






281
282
283
284
285
286
287
262
263
264
265
266
267
268





269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304




305
306
307
308
309
310



311
312
313
314
315
316
317
318
319
320
321
322
323







-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+







;;======================================================================

(if (args:get-arg "-env2file")
    (begin
      (save-environment-as-files (args:get-arg "-env2file"))
      (set! *didsomething* #t)))

;; (if (args:get-arg "-list-targets")
;;     (print (string-intersperse
;; 	    (sort (map car (hash-table->alist
;; 			    (read-config "runconfigs.config"
;; 					 (make-hash-table) #f))) string<?) "\n")))
(if (args:get-arg "-list-targets")
    (begin
      (print (string-intersperse
	      (common:get-runconfig-targets)
	      "\n"))
      (set! *didsomething* #t)))

;; (if (args:get-arg "-list-db-targets")
;;     (if (setup-for-run)
;; 	(let* ((db       (open-db)) ;; A=%,B=foo => ("A=%" "B=foo")
;; 	       (keypatts (let ((pattstr  (args:get-arg "-list-db-targets")))
;; 			   (if (equal? pattstr "-") 
;; 			       #f
;; 			       (let ((all (string-split pattstr ",")))
;; 				 (map (lambda (x) ;; A=% => (A "%")
;; 					(string-split x "="))
;; 				      all)))))
;; 	       (runsdat  (db:get-runs db "%" #f #f keypatts))
;; 	       (runs     (cadr runsdat))
;; 	       (header   (car  runsdat))
;; 	       (seen     (make-hash-table))
;; 	       (keysdat  (db:get-keys db))
;; 	       (keys     (map (lambda (x)(vector-ref x 0)) keysdat)))
;; 
;; 	  (for-each 
;; 	   (lambda (run)
;; 	     (print (string-intersperse 
;; 		     (let loop ((key (car keys))
;; 				(tal (cdr keys))
;; 				(res '()))
;; 		       (let ((val (db:get-value-by-header run header key)))
;; 			 (if (null? tal)
;; 			     (append res (list val))
;; 			     (loop (car tal)(cdr tal)(append res (list val))))))
;; 		     "/")))
;; 	   runs))))
;; 
;; (if (args:get-arg "-list-disks")
;;     (print (string-intersperse 
;; 	    (map cadr (hash-table-ref/default 

(if (args:get-arg "-list-disks")
    (begin
      (print 
       (string-intersperse 
	(map (lambda (x)
;; 		       (read-config "megatest.config" #f #t) 
;; 		       "disks" "'" 
;; 		       ("none" ""))) "\n")))
	       (string-intersperse 
		x
		" => "))
	     (common:get-disks) )
	"\n"))
      (set! *didsomething* #t)))

;;======================================================================
;; Start the server - can be done in conjunction with -runall or -runtests (one day...)
;;   we start the server if not running else start the client thread
;;======================================================================

(if (args:get-arg "-server")
382
383
384
385
386
387
388
389


390
391
392

393


394
395
396
397
398



399
400
401
402
403
404
405



406
407
408










409
410
411
412
413
414
415
418
419
420
421
422
423
424

425
426
427
428
429
430

431
432
433
434
435
436

437
438
439
440
441
442




443
444
445



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462







-
+
+



+
-
+
+




-
+
+
+



-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+







     (lambda (target runname keys keynames keyvallst)
       (operate-on 'set-state-status))))

;;======================================================================
;; Query runs
;;======================================================================

(if (args:get-arg "-list-runs")
(if (or (args:get-arg "-list-runs")
	(args:get-arg "-list-db-targets"))
    (if (setup-for-run)
	(let* ((db       #f)
	       (runpatt  (args:get-arg "-list-runs"))
	       (testpatt (if (args:get-arg "-testpatt") 
	       (testpatt (args:get-arg "-testpatt"))
			     (args:get-arg "-testpatt") 
			     "A long and rediculous test name that hopefully will never match"))
	       (runsdat  (open-run-close db:get-runs db runpatt #f #f '()))
	       (runs     (db:get-rows runsdat))
	       (header   (db:get-header runsdat))
	       (keys     (open-run-close db:get-keys db))
	       (keynames (map key:get-fieldname keys)))
	       (keynames (map key:get-fieldname keys))
	       (db-targets (args:get-arg "-list-db-targets"))
	       (seen     (make-hash-table)))
	  ;; Each run
	  (for-each 
	   (lambda (run)
	     (debug:print 1 "Run: "
			  (string-intersperse (map (lambda (x)
						     (db:get-value-by-header run header x))
						   keynames) "/")
	     (let ((targetstr (string-intersperse (map (lambda (x)
							 (db:get-value-by-header run header x))
						       keynames) "/")))
			  "/"
			  (db:get-value-by-header run header "runname")
			  " status: " (db:get-value-by-header run header "state"))
	       (if db-targets
		   (if (not (hash-table-ref/default seen targetstr #f))
		       (begin
			 (hash-table-set! seen targetstr #t)
			 (print targetstr)))
		   (debug:print 1 
				(if db-targets "" "Run: ")
				targetstr 
				(if db-targets "" (conc " status: " (db:get-value-by-header run header "state"))))
		   ))
	     (let ((run-id (open-run-close db:get-value-by-header run header "id")))
	       (let ((tests (open-run-close db:get-tests-for-run db run-id testpatt '() '())))
		 ;; Each test
		 (for-each 
		  (lambda (test)
		    (format #t
			    "  Test: ~25a State: ~15a Status: ~15a Runtime: ~5@as Time: ~22a Host: ~10a\n"