Megatest

Check-in [cdcc503117]
Login
Overview
Comment:added make-defstructs to read functions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | defstruct-srehman
Files: files | file ages | folders
SHA1: cdcc5031173140b6e9beed1e1db953dacd6e0d5a
User & Date: srehman on 2016-09-15 17:08:13
Other Links: branch diff | manifest | tags
Context
2016-09-19
11:13
merged with v1.62 latest build check-in: d854ad72ea user: srehman tags: defstruct-srehman
2016-09-15
17:08
added make-defstructs to read functions check-in: cdcc503117 user: srehman tags: defstruct-srehman
17:07
fixed var names check-in: 759d0eca16 user: srehman tags: defstruct-srehman
Changes

Modified db.scm from [2012e2597e] to [c566a984d2].

2283
2284
2285
2286
2287
2288
2289
2290

2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304

2305
2306
2307
2308
2309
2310
2311
2283
2284
2285
2286
2287
2288
2289

2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303

2304
2305
2306
2307
2308
2309
2310
2311







-
+













-
+







    (debug:print-info 8 *default-log-port* "db:get-tests-for-run qry=" qry)
    (db:with-db dbstruct run-id #f
		(lambda (db)
		  (sqlite3:for-each-row
		   (lambda (id testname item-path state status)
		     ;;                      id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment
		     ;;(set! res (cons (vector id run-id testname state status -1         ""     -1      -1       ""    "-"  item-path -1           "-"         "-") res)))
		     (cons (make-db:test-rec id: id testname: testname item-path: item-path state: state status: status) res))
		     (cons (make-db:test-rec id: id testname: testname item_path: item-path state: state status: status) res))
		   db 
		   qry
		   run-id)))
    res))

(define (db:get-testinfo-state-status dbstruct run-id test-id)
  (let ((res            '()))
    (db:with-db dbstruct run-id #f
		(lambda (db)
		  (sqlite3:for-each-row
		   (lambda (run-id testname item-path state status)
		     ;; id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment
		     ;;(set! res (vector test-id run-id testname state status -1 "" -1 -1 "" "-" item-path -1 "-" "-")))
		     (cons (make-db:test-rec run_id: run-id testname: testname item-path: item-path state: state status: status) res))
		     (cons (make-db:test-rec run_id: run-id testname: testname item_path: item-path state: state status: status) res))
		   db 
		   "SELECT run_id,testname,item_path,state,status FROM tests WHERE id=?;" 
		   test-id)))
    res))

;; get a useful subset of the tests data (used in dashboard
;; use db:mintest-get-{id ,run_id,testname ...}
2568
2569
2570
2571
2572
2573
2574
2575
2576






2577
2578
2579
2580
2581
2582
2583
2568
2569
2570
2571
2572
2573
2574


2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587







-
-
+
+
+
+
+
+







		    dbstruct)) ;; still settling on when to use dbstruct or dbdat
	 (db    (db:dbdat-get-db dbdat))
	 (res '()))
    (db:delay-if-busy dbdat)
    (sqlite3:for-each-row
     (lambda (id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment shortdir attemptnum archived)
       ;;                 0    1       2      3      4        5       6      7        8     9     10      11          12          13       14     15        16
       (set! res (cons (vector id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment shortdir attemptnum archived)
		       res)))
       ;;(set! res (cons (vector id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment shortdir attemptnum archived)
       (cons (make-db:test-rec id: id run-id: run-id testname: testname state: state status: status event_time: event-time
       		host: host cpuload: cpuload diskfree: diskfree uname: uname rundir: rundir item_path: item-path
       		run_duration: run-duration final_logf: final-logf comment: comment shortdir: shortdir 
       		attemptnum: attemptnum archived: archived )
		       res))
     db
     (conc "SELECT " db:test-record-qry-selector " FROM tests WHERE state != 'DELETED' AND run_id=?;")
     run-id)
    res))

(define (db:replace-test-records dbstruct run-id testrecs)
  (db:with-db dbstruct run-id #t 
2645
2646
2647
2648
2649
2650
2651
2652






2653
2654
2655
2656
2657
2658
2659
2649
2650
2651
2652
2653
2654
2655

2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668







-
+
+
+
+
+
+







   run-id
   #f
   (lambda (db)
     (let ((res #f))
       (sqlite3:for-each-row ;; attemptnum added to hold pid of top process (not Megatest) controlling a test
	(lambda (id run-id testname state status event-time host cpuload diskfree uname rundir-id item-path run_duration final-logf-id comment short-dir-id attemptnum archived)
	  ;;             0    1       2      3      4        5       6      7        8     9     10      11          12          13           14         15          16
	  (set! res (vector id run-id testname state status event-time host cpuload diskfree uname rundir-id item-path run_duration final-logf-id comment short-dir-id attemptnum archived)))
	  ;;(set! res (vector id run-id testname state status event-time host cpuload diskfree uname rundir-id item-path run_duration final-logf-id comment short-dir-id attemptnum archived)))
	  (cons (make-db:test-rec id: id run-id: run-id testname: testname state: state status: status event_time: event-time
       		host: host cpuload: cpuload diskfree: diskfree uname: uname rundir: rundir item_path: item-path
       		run_duration: run-duration final_logf: final-logf comment: comment shortdir: shortdir 
       		attemptnum: attemptnum archived: archived )
		       res))
	db
	(conc "SELECT " db:test-record-qry-selector " FROM tests WHERE id=?;")
	test-id)
       res))))

;; Use db:test-get* to access
;; Get test data using test_ids. NB// Only works within a single run!!
2679
2680
2681
2682
2683
2684
2685
2686

2687
2688
2689
2690
2691
2692
2693
2688
2689
2690
2691
2692
2693
2694

2695
2696
2697
2698
2699
2700
2701
2702







-
+







   dbstruct
   run-id
   #f
   (lambda (db)
     (let ((res #f))
       (sqlite3:for-each-row
	(lambda (a . b)
	  (set! res (apply vector a b)))
	  (print a));;set! res (apply vector a b)))
	db
	(conc "SELECT " db:test-record-qry-selector " FROM tests WHERE testname=? AND item_path=?;")
	test-name item-path)
       res))))

(define (db:test-get-rundir-from-test-id dbstruct run-id test-id)
  (db:with-db