Megatest

Check-in [dd508f0885]
Login
Overview
Comment:It compiles
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65-real-new-runs-view-wip3
Files: files | file ages | folders
SHA1: dd508f0885d679c208f3fc5b4f99b37064bbae65
User & Date: matt on 2021-02-27 18:53:12
Other Links: branch diff | manifest | tags
Context
2021-02-27
21:06
compiles and basics run check-in: a3b4a5e4bc user: matt tags: v1.65-real-new-runs-view-wip3
18:53
It compiles check-in: dd508f0885 user: matt tags: v1.65-real-new-runs-view-wip3
11:33
wip check-in: 219180af64 user: matt tags: v1.65-real-new-runs-view-wip3
Changes

Modified Makefile from [f416862a44] to [26dfe3b087].

17
18
19
20
21
22
23
24

25
26
27

28
29
30
31
32
33
34
35


36
37
38
39
40
41
42
17
18
19
20
21
22
23

24
25
26

27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43







-
+


-
+







-
+
+








# make install CSCOPTS='-accumulate-profile -profile-name $(PWD)/profile-ww$(shell date +%V.%u)'
# rm <files>.o ; make install CSCOPTS='-profile' ; ... ;  chicken-profile | less
SHELL=/bin/bash
PREFIX=$(PWD)
CSCOPTS=
INSTALL=install
SRCFILES = common.scm items.scm launch.scm runconfig.scm	\
SRCFILES = common.scm launch.scm runconfig.scm	\
           server.scm configf.scm db.scm		\
           process.scm runs.scm tests.scm genexample.scm	\
           http-transport.scm filedb.scm tdb.scm mt.scm	\
           http-transport.scm filedb.scm mt.scm	\
           ezsteps.scm lock-queue.scm sdb.scm rmt.scm api.scm		\
           subrun.scm archive.scm env.scm		\
           diff-report.scm

# module source files
MSRCFILES = dbmod.scm servermod.scm apimod.scm commonmod.scm rmtmod.scm \
            ods.scm configfmod.scm transport.scm portlogger.scm tasks.scm \
            pgdb.scm margsmod.scm debugprint.scm client.scm
            pgdb.scm margsmod.scm debugprint.scm client.scm items.scm \
            tdb.scm

MOFILES = $(addprefix mofiles/,$(MSRCFILES:%.scm=%.o))
MOIMPFILES = $(MSRCFILES:%.scm=%.import.o)

# ftail.scm rmtmod.scm commonmod.scm removed
# MSRCFILES = ducttape-lib.scm pkts.scm stml2.scm cookie.scm mutils.scm	\
#             mtargs.scm commonmod.scm dbmod.scm adjutant.scm ulex.scm	\
83
84
85
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
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
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98
99
100
101
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







-



+

















-
-





-








-







# ARCHSTR=$(shell uname -m)_$(shell uname -r)
# BASH_MACHTYPE=$(shell bash -c "echo \$$MACHTYPE")
# ARCHSTR=$(BASH_MACHTYPE)_$(shell lsb_release -sr)
ARCHSTR=$(shell if [[ -e /usr/bin/sw_vers ]]; then /usr/bin/sw_vers -productVersion; else lsb_release -sr; fi)

PNGFILES = $(shell cd docs/manual;ls *png)

# all : $(PREFIX)/bin/.$(ARCHSTR) mtest dboard mtut ndboard
all : $(PREFIX)/bin/.$(ARCHSTR) mtest dboard mtut tcmt

mtest: $(OFILES) readline-fix.scm megatest.o $(MOFILES) $(MOIMPFILES)  megatest-version.scm
	@echo "Suggestion: run make build.pdf to regenerate dependencies"
	csc $(CSCOPTS) $(OFILES) $(MOFILES) $(MOIMPFILES) megatest.o -o mtest

showmtesthash:
	@echo $(MTESTHASH)

