Megatest

Check-in [214b154bb2]
Login
Overview
Comment:Partial implemenation of writing out ods file from megatest.db
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 214b154bb2b6052ea4be937893ef2a1d2092333e
User & Date: mrwellan on 2011-09-07 23:52:18
Other Links: manifest | tags
Context
2011-09-08
15:10
Completed couple things for ods file extraction check-in: 9940aff1c0 user: mrwellan tags: trunk, v1.24
2011-09-07
23:52
Partial implemenation of writing out ods file from megatest.db check-in: 214b154bb2 user: mrwellan tags: trunk
21:40
Added basic ods writer check-in: 74f1ced943 user: mrwellan tags: trunk
Changes

Modified db.scm from [59e15d9a38] to [f6c0a6448e].

603
604
605
606
607
608
609
























































603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
						      (member (db:test-get-status test) '("PASS" "WARN" "CHECK"))))
					    (set! result (cons waitontest-name result))))))
				tests)
		      (if (not ever-seen)(set! result (cons waitontest-name result)))))
		  waiton)
	(delete-duplicates result))))

;;======================================================================
;; Extract ods file from the db
;;======================================================================

;; runspatt is a comma delimited list of run patterns
;; keypatt-alist must contain *all* keys with an associated pattern: '( ("KEY1" "%") .. )
(define (db:extract-ods-file db outputfile keypatt-alist runspatt)
  (let ((keysstr  (string-intersperse (map car keypatt-alist) ","))
	(keyqry   (string-intersperse (map (lambda (p)(conc (car p) " like ? ")) keypatt-alist) " AND "))
	(results   '())
	(test-ids '())
	(tempdir  (conc "/tmp/" (current-user-name) "/" runspatt "_" (random 10000) "_" (current-process-id))))
    (apply sqlite3:for-each-row
     (lambda (test-id . b)
       (set! test-ids (cons test-id test-ids))
       (set! results (append results (list b)))) ;; note, drop the test-id
     db
     (conc "SELECT
              t.id,runname," keysstr ",t.testname,description,
              item_path,t.state,t.status,
              attemptnum,final_logf,logdat,run_duration,r.comment,
              t.event_time,expected_value,value,tol,tol_perc,
              first_err,first_warn,tm.tags,
              r.owner,t.comment,
              author,tm.owner,reviewed,iterated,avg_runtime,
              diskfree,uname,rundir,avg_disk,t.tags,run_id,
              host,cpuload
            FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id INNER JOIN test_meta AS tm ON tm.testname=t.testname
            WHERE runname LIKE ? AND " keyqry ";")
     runspatt (map cadr keypatt-alist))
    (set! results (list "Runs" results))
    ;; now, for each test, collect the test_data info and add a new sheet
    (for-each
     (lambda (test-id)
       (let ((test-data '())
	     (curr-test-name #f))
	 (sqlite3:for-each-row
	  (lambda (testname item_path category variable value comment)
	    (set! curr-test-name testname)
	    (set! test-data (append test-data (list (list testname item_path category variable value comment)))))
	  db 
	  "SELECT testname,item_path,category,variable,value,comment FROM test_data INNER JOIN tests ON tests.id=test_data.test_id WHERE test_id=?;"
	  test-id)
	 (set! results (append results (list (cons curr-test-name test-data))))
	 ))
     test-ids)
    (system (conc "mkdir -p " tempdir))
    (pp results)
    (ods:list->ods 
     tempdir
     (if (string-match (regexp "^/") outputfile) ;; full path?
	 outputfile
	 (conc (current-directory) "/" outputfile))
     results)))

;; (db:extract-ods-file db "outputfile.ods" '(("sysname" "%")("fsname" "%")("datapath" "%")) "%")

Modified megatest.scm from [94499f5a91] to [410ce3edb9].

152
153
154
155
156
157
158

159
160
161
162
163
164
165
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166







+







(include "items.scm")
(include "db.scm")
(include "configf.scm")
(include "process.scm")
(include "launch.scm")
(include "runs.scm")
(include "runconfig.scm")
(include "ods.scm")

(define *didsomething* #f)

;;======================================================================
;; Misc setup stuff
;;======================================================================

Added tests/ods-test.scm version [08da0f4575].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
(load "ods.scm")

(ods:list->ods 
 "testing"
 "testing.ods"
  '((Sheet1 ("Row 1,A" "Row 1,B")
 	   ("Row 2,A" "Row 2,B"))
    (Sheet2 (1 2)
	    (3 4)
	    ()
	    ("This is sheet 2"))
    (Sheet_3 ("Test" "Item Path" "Category" "Value" "Comment")
	     ("LVS_esd" "eb8zxffd" "Cells"  "n"))))