Megatest

Check-in [00aca6f09e]
Login
Overview
Comment:Progress snapshot
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | run-mgr
Files: files | file ages | folders
SHA1: 00aca6f09e92fa4c5c1ab48c0fd0f7f09e2a6573
User & Date: matt on 2017-02-12 14:32:45
Other Links: branch diff | manifest | tags
Context
2017-02-12
20:33
Parts of command line coming together check-in: f8ecc58db2 user: matt tags: run-mgr
14:32
Progress snapshot check-in: 00aca6f09e user: matt tags: run-mgr
11:48
Split sensing out to new config file rungen.config check-in: 83aea4b059 user: matt tags: run-mgr
Changes

Modified megatest.config from [b40ed6ff61] to [5f36d3b956].

1
2
3
4

5
6
7
8
9
10
11
[setup]
pktsdirs /tmp/pkts /some/other/source

[areas]

fullrun tests/fullrun
ext-tests ext-tests

[contours]
#     mode-patt/tag-expr
quick QUICKPATT/quick
full  MAXPATT/long QUICKPATT/quick




>
|






1
2
3
4
5
6
7
8
9
10
11
12
[setup]
pktsdirs /tmp/pkts /some/other/source

[areas]
#         path-to-area   map-target-script(optional)
fullrun   tests/fullrun  cat
ext-tests ext-tests

[contours]
#     mode-patt/tag-expr
quick QUICKPATT/quick
full  MAXPATT/long QUICKPATT/quick

Modified mtut.scm from [5bb4365b55] to [95c6d56ac6].

133
134
135
136
137
138
139


140
141
142