# dboard : $(OFILES) $(GOFILES) dashboard.scm $(MOFILES) $(MOIMPFILES) megatest-version.scm megatest-fossil-hash.scm dashboard-new-runs-view.scm
dboard : $(OFILES) $(GOFILES) dashboard.scm $(MOFILES) $(MOIMPFILES) $(DMOFILES) $(DMOIMPFILES) megatest-version.scm megatest-fossil-hash.scm dashboard-new-runs-view.scm
	csc $(CSCOPTS) $(OFILES) dashboard.scm $(GOFILES) $(MOFILES) $(MOIMPFILES) $(DMOFILES) $(DMOIMPFILES) -o dboard

mtut: $(OFILES) $(MOFILES) megatest-fossil-hash.scm mtut.scm megatest-version.scm
	csc $(CSCOPTS) $(OFILES) $(MOFILES) mtut.scm -o mtut

# include makefile.inc

TCMTOBJS = \
	api.o \
	archive.o \
	cgisetup/models/pgdb.o \
	client.o \
	common.o \
	configf.o \
	db.o \
	env.o \
	http-transport.o \
	items.o \
	launch.o \
	lock-queue.o \
	mt.o \
	process.o \
	rmt.o \
	runconfig.o \
	runs.o \
	server.o \
	tdb.o \
	tests.o \
	subrun.o \
        ezsteps.o

# 	 ods.o \
#        mofiles/rmtmod.o \
#        mofiles/commonmod.o \
443
444
445
446
447
448
449
450
451




452
453
454
455
456
457
458
440
441
442
443
444
445
446


447
448
449
450
451
452
453
454
455
456
457







-
-
+
+
+
+








portlogger-example : portlogger-example.scm api.o archive.o client.o common.o configf.o dashboard-tests.o dashboard-context-menu.o db.o dcommon.o ezsteps.o filedb.o genexample.o gutils.o http-transport.o items.o launch.o lock-queue.o mofiles/margsmod.o mt.o mofiles/portlogger.o process.o rmt.o runconfig.o runs.o sdb.o server.o synchash.o mofiles/tasks.o tdb.o tests.o tree.o
	csc $(CSCOPTS) portlogger-example.scm api.o archive.o client.o common.o configf.o dashboard-tests.o dashboard-context-menu.o db.o dcommon.o ezsteps.o filedb.o genexample.o gutils.o http-transport.o items.o launch.o lock-queue.o mofiles/margsmod.o mt.o mofiles/portlogger.o process.o rmt.o runconfig.o runs.o sdb.o server.o synchash.o mofiles/tasks.o tdb.o tests.o tree.o

%.pdf : %.dot
	dot -Tpdf $*.dot -o $*.pdf

all.dot all-inc.dot : *.scm cgisetup/models/pgdb.scm
	gendeps all *.scm 
build.dot build-inc.dot : *.scm cgisetup/models/pgdb.scm
	gendeps build *.scm 

# build.inc : build.dot

buildmanual:
	cd docs/manual && make

wikipage=plan
editwiki:
	cd docs/manual && ../../utils/editwiki $(wikipage)

Modified api.scm from [87d8f25daf] to [26d83ebd3e].

17
18
19
20
21
22
23



24
25
17
18
19
20
21
22
23
24
25
26
27
28







+
+
+


;; 
;;     You should have received a copy of the GNU General Public License
;;     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.
;;
;;======================================================================

(use srfi-69 posix)

(declare (unit api))



