Megatest

Diff
Login

Differences From Artifact [63e9da460d]:

To Artifact [cb095d1eb1]:


46
47
48
49
50
51
52



53
54
55
56
57
58
59
(define *test-meta-updated* (make-hash-table))
(define *globalexitstatus*  0) ;; attempt to work around possible thread issues
(define *passnum*           0) ;; when running track calls to run-tests or similar
(define *write-frequency*   (make-hash-table)) ;; run-id => (vector (current-seconds) 0))
(define *alt-log-file* #f)  ;; used by -log
(define *common:denoise*    (make-hash-table)) ;; for low noise printing




;; DATABASE
(define *dbstruct-db*  #f)
(define *db-stats*            (make-hash-table)) ;; hash of vectors < count duration-total >
(define *db-stats-mutex*      (make-mutex))
(define *db-sync-mutex*       (make-mutex))
(define *db-multi-sync-mutex* (make-mutex))
(define *db-local-sync*       (make-hash-table)) ;; used to record last touch of db







>
>
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(define *test-meta-updated* (make-hash-table))
(define *globalexitstatus*  0) ;; attempt to work around possible thread issues
(define *passnum*           0) ;; when running track calls to run-tests or similar
(define *write-frequency*   (make-hash-table)) ;; run-id => (vector (current-seconds) 0))
(define *alt-log-file* #f)  ;; used by -log
(define *common:denoise*    (make-hash-table)) ;; for low noise printing

;; MULTI-TESTSUITE support
(define *testsuite-mutex* (make-mutex))

;; DATABASE
(define *dbstruct-db*  #f)
(define *db-stats*            (make-hash-table)) ;; hash of vectors < count duration-total >
(define *db-stats-mutex*      (make-mutex))
(define *db-sync-mutex*       (make-mutex))
(define *db-multi-sync-mutex* (make-mutex))
(define *db-local-sync*       (make-hash-table)) ;; used to record last touch of db
116
117
118
119
120
121
122

































































123
124
125
126
127
128
129
  (set! *env-vars-by-run-id* (make-hash-table))
  (set! *test-id-cache*      (make-hash-table)))

;; Generic string database
(define sdb:qry #f) ;; (make-sdb:qry)) ;;  'init #f)
;; Generic path database
(define *fdb* #f)


































































;;======================================================================
;; L O C K E R S   A N D   B L O C K E R S 
;;======================================================================

;; block further accesses to databases. Call this before shutting db down
(define (common:db-block-further-queries)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
  (set! *env-vars-by-run-id* (make-hash-table))
  (set! *test-id-cache*      (make-hash-table)))

;; Generic string database
(define sdb:qry #f) ;; (make-sdb:qry)) ;;  'init #f)
;; Generic path database
(define *fdb* #f)

;;======================================================================
;; G E N E R I C   S E T U P   F O R   A   T E S T S U I T E
;;======================================================================

;; set up the very basics needed for doing anything here.
;; this returns a common_records:testsuite record: < toppath linktree configdat envvars >
;;
(define (common:multi-setup-for-run #!key (force #f)(configdat-in #f))
  (mutex-lock! *testsuite-mutex*)
  (let* ((configinfo (or (if (get-environment-variable "MT_CMDINFO") ;; we are inside a test - do not reprocess configs
			     (let ((alistconfig (conc (get-environment-variable "MT_LINKTREE") "/"
						      (get-environment-variable "MT_TARGET")   "/"
						      (get-environment-variable "MT_RUNNAME")  "/"
						      ".megatest.cfg")))
			       (if (file-exists? alistconfig)
				   (list (configf:read-alist alistconfig)
					 (get-environment-variable "MT_RUN_AREA_HOME"))
				   #f))
			     #f) ;; no config cached - give up
			 (find-and-read-config 
			  (if (args:get-arg "-config")(args:get-arg "-config") "megatest.config")
			  environ-patt: "env-override"
			  given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
			  pathenvvar: "MT_RUN_AREA_HOME")))
	 (configdat  (if (car configinfo)(car configinfo) #f))
	 (toppath    (if (car configinfo)(cadr configinfo) #f))
	 (linktree   (configf:lookup configdat "setup" "linktree"))) ;; link tree is critical
    (if linktree
	(if (not (file-exists? linktree))
	    (begin
	      (handle-exceptions
	       exn
	       (begin
		 (debug:print 0 "ERROR: Something went wrong when trying to create linktree dir at " linktree)
		 (debug:print 0 " message: " ((condition-property-accessor 'exn 'message) exn)))
	       (create-directory linktree #t))))
	(begin
	  (debug:print 0 "ERROR: linktree not defined in [setup] section of megatest.config")
	  (exit 1)))
    (if linktree
	(let ((dbdir (or (configf:lookup configdat "setup" "dbdir") ;; not really supported yet, placeholder only
			 (conc linktree "/.db"))))
	  (handle-exceptions
	   exn
	   (begin
	     (debug:print 0 "ERROR: failed to create the " dbdir " area for your database files")
	     (debug:print 0 " message: " ((condition-property-accessor 'exn 'message) exn)))
	   (if (not (directory-exists? dbdir))(create-directory dbdir))))
	;; (setenv "MT_LINKTREE" linktree))
	(begin
	  (debug:print 0 "ERROR: linktree is required in your megatest.config [setup] section")
	  ;; (exit 1)
	  )
	)
    (if (not (and toppath
		  (directory-exists? toppath)))
	;; (setenv "MT_RUN_AREA_HOME" *toppath*)
	(begin
	  (debug:print 0 "ERROR: failed to find the top path to your Megatest area.")))
	;; (exit 1)))
    (mutex-unlock! *testsuite-mutex*)
    (vector toppath linktree configinfo
	    (list (cons "MT_LINKTREE" linktree)
		  (cons "MT_RUN_AREA_HOME" toppath)))))

;;======================================================================
;; L O C K E R S   A N D   B L O C K E R S 
;;======================================================================

;; block further accesses to databases. Call this before shutting db down
(define (common:db-block-further-queries)