143
144
145
146
147
148
149
    ("-manual"     . #f)
    ("-version"    . #f)
    ;; misc
    ("-repl"       . #f)
    ("-immediate"  . I)
    ))



;; a action
;; u username (Unix)
;; D timestamp


;; process args
(define *action* (if (> (length (argv)) 1)
		     (cadr (argv))
		     #f))
(define remargs (args:get-args 
		 (if *action* (cdr (argv)) (argv)) ;; args:get-args dumps first in argv list (the program name)







>
>



>







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    ("-manual"     . #f)
    ("-version"    . #f)
    ;; misc
    ("-repl"       . #f)
    ("-immediate"  . I)
    ))

;; Card types:
;;
;; a action
;; u username (Unix)
;; D timestamp
;; T card type

;; process args
(define *action* (if (> (length (argv)) 1)
		     (cadr (argv))
		     #f))
(define remargs (args:get-args 
		 (if *action* (cdr (argv)) (argv)) ;; args:get-args dumps first in argv list (the program name)
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
198
199


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
	       (args:get-arg "-envcap")
	       (args:get-arg "-envdelta")
	       )
	      ))
    (debug:print-error 0 *default-log-port* "Unrecognised arguments: " (string-intersperse (if (list? remargs) remargs (argv))  " ")))

;;======================================================================
;; Process pkts
;;======================================================================

(define (load-pkts-to-db mtconf)
  (let* ((pktsdirs (configf:lookup mtconf "setup"  "pktsdirs"))
	 (pktsdir  (if pktsdirs (car (string-split pktsdirs " ")) #f))
	 (toppath  (configf:lookup mtconf "dyndat" "toppath"))
	 (pdbpath  (or (configf:lookup mtconf "setup"  "pdbpath") pktsdir)))
    (if (not (and  pktsdir toppath pdbpath))
	(begin
	  (print "ERROR: settings are missing in your megatest.config for area management.")
	  (print "  you need to have pktsdir in the [setup] section."))
	(let* ((pdb  (open-queue-db pdbpath "pkts.db"
				    schema: '("CREATE TABLE groups (id INTEGER PRIMARY KEY,groupname TEXT, CONSTRAINT group_constraint UNIQUE (groupname));"))))







	  (for-each
	   (lambda (pktsdir) ;; look at all
	     (if (and (file-exists? pktsdir)
		      (directory? pktsdir)
		      (file-read-access? pktsdir))
		 (let ((pkts (glob (conc pktsdir "/*.pkt"))))
		   (for-each
		    (lambda (pkt)
		      (let* ((uuid    (cadr (string-match ".*/([0-9a-f]+).pkt" pkt)))
			     (exists  (lookup-by-uuid pdb uuid #f)))
			(if (not exists)
			    (let ((pktdat (string-intersperse
					   (with-input-from-file pkt read-lines)
					   "\n")))


			      (add-to-queue pdb pktdat uuid 'cmd #f 0)
			      (print "Added " uuid " to queue"))
			    (print "pkt: " uuid " exists, skipping...")
			    )))
		    pkts))))
	   (string-split pktsdirs))
	  (dbi:close pdb)))))

;;======================================================================
;; Runs
;;======================================================================

;; collect, translate, collate and assemble a pkt from the command-line
;;
(define (command-line->pkt args args-hash)







|


|










>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
|
|
|
|
|
|
<








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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217

218
219
220
221
222
223
224
225
	       (args:get-arg "-envcap")
	       (args:get-arg "-envdelta")
	       )
	      ))
    (debug:print-error 0 *default-log-port* "Unrecognised arguments: " (string-intersperse (if (list? remargs) remargs (argv))  " ")))

;;======================================================================
;; pkts
;;======================================================================

(define (with-queue-db mtconf proc)
  (let* ((pktsdirs (configf:lookup mtconf "setup"  "pktsdirs"))
	 (pktsdir  (if pktsdirs (car (string-split pktsdirs " ")) #f))
	 (toppath  (configf:lookup mtconf "dyndat" "toppath"))
	 (pdbpath  (or (configf:lookup mtconf "setup"  "pdbpath") pktsdir)))
    (if (not (and  pktsdir toppath pdbpath))
	(begin
	  (print "ERROR: settings are missing in your megatest.config for area management.")
	  (print "  you need to have pktsdir in the [setup] section."))
	(let* ((pdb  (open-queue-db pdbpath "pkts.db"
				    schema: '("CREATE TABLE groups (id INTEGER PRIMARY KEY,groupname TEXT, CONSTRAINT group_constraint UNIQUE (groupname));"))))
	  (proc pktsdirs pktsdir pdb)
	  (dbi:close pdb)))))

(define (load-pkts-to-db mtconf)
  (with-queue-db
   mtconf
   (lambda (pktsdirs pktsdir pdb)
     (for-each
      (lambda (pktsdir) ;; look at all
	(if (and (file-exists? pktsdir)
		 (directory? pktsdir)
		 (file-read-access? pktsdir))
	    (let ((pkts (glob (conc pktsdir "/*.pkt"))))
	      (for-each
	       (lambda (pkt)
		 (let* ((uuid    (cadr (string-match ".*/([0-9a-f]+).pkt" pkt)))
			(exists  (lookup-by-uuid pdb uuid #f)))
		   (if (not exists)
		       (let* ((pktdat (string-intersperse
				       (with-input-from-file pkt read-lines)
				       "\n"))
			      (apkt   (convert-pkt->alist pktdat))
			      (ptype  (alist-ref 'T apkt)))
			 (add-to-queue pdb pktdat uuid (or ptype 'cmd) #f 0)
			 (print "Added " uuid " of type " ptype " to queue"))
		       (print "pkt: " uuid " exists, skipping...")
		       )))
	       pkts))))
      (string-split pktsdirs)))))


;;======================================================================
;; Runs
;;======================================================================

;; collect, translate, collate and assemble a pkt from the command-line
;;
(define (command-line->pkt args args-hash)
268
269
270
271
272
273
274
275

276
277










278
279
280
281
282
283
284
	       (with-output-to-file
		   (conc pktsdir "/" uuid ".pkt")
		 (lambda ()
		   (print pkt)))
	       (print "ERROR: cannot process commands without a pkts directory")))))
      ((process import rungen)
       (let* ((mtconfdat (simple-setup (args:get-arg "-start-dir")))
	      (mtconf    (car mtconfdat)))

	 (case (string->symbol *action*)
	   ((import)(load-pkts-to-db mtconf)))))))











(if (or (args:get-arg "-repl")
	(args:get-arg "-load"))
    (begin
      (import extras) ;; might not be needed
      ;; (import csi)
      (import readline)







|
>

|
>
>
>
>
>
>
>
>
>
>







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
	       (with-output-to-file
		   (conc pktsdir "/" uuid ".pkt")
		 (lambda ()
		   (print pkt)))
	       (print "ERROR: cannot process commands without a pkts directory")))))
      ((process import rungen)
       (let* ((mtconfdat (simple-setup (args:get-arg "-start-dir")))
	      (mtconf    (car mtconfdat))
	      (toppath   (configf:lookup mtconf "dyndat" "toppath")))
	 (case (string->symbol *action*)
	   ((import)(load-pkts-to-db mtconf)) ;; import pkts
	   ((rungen)
	    (with-queue-db
	     mtconf
	     (lambda (pktsdirs pktdir pdb)
	       (let ((rgconf   (find-and-read-config (conc toppath "/rungen.config")))
		     (areas    (configf:get-section mtconf "areas"))
		     (contours (configf:get-section mtconf "contours"))
		     (runstats (find-pkts pdb '(runstat) '())))
		 (print "runstats: " runstats)))))
	   )))))

(if (or (args:get-arg "-repl")
	(args:get-arg "-load"))
    (begin
      (import extras) ;; might not be needed
      ;; (import csi)
      (import readline)