Modified build.inc from [0dfa31656d] to [da84f2ecb8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

















































22
23
24
25
26

27
28

29
30
31
32
33

34
35
36


37
38
39
40

41
42
43
44
45
46
47
48






49
50
51
52



53
54

1
2
3
4
5
















6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55




56


57





58



59
60




61








62
63
64
65
66
67




68
69
70


71





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

-
-
-
-
+
-
-
+
-
-
-
-
-
+
-
-
-
+
+
-
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
+
# To regenerate this file do:
#   (cd utils/;ck52 csc gendeps.scm) && ./utils/gendeps allunits *scm
#   cp allunits.inc build.inc
#

mofiles/apimod.o : mofiles/commonmod.o
mofiles/apimod.o : mofiles/dbmod.o
mofiles/apimod.o : mofiles/debugprint.o
mofiles/apimod.o : mofiles/tasks.o
mofiles/apimod.o : mofiles/client.o
mofiles/commonmod.o : mofiles/debugprint.o
mofiles/commonmod.o : mofiles/margsmod.o
mofiles/commonmod.o : mofiles/configfmod.o
mofiles/configfmod.o : mofiles/margsmod.o
mofiles/client.o : mofiles/servermod.o
mofiles/client.o : mofiles/rmtmod.o
mofiles/dbmod.o : mofiles/commonmod.o
mofiles/dbmod.o : mofiles/configfmod.o
mofiles/dbmod.o : mofiles/debugprint.o
mofiles/dbmod.o : mofiles/margsmod.o
mofiles/dbmod.o : mofiles/ods.o
mofiles/tdb.o : mofiles/dbmod.o
mofiles/tasks.o : mofiles/dbmod.o
mofiles/servermod.o : mofiles/dbmod.o
mofiles/rmtmod.o : mofiles/dbmod.o
mofiles/portlogger.o : mofiles/dbmod.o
mofiles/client.o : mofiles/dbmod.o
mofiles/apimod.o : mofiles/dbmod.o
mofiles/tdb.o : mofiles/ods.o
mofiles/dbmod.o : mofiles/ods.o
mofiles/transport.o : mofiles/configfmod.o
mofiles/tasks.o : mofiles/configfmod.o
mofiles/servermod.o : mofiles/configfmod.o
mofiles/rmtmod.o : mofiles/configfmod.o
mofiles/portlogger.o : mofiles/configfmod.o
mofiles/pgdb.o : mofiles/configfmod.o
mofiles/items.o : mofiles/configfmod.o
mofiles/dcommonmod.o : mofiles/configfmod.o
mofiles/dbmod.o : mofiles/configfmod.o
mofiles/commonmod.o : mofiles/configfmod.o
mofiles/transport.o : mofiles/portlogger.o
mofiles/rmtmod.o : mofiles/portlogger.o
mofiles/rmtmod.o : mofiles/items.o
mofiles/rmtmod.o : mofiles/tdb.o
mofiles/tasks.o : mofiles/pgdb.o
mofiles/transport.o : mofiles/debugprint.o
mofiles/tdb.o : mofiles/debugprint.o
mofiles/tasks.o : mofiles/debugprint.o
mofiles/servermod.o : mofiles/debugprint.o
mofiles/rmtmod.o : mofiles/debugprint.o
mofiles/portlogger.o : mofiles/debugprint.o
mofiles/pgdb.o : mofiles/debugprint.o
mofiles/ods.o : mofiles/debugprint.o
mofiles/items.o : mofiles/debugprint.o
mofiles/dcommonmod.o : mofiles/debugprint.o
mofiles/dbmod.o : mofiles/debugprint.o
mofiles/configfmod.o : mofiles/debugprint.o
mofiles/commonmod.o : mofiles/debugprint.o
mofiles/client.o : mofiles/debugprint.o
mofiles/apimod.o : mofiles/debugprint.o
mofiles/apimod.o : mofiles/tasks.o
mofiles/transport.o : mofiles/commonmod.o
mofiles/tdb.o : mofiles/commonmod.o
mofiles/tasks.o : mofiles/commonmod.o
mofiles/servermod.o : mofiles/commonmod.o
mofiles/rmtmod.o : mofiles/commonmod.o
mofiles/portlogger.o : mofiles/commonmod.o
mofiles/pgdb.o : mofiles/commonmod.o
mofiles/ods.o : mofiles/commonmod.o
mofiles/items.o : mofiles/commonmod.o
mofiles/dcommonmod.o : mofiles/commonmod.o
mofiles/dcommonmod.o : mofiles/configfmod.o
mofiles/dcommonmod.o : mofiles/debugprint.o
mofiles/debugprint.o : mofiles/margsmod.o
mofiles/ods.o : mofiles/commonmod.o
mofiles/dbmod.o : mofiles/commonmod.o
mofiles/ods.o : mofiles/debugprint.o
mofiles/portlogger.o : mofiles/commonmod.o
mofiles/client.o : mofiles/commonmod.o
mofiles/portlogger.o : mofiles/configfmod.o
mofiles/portlogger.o : mofiles/dbmod.o
mofiles/portlogger.o : mofiles/debugprint.o
mofiles/rmtmod.o : mofiles/apimod.o
mofiles/rmtmod.o : mofiles/commonmod.o
mofiles/apimod.o : mofiles/commonmod.o
mofiles/rmtmod.o : mofiles/configfmod.o
mofiles/rmtmod.o : mofiles/dbmod.o
mofiles/rmtmod.o : mofiles/debugprint.o
mofiles/transport.o : mofiles/apimod.o
mofiles/rmtmod.o : mofiles/apimod.o
mofiles/rmtmod.o : mofiles/portlogger.o
mofiles/servermod.o : mofiles/commonmod.o
mofiles/servermod.o : mofiles/configfmod.o
mofiles/servermod.o : mofiles/dbmod.o
mofiles/tdb.o : mofiles/margsmod.o
mofiles/servermod.o : mofiles/debugprint.o
mofiles/servermod.o : mofiles/rmtmod.o
mofiles/tasks.o : mofiles/commonmod.o
mofiles/tasks.o : mofiles/configfmod.o
mofiles/tasks.o : mofiles/dbmod.o
mofiles/tasks.o : mofiles/debugprint.o
mofiles/tasks.o : mofiles/margsmod.o
mofiles/tasks.o : mofiles/pgdb.o
mofiles/tasks.o : mofiles/margsmod.o
mofiles/rmtmod.o : mofiles/margsmod.o
mofiles/pgdb.o : mofiles/margsmod.o
mofiles/debugprint.o : mofiles/margsmod.o
mofiles/dbmod.o : mofiles/margsmod.o
mofiles/configfmod.o : mofiles/margsmod.o
mofiles/transport.o : mofiles/apimod.o
mofiles/transport.o : mofiles/commonmod.o
mofiles/transport.o : mofiles/configfmod.o
mofiles/transport.o : mofiles/debugprint.o
mofiles/commonmod.o : mofiles/margsmod.o
mofiles/transport.o : mofiles/servermod.o
mofiles/client.o : mofiles/servermod.o
mofiles/transport.o : mofiles/portlogger.o
mofiles/transport.o : mofiles/servermod.o
mofiles/servermod.o : mofiles/rmtmod.o

Modified dashboard.scm from [34a5c499cc] to [b63dfdc16f].

21
22
23
24
25
26
27

28
29
30










31
32
33
34
35
36
37
38


39
40
41
42
43
44
45
21
22
23
24
25
26
27
28
29


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







+

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








+
+







(use format)

(require-library iup)
(import (prefix iup iup:))

(use canvas-draw)
(import canvas-draw-iup)

(use ducttape-lib)
(use sqlite3 srfi-1 posix regex regex-case srfi-69 typed-records sparse-vectors
     matchable) ;; defstruct
(use sqlite3
     srfi-1
     posix
     regex
     regex-case
     srfi-69
     typed-records
     sparse-vectors
     matchable)

(import (prefix sqlite3 sqlite3:))


(declare (uses common))
(declare (uses margsmod))
(import margsmod)

(declare (uses items))
(import items)

(declare (uses db))
(declare (uses configf))
(declare (uses process))
(declare (uses launch))
(declare (uses runs))
(declare (uses dashboard-tests))
(declare (uses dashboard-guimonitor))

Modified db_records.scm from [87bd276d2f] to [cbf9399908].

74
75
76
77
78
79
80
81
82
83
84
85





86
87
88
89
90
91
92
74
75
76
77
78
79
80





81
82
83
84
85
86
87
88
89
90
91
92







-
-
-
-
-
+
+
+
+
+







;;     (dbr:dbstruct-path-set! v path)
;;     (dbr:dbstruct-local-set! v local)
;;     (dbr:dbstruct-locdbs-set! v (make-hash-table))
;;     v))

