1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
;;======================================================================
;; Copyright 2006-2012, Matthew Welland.
;;
;; This program is made available under the GNU GPL version 2.0 or
;; greater. See the accompanying file COPYING for details.
;;
;; This program is distributed WITHOUT ANY WARRANTY; without even the
;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE.
;;======================================================================
(declare (unit genexample))
(use posix regex)
(define genexample:example-logpro
#<<EOF
;; You should have at least one expect:required. This ensures that your process ran
;; comment out the line below and replace "put pattern here" with a pattern that will
;; always be seen in your log file if the step runs successfully.
;;
|
|
|
>
>
>
>
>
|
|
>
>
>
>
|
|
>
>
|
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
|
;;======================================================================
;; Copyright 2006-2012, Matthew Welland.
;;
;; This file is part of Megatest.
;;
;; Megatest is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Megatest is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Megatest. If not, see <http://www.gnu.org/licenses/>.
;;======================================================================
(declare (unit genexample))
(use posix regex matchable)
(include "db_records.scm")
(define genexample:example-logpro
#<<EOF
;; You should have at least one expect:required. This ensures that your process ran
;; comment out the line below and replace "put pattern here" with a pattern that will
;; always be seen in your log file if the step runs successfully.
;;
|
︙ | | | ︙ | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
(if (not (directory? path))
(begin
(print "The path " path " does not exist or is not a directory. Attempting to create it now")
(create-directory path #t)))
;; First check that the directory is empty!
(if (and (file-exists? path)
(not (null? (glob (conc path "/*")))))
(begin
(print "WARNING: directory " path " is not empty, are you sure you want to continue?")
(display "Enter y/n: ")
(if (equal? "y" (read-line))
(print "Using directory " path " for your Megatest area.")
(begin
|
|
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
(if (not (directory? path))
(begin
(print "The path " path " does not exist or is not a directory. Attempting to create it now")
(create-directory path #t)))
;; First check that the directory is empty!
(if (and (common:file-exists? path)
(not (null? (glob (conc path "/*")))))
(begin
(print "WARNING: directory " path " is not empty, are you sure you want to continue?")
(display "Enter y/n: ")
(if (equal? "y" (read-line))
(print "Using directory " path " for your Megatest area.")
(begin
|
︙ | | | ︙ | |
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
(print "[fields]")
(map (lambda (k)(print k " TEXT")) keys)
(print "")
(print "[setup]")
(print "# Adjust max_concurrent_jobs to limit how much you load your machines")
(print "max_concurrent_jobs 50\n")
(print "# This is your link path. Avoid moving it once set.")
(print "linktree " (common:real-path lntree))
(print "\n# Job tools are more advanced ways to control how your jobs are launched")
(print "[jobtools]\nuseshell yes\nlauncher nbfake\nmaxload 1.5\n")
(print "# You can override environment variables for all your tests here")
(print "[env-override]\nEXAMPLE_VAR example value\n")
(print "# As you run more tests you may need to add additional disks, the names are arbitrary but must be unique")
(print "[disks]\ndisk0 " (common:real-path firstd))))
(print
"==================
I'm now creating a runconfigs.config file for you with a default section.
You can use this file to set variables for your tests based on the \"target\" (the combination
of keys).
|
|
|
|
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
(print "[fields]")
(map (lambda (k)(print k " TEXT")) keys)
(print "")
(print "[setup]")
(print "# Adjust max_concurrent_jobs to limit how much you load your machines")
(print "max_concurrent_jobs 50\n")
(print "# This is your link path. Avoid moving it once set.")
(print "linktree " lntree) ;; (common:real-path lntree))
(print "\n# Job tools are more advanced ways to control how your jobs are launched")
(print "[jobtools]\nuseshell yes\nlauncher nbfake\nmaxload 1.5\n")
(print "# You can override environment variables for all your tests here")
(print "[env-override]\nEXAMPLE_VAR example value\n")
(print "# As you run more tests you may need to add additional disks, the names are arbitrary but must be unique")
(print "[disks]\ndisk0 " firstd))) ;; (common:real-path firstd))))
(print
"==================
I'm now creating a runconfigs.config file for you with a default section.
You can use this file to set variables for your tests based on the \"target\" (the combination
of keys).
|
︙ | | | ︙ | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
(print "# Override settings in ../runconfigs.config for user " (current-user-name) " here.")))
;; Now create a test and logpro file
(print
"==================
You now have the basic common files for your megatest setup. Next run
\"megatest -gen-test\" to create a test.
Thank you for using Megatest.
You can edit your config files and create tests in the " path " directory
")))
|
|
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
(print "# Override settings in ../runconfigs.config for user " (current-user-name) " here.")))
;; Now create a test and logpro file
(print
"==================
You now have the basic common files for your megatest setup. Next run
\"megatest -create-test <testname>\" to create a test.
Thank you for using Megatest.
You can edit your config files and create tests in the " path " directory
")))
|
︙ | | | ︙ | |
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
(description #f)
(steps '())
(scripts '())
(items '())
(rel-path #f))
(cond
((file-exists? "megatest.config") (set! rel-path "./"))
((file-exists? "../megatest.config") (set! rel-path "../"))
((file-exists? "../../megatest.config") (set! rel-path "../../"))
((file-exists? "../../../megatest.config")(set! rel-path "../../../"))) ;; good enough dang it.
;; Don't gather data or continue if a) megatest.config can't be found or b) testconfig already exists
(if (not rel-path)
(begin
(print "ERROR: I could not find megatest.config, please run -create-test in the top dir of your megatest area")
(exit 1)))
(if (file-exists? (conc rel-path "tests/" testname "/testconfig"))
(begin
(print "WARNING: You already have a testconfig in " rel-path "tests/" testname ", do you want to clobber your files?")
(display "Enter y/n: ")
(if (not (equal? "y" (read-line)))
(begin
(print "INFO: user abort of creation of test " testname)
(exit 1)))))
|
|
|
|
|
|
|
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
(description #f)
(steps '())
(scripts '())
(items '())
(rel-path #f))
(cond
((common:file-exists? "megatest.config") (set! rel-path "./"))
((common:file-exists? "../megatest.config") (set! rel-path "../"))
((common:file-exists? "../../megatest.config") (set! rel-path "../../"))
((common:file-exists? "../../../megatest.config")(set! rel-path "../../../"))) ;; good enough dang it.
;; Don't gather data or continue if a) megatest.config can't be found or b) testconfig already exists
(if (not rel-path)
(begin
(print "ERROR: I could not find megatest.config, please run -create-test in the top dir of your megatest area")
(exit 1)))
(if (common:file-exists? (conc rel-path "tests/" testname "/testconfig"))
(begin
(print "WARNING: You already have a testconfig in " rel-path "tests/" testname ", do you want to clobber your files?")
(display "Enter y/n: ")
(if (not (equal? "y" (read-line)))
(begin
(print "INFO: user abort of creation of test " testname)
(exit 1)))))
|
︙ | | | ︙ | |
327
328
329
330
331
332
333
|
(if (string-match ".*\\.sh$" script)
(begin
(with-output-to-file (conc testdir "/" script)
(lambda ()
(print genexample:example-script)))
(system (conc "chmod ug+r,a+x " (conc testdir "/" script)))))))
steps))))))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
|
(if (string-match ".*\\.sh$" script)
(begin
(with-output-to-file (conc testdir "/" script)
(lambda ()
(print genexample:example-script)))
(system (conc "chmod ug+r,a+x " (conc testdir "/" script)))))))
steps))))))
;; easier to work backwards than change the upstream code
;;
(define (hrs-min-sec->seconds str)
(let* ((parts (string-split str))
(res 0))
(for-each
(lambda (part)
(set! res
(+ res
(match (string-match "(\\d+)([a-z])" part)
((_ val units)(* (string->number val)(case (string->symbol units)
((s) 1)
((m) 60)
((h) 3600))))
(else 0)))))
parts)
res))
;; generate a skeleton Megatest area from a current area with runs
;;
;; specify target, runname etc to use specific runs for the template
;;
(define (genexample:extract-skeleton-area dest-path)
(let* ((target (args:get-arg "-target"))
(runname (args:get-arg "-runname"))
)
(if (not (and target runname))
(debug:print 0 *default-log-port* "WARNING: For best results please specifiy -target and -runname for a good run to use as a template."))
(if (not (and (file-exists? "megatest.config")
(file-exists? "megatest.db")))
(begin
(debug:print 0 *default-log-port* "ERROR: this command must be run at the top level of a megatest area where runs have been completed")
(exit)))
;; first create the dest path and needed subdirectories
(if (not (file-exists? dest-path))
(begin
(create-directory dest-path)
(create-directory (conc dest-path "/tests")))
(if (file-exists? (conc dest-path "/megatest.config"))
(begin
(debug:print 0 *default-log-port* "ERROR: destination path already has megatest.config, stopping now.")
(exit))))
;; dump the config files from this area to the dest area
(system (conc "megatest -show-config > " dest-path "/megatest.config"))
(system (conc "megatest -show-runconfig > " dest-path "/runconfigs.config"))
;; create a refdb, some stuff has to be done due to refdb not initing area
;; sheet row col value
;; test itempath stepname steptime
(if (not (file-exists? (conc dest-path "/stepsinfo")))
(begin
(create-directory (conc dest-path "/stepsinfo/sxml") #t)
(with-output-to-file (conc dest-path "/stepsinfo/sheet-names.cfg") (lambda ()(print)))))
;; rmt:get-tests-for-run
;; rmt:get-tests-for-run-mindata run-id testpatt states status not-in
;; rmt:simple-get-runs
;; (define-record simple-run target id runname state status owner event_time)
(let* ((runs (rmt:simple-get-runs (or runname "%") #f #f (or target "%")))
(tests (make-hash-table))
(refdb (conc dest-path "/stepsinfo")))
(if (> (length runs) 1)
(debug:print-info 0 *default-log-port* "More than one run matches, first found data will be used."))
;; get all testnames
(for-each
(lambda (run-id)
(let* ((tests-data (rmt:get-tests-for-run-mindata run-id "%" '() '() #f)))
(for-each
(lambda (testdat)
(let* ((test-id (db:mintest-get-id testdat))
(testname (db:mintest-get-testname testdat))
(item-path (db:mintest-get-item_path testdat))
;; now get steps info
(test-steps (tests:get-compressed-steps run-id test-id)))
(if (not (hash-table-exists? tests testname))
(begin
(print "\n" testname)
(for-each
(lambda (teststep)
(let* ((step-name (vector-ref teststep 0))
(step-duration (hrs-min-sec->seconds (vector-ref teststep 4))))
(system (conc "refdb set " refdb " " testname " '" (if (equal? item-path "")
"no-item-path"
item-path)
"' " step-name " " step-duration))
))
test-steps))
(else (debug:print-info 0 *default-log-port* "Skipping already seen test " testname)))))
tests-data)))
(map (lambda (runrec)(simple-run-id runrec)) runs)))
))
|