;; Returns the database for a particular run-id fron the dbstruct:localdbs
;;
(define (dbr:dbstruct-localdb v run-id)
  (hash-table-ref/default (dbr:dbstruct-locdbs v) run-id #f))

(define (dbr:dbstruct-localdb-set! v run-id db)
  (hash-table-set! (dbr:dbstruct-locdbs v) run-id db))
;; (define (dbr:dbstruct-localdb v run-id)
;;   (hash-table-ref/default (dbr:dbstruct-locdbs v) run-id #f))
;; 
;; (define (dbr:dbstruct-localdb-set! v run-id db)
;;   (hash-table-set! (dbr:dbstruct-locdbs v) run-id db))


(define (make-db:test)(make-vector 20))
(define-inline (db:test-get-id           vec) (vector-ref vec 0))
(define-inline (db:test-get-run_id       vec) (vector-ref vec 1))
(define-inline (db:test-get-testname     vec) (vector-ref vec 2))
(define-inline (db:test-get-state        vec) (vector-ref vec 3))

Modified dcommon.scm from [8d80bc37a6] to [f3a8d144b3].

28
29
30
31
32
33
34

35
36
37
38
39
40
41
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







+







(declare (unit dcommon))

(declare (uses gutils))
(declare (uses db))

(declare (uses commonmod))
(declare (uses debugprint))

(import commonmod)
(import debugprint)

(declare (uses dbmod))
(import dbmod)

(declare (uses configfmod))

Modified http-transport.scm from [dc3e5fe249] to [5c6dd61f45].

62
63
64
65
66
67
68
69

70
71
72
73
74
75
76
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76







-
+








(declare (uses servermod))
(import servermod)

(declare (uses transport))
(import transport)

(declare (uses margsmod)])
(declare (uses margsmod))
(import margsmod)

(include "common_records.scm")
(include "db_records.scm")
;; (include "js-path.scm")

;; (require-library stml)

Modified items.scm from [e4ba382538] to [88a87a75c9].

19
20
21
22
23
24
25
26
27
28






29
30
31
32
33




34
35
36
37
38
39
40
19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35



36
37
38
39
40
41
42
43
44
45
46







-


+
+
+
+
+
+


-
-
-
+
+
+
+








;; (define itemdat '((ripeness    "green ripe overripe")
;; 		     (temperature "cool medium hot")
;; 		     (season      "summer winter fall spring")))

(declare (unit items))
(declare (uses common))

(declare (uses commonmod))
(declare (uses debugprint))
(declare (uses configfmod))

(module items
	*

(import scheme chicken data-structures extras ports)
(import commonmod)
(import debugprint)

(declare (uses configfmod))
(import configfmod)
(import configfmod)
(import srfi-69
	srfi-1
	)

(include "common_records.scm")

;; Puts out all combinations
(define (process-itemlist hierdepth curritemkey itemlist)
  (let ((res '()))
    (if (not hierdepth)
210
211
212
213
214
215
216
217
218

219
220
216
217
218
219
220
221
222


223
224
225







-
-
+


	(append (item-assoc->item-list items)
		(item-table->item-list itemstable)
		(items:read-items-file slashf 'slash)
		(items:read-items-file sxmlf  'sxml)
		(items:read-items-file spacef 'space))
	'(()))))

;; (pp (item-assoc->item-list itemdat))

)

	

Modified pgdb.scm from [c36721630d] to [a2e7a9d7da].

1


1
-
+
(include "cgisetup/models/pgdb.scm")
cgisetup/models/pgdb.scm

Modified rmtmod.scm from [d2e9fe8c20] to [dc5879432a].

22
23
24
25
26
27
28


29
30
31
32
33
34
35
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37







+
+







(declare (uses commonmod))
(declare (uses debugprint))
(declare (uses apimod))
(declare (uses dbmod))
(declare (uses configfmod))
(declare (uses margsmod))
(declare (uses portlogger))
(declare (uses items))
(declare (uses tdb))

(module rmtmod
	*
	
(import scheme chicken data-structures extras ports)
(import (prefix sqlite3 sqlite3:)
	directory-utils
54
55
56
57
58
59
60


61
62
63
64
65
66
67
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







+
+







(import apimod)
(import commonmod)
(import debugprint)
(import dbmod)
(import configfmod)
(import margsmod)
(import portlogger)
(import items)
(import tdb)

(defstruct alldat
  (areapath #f)
  (ulexdat  #f)
  )

(define (rmtmod:calc-ro-mode runremote *toppath*)
2566
2567
2568
2569
2570
2571
2572
2573













2574













2575











2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604

2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615








+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
			  )))
		  (begin    ;; no server registered
		    ;; (server:kind-run areapath)
		    (server:start-and-wait areapath)
		    (debug:print-info 0 *default-log-port* "client:setup, no server registered, remaining-tries=" remaining-tries)
		    (thread-sleep! 1) ;; (+ 5 (random (- 20 remaining-tries))))  ;; give server a little time to start up, randomize a little to avoid start storms.
		    (client:setup-http areapath remaining-tries: (- remaining-tries 1)))))))))

;; NOTE: Run this local with #f for db !!!
(define (tdb:load-test-data run-id test-id)
  (let loop ((lin (read-line)))
    (if (not (eof-object? lin))
	(begin
	  (debug:print 4 *default-log-port* lin)
          ;;(when lin ;; this when blocked stack dump caused by .dat file from logpro being 0-byte.  fixed by upgrading logpro
          (rmt:csv->test-data run-id test-id lin)
          ;;)
	  (loop (read-line)))))
  ;; roll up the current results.
  ;; FIXME: Add the status too 
  (rmt:test-data-rollup run-id test-id #f))

;; NOTE: Run this local with #f for db !!!
(define (tdb:load-logpro-data run-id test-id)
  (let loop ((lin (read-line)))
    (if (not (eof-object? lin))
	(begin
	  (debug:print 4 *default-log-port* lin)
          ;;(when lin  ;; this when blocked stack dump caused by .dat file from logpro being 0-byte.  fixed by upgrading logpro
          (rmt:csv->test-data run-id test-id lin)
          ;;)
	  (loop (read-line)))))
  ;; roll up the current results.
  ;; FIXME: Add the status too 
  (rmt:test-data-rollup run-id test-id #f))
)

;; find and open the testdat.db file for an existing test
(define (tdb:open-test-db-by-test-id test-id #!key (work-area #f))
  (let* ((test-path (if work-area
			work-area
			(rmt:test-get-rundir-from-test-id test-id))))
    (debug:print 3 *default-log-port* "TEST PATH: " test-path)
    (open-test-db test-path)))


)

Modified tdb.scm from [ffd7d10ddb] to [3c898d537a].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39




















40
41
42
43
44
45
46
47
48
49
50
51
52
53
18
19
20
21
22
23
24





25
26
27
28
29
30




31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

54
55

56
57
58
59
60
61
62







-
-
-
-
-






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



-


-







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

;;======================================================================
;; Database access
;;======================================================================

(require-extension (srfi 18) extras tcp)
(use sqlite3 srfi-1 posix regex regex-case srfi-69 csv-xml s11n md5 message-digest base64)
(import (prefix sqlite3 sqlite3:))
(import (prefix base64 base64:))

(declare (unit tdb))
(declare (uses common))
(declare (uses client))
(declare (uses mt))
(declare (uses db))
(declare (uses margsmod))
(import margsmod)

(declare (uses commonmod))
(declare (uses debugprint))
(declare (uses commonmod))
(declare (uses debugprint))
(declare (uses dbmod))
(declare (uses ods))

(module tdb
	*

(import scheme chicken data-structures extras ports)

(import (srfi 18) extras tcp)
(use sqlite3 srfi-1 posix regex regex-case srfi-69 csv-xml s11n md5 message-digest base64)



(import (prefix sqlite3 sqlite3:))
(import (prefix base64 base64:))

(import margsmod)

(import commonmod)
(import debugprint)

(declare (uses dbmod))
(import dbmod)

(declare (uses ods))
(import ods)

(include "common_records.scm")
(include "db_records.scm")
(include "key_records.scm")
(include "run_records.scm")

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
168
169
170
171
172
173
174








175
176
177
178
179
180
181







-
-
-
-
-
-
-
-







      ;; no work-area or not readable - create a placeholder to fake rest of world out
      (let ((baddb (sqlite3:open-database ":memory:")))
 	(debug:print-info 11 *default-log-port* "open-test-db END (unsucessful)" work-area)
 	;; provide an in-mem db (this is dangerous!)
 	(tdb:testdb-initialize baddb)
 	baddb)))

;; find and open the testdat.db file for an existing test
(define (tdb:open-test-db-by-test-id test-id #!key (work-area #f))
  (let* ((test-path (if work-area
			work-area
			(rmt:test-get-rundir-from-test-id test-id))))
    (debug:print 3 *default-log-port* "TEST PATH: " test-path)
    (open-test-db test-path)))

;; find and open the testdat.db file for an existing test
(define (tdb:open-test-db-by-test-id-local dbstruct run-id test-id #!key (work-area #f))
  (let* ((test-path (if work-area
			work-area
			(db:test-get-rundir-from-test-id dbstruct run-id test-id))))
    (debug:print 3 *default-log-port* "TEST PATH: " test-path)
    (open-test-db test-path)))
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
263
264
265
266
267
268
269




























270
271
272
273
274
275
276







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







;; 	     (set! res (cons (vector id test_id category variable value expected tol units comment status type) res)))
;; 	   tdb
;; 	   "SELECT id,test_id,category,variable,value,expected,tol,units,comment,status,type FROM test_data WHERE test_id=? AND category LIKE ? ORDER BY category,variable;" test-id categorypatt)
;; 	  (sqlite3:finalize! tdb)
;; 	  (reverse res))
;; 	'())))

;; NOTE: Run this local with #f for db !!!
(define (tdb:load-test-data run-id test-id)
  (let loop ((lin (read-line)))
    (if (not (eof-object? lin))
	(begin
	  (debug:print 4 *default-log-port* lin)
          ;;(when lin ;; this when blocked stack dump caused by .dat file from logpro being 0-byte.  fixed by upgrading logpro
          (rmt:csv->test-data run-id test-id lin)
          ;;)
	  (loop (read-line)))))
  ;; roll up the current results.
  ;; FIXME: Add the status too 
  (rmt:test-data-rollup run-id test-id #f))

;; NOTE: Run this local with #f for db !!!
(define (tdb:load-logpro-data run-id test-id)
  (let loop ((lin (read-line)))
    (if (not (eof-object? lin))
	(begin
	  (debug:print 4 *default-log-port* lin)
          ;;(when lin  ;; this when blocked stack dump caused by .dat file from logpro being 0-byte.  fixed by upgrading logpro
          (rmt:csv->test-data run-id test-id lin)
          ;;)
	  (loop (read-line)))))
  ;; roll up the current results.
  ;; FIXME: Add the status too 
  (rmt:test-data-rollup run-id test-id #f))

;;======================================================================
;; S T E P S 
;;======================================================================

(define (tdb:step-get-time-as-string vec)
  (seconds->time-string (tdb:step-get-event_time vec)))

447
448
449
450
451
452
453
454

455
456
457
458
459
460
461
462

420
421
422
423
424
425
426

427
428
429
430
431
432
433
434
435
436







-
+








+
			 (if (eq? time-a time-b)
			     (string<? (conc (vector-ref a 2))
				       (conc (vector-ref b 2)))
			     #f))
		     (string<? (conc time-a)(conc time-b))))))))

;; 
(define (tdb:remote-update-testdat-meta-info run-id test-id work-area cpuload diskfree minutes)
#;(define (tdb:remote-update-testdat-meta-info run-id test-id work-area cpuload diskfree minutes)
  (let ((tdb         (rmt:open-test-db-by-test-id run-id test-id work-area: work-area)))
    (if (sqlite3:database? tdb)
	(begin
	  (sqlite3:execute tdb "INSERT INTO test_rundat (update_time,cpuload,diskfree,run_duration) VALUES (strftime('%s','now'),?,?,?);"
			   cpuload diskfree minutes)
	  (sqlite3:finalize! tdb))
	(debug:print 2 *default-log-port* "Can't update testdat.db for test " test-id " read-only or non-existant"))))
    
)