Megatest

Check-in [06c4198b8e]
Login
Overview
Comment:Extracted aliases into scripts for convience functions mt_runstep and mt_laststep, fixed validvalues handling
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 06c4198b8e27eca7d6b5b8609c32a73c5f783216
User & Date: matt on 2011-09-25 18:02:09
Other Links: manifest | tags
Context
2011-09-25
18:54
Fixed sorting issue on steps in dashboard check-in: 89b1a10150 user: matt tags: trunk
18:02
Extracted aliases into scripts for convience functions mt_runstep and mt_laststep, fixed validvalues handling check-in: 06c4198b8e user: matt tags: trunk
15:40
Fixed broken -list-runs, dashboard key filters check-in: 2ab4dded8c user: matt tags: trunk
Changes

Modified dashboard.scm from [d2fd43fdf3] to [f4b8fd3a36].

528
529
530
531
532
533
534








535
536


537
538
539
540
541
542
543
544
545


546
547
548
549
550
551
552
    (set! *num-tests* (min (max (update-rundat "%" *num-runs* "%" "%" '()) 8) 20)))

(define *tim* (iup:timer))
(define *ord* #f)
(iup:attribute-set! *tim* "TIME" 300)
(iup:attribute-set! *tim* "RUN" "YES")









(define (run-update x)
  (update-buttons uidat *num-runs* *num-tests*)


  (update-rundat (hash-table-ref/default *searchpatts* "runname" "%") *num-runs*
		 (hash-table-ref/default *searchpatts* "test-name" "%")
		 (hash-table-ref/default *searchpatts* "item-name" "%")
		 (let ((res '()))
		   (for-each (lambda (key)
			       (let ((val (hash-table-ref/default *searchpatts* key #f)))
				 (if val (set! res (cons (list key val) res)))))
			     *dbkeys*)
		   res)))



(cond 
 ((args:get-arg "-run")
  (let ((runid (string->number (args:get-arg "-run"))))
    (if runid
	(begin
	  (lambda (x)







>
>
>
>
>
>
>
>


>
>
|
|
|
|
|
|
|
|
|
>
>







528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
    (set! *num-tests* (min (max (update-rundat "%" *num-runs* "%" "%" '()) 8) 20)))

(define *tim* (iup:timer))
(define *ord* #f)
(iup:attribute-set! *tim* "TIME" 300)
(iup:attribute-set! *tim* "RUN" "YES")

;; Move this stuff to db.scm FIXME
;;
(define *last-db-update-time* (file-modification-time (conc *toppath* "/megatest.db")))
(define (db:been-changed)
  (> (file-modification-time (conc *toppath* "/megatest.db")) *last-db-update-time*))
(define (db:set-db-update-time)
  (set! *last-db-update-time* (file-modification-time (conc *toppath* "/megatest.db"))))

(define (run-update x)
  (update-buttons uidat *num-runs* *num-tests*)
  ;; (if (db:been-changed)
  (begin
    (update-rundat (hash-table-ref/default *searchpatts* "runname" "%") *num-runs*
		   (hash-table-ref/default *searchpatts* "test-name" "%")
		   (hash-table-ref/default *searchpatts* "item-name" "%")
		   (let ((res '()))
		     (for-each (lambda (key)
				 (let ((val (hash-table-ref/default *searchpatts* key #f)))
				   (if val (set! res (cons (list key val) res)))))
			       *dbkeys*)
		     res))
    ; (db:set-db-update-time)
    ))

(cond 
 ((args:get-arg "-run")
  (let ((runid (string->number (args:get-arg "-run"))))
    (if runid
	(begin
	  (lambda (x)

Modified runs.scm from [9b2009f6fd] to [55aae7c602].

404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
	 (status    (check-valid-items "status" status-in))
	 (item-path (item-list->path itemdat))
	 (testdat   (db:get-test-info db run-id test-name item-path)))
    (debug:print 5 "testdat: " testdat)
    (if (and testdat ;; if the section exists then force specification BUG, I don't like how this works.
	     (or (not state)(not status)))
	(debug:print 0 "WARNING: Invalid " (if status "status" "state")
	       " value \"" (if status status-in state-in) "\", update your validstates section in megatest.config"))
    (if testdat
	(let ((test-id (test:get-id testdat)))
	  (sqlite3:execute db 
			"INSERT OR REPLACE into test_steps (test_id,stepname,state,status,event_time,comment) VALUES(?,?,?,?,strftime('%s','now'),?);"
			test-id teststep-name state status (if comment comment "")))
	(debug:print 0 "ERROR: Can't update " test-name " for run " run-id " -> no such test in db"))))

(define (test-get-kill-request db run-id test-name itemdat)
  (let* ((item-path (item-list->path itemdat))
	 (testdat   (db:get-test-info db run-id test-name item-path)))
    (equal? (test:get-state testdat) "KILLREQ")))








|




|







404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
	 (status    (check-valid-items "status" status-in))
	 (item-path (item-list->path itemdat))
	 (testdat   (db:get-test-info db run-id test-name item-path)))
    (debug:print 5 "testdat: " testdat)
    (if (and testdat ;; if the section exists then force specification BUG, I don't like how this works.
	     (or (not state)(not status)))
	(debug:print 0 "WARNING: Invalid " (if status "status" "state")
	       " value \"" (if status state-in status-in) "\", update your validvalues section in megatest.config"))
    (if testdat
	(let ((test-id (test:get-id testdat)))
	  (sqlite3:execute db 
			"INSERT OR REPLACE into test_steps (test_id,stepname,state,status,event_time,comment) VALUES(?,?,?,?,strftime('%s','now'),?);"
			test-id teststep-name state-in status-in (if comment comment "")))
	(debug:print 0 "ERROR: Can't update " test-name " for run " run-id " -> no such test in db"))))

(define (test-get-kill-request db run-id test-name itemdat)
  (let* ((item-path (item-list->path itemdat))
	 (testdat   (db:get-test-info db run-id test-name item-path)))
    (equal? (test:get-state testdat) "KILLREQ")))

Modified tests/megatest.config from [077783b818] to [dd77d506f9].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## use "xterm -e csi -- " as a launcher to examine the launch environment.
## exit with (exit)
## get a shell with (system "bash")
# launcher xterm -e csi --

[validvalues]
state start end completed
status pass fail n/a

# These are set before all tests, override them 
# in the testconfig [pre-launch-env-overrides] section
[env-override]
SPECIAL_ENV_VARS overide them here - should be seen at launch and in the runs
TESTVAR [system realpath .]
DEADVAR [system ls]







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## use "xterm -e csi -- " as a launcher to examine the launch environment.
## exit with (exit)
## get a shell with (system "bash")
# launcher xterm -e csi --

[validvalues]
state start end completed
status pass fail n/a 0 1

# These are set before all tests, override them 
# in the testconfig [pre-launch-env-overrides] section
[env-override]
SPECIAL_ENV_VARS overide them here - should be seen at launch and in the runs
TESTVAR [system realpath .]
DEADVAR [system ls]

Added utils/mt_laststep version [3e6695b426].



































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/bin/bash

# Purpose: run a step, record start and end with exit codes, if sucessful
# update test status with PASS, else update with FAIL
#
# Call like this:
# mt_laststep stepname command ....
# 
# This expects that you have a logpro file named stepname.logpro and must be run
# inside a test environment (click on xterm button on a test control panel
# then source megatest.csh (if you are using tcsh) or megatest.sh (if you are using
# bash, sh or zsh)
# 
# Example: copy files
# mt_runstep copy_files cp $frompath $topath
#
# Use a copy_files.logpro file like this:
# (expect:error in "LogFileBody" = 0 "Any err/error/warn/warning" #/(err|warn)/)
# 
stepname=$1;shift

# Theoretically could call megatest directly like the following line but
# we'll do each individual step so folks can see what is going on.
#
# $MT_MEGATEST -runstep $stepname -logpro ${stepname}.logpro "$*" || exit $?

# First, register the start of this step
$MT_MEGATEST -step $stepname :state start :status n/a 

# Second, run the command (the remaining stuff on the command line after the stepname)
# We could put the results in a log file for processing but we are relying on logpro...
# $* 2>&1 ${stepname}.log

# So lets use a pipe to logpro, put the output from logpro into stepname_logpro.log
$* 2>&1| logpro ${stepname}.logpro ${stepname}.html 2>&1 ${stepname}_logpro.log 

allstatus=(${PIPESTATUS[0]} ${PIPESTATUS[1]})
runstatus=${allstatus[0]}
logprostatus=${allstatus[1]}

echo runstatus: $runstatus logprostatus: $logprostatus

# Record the step completion and exit status
$MT_MEGATEST -step $stepname :state end :status $runstatus

# If the test exits with non-zero, we will record FAIL even if logpro
# says it is a PASS

if [ $runstatus -ne 0 ]; then
    finalstatus=FAIL
elif [ $logprostatus -eq 0 ]; then
    finalstatus=PASS
elif [ $logprostatus -eq 2 ]; then
    finalstatus=WARN
else 
    finalstatus=FAIL
fi

# test ${logprostatus} -eq 0 && finalstatus="PASS"
# test ${logprostatus} -eq 1 && finalstatus="FAIL"
# test ${logprostatus} -eq 2 && finalstatus="WARN"
# test ${logprostatus} -gt 2 && finalstatus="FAIL"

# Set the final test status
$MT_MEGATEST -test-status :state COMPLETED :status $finalstatus

Added utils/mt_runstep version [35ded54591].











































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/bin/bash

# Purpose: run a step, record start and end with exit codes
#
# Call like this:
# mt_runstep stepname command ....
# 
# This expects that you have a logpro file named stepname.logpro and must be run
# inside a test environment (click on xterm button on a test control panel
# then source megatest.csh (if you are using tcsh) or megatest.sh (if you are using
# bash, sh or zsh)
# 
# Example: copy files
# mt_runstep copy_files cp $frompath $topath
#
# Use a copy_files.logpro file like this:
# (expect:error in "LogFileBody" = 0 "Any err/error/warn/warning" #/(err|warn)/)
# 
stepname=$1;shift

# Theoretically could call megatest directly like the following line but
# we'll do each individual step so folks can see what is going on.
#
# $MT_MEGATEST -runstep $stepname -logpro ${stepname}.logpro "$*" || exit $?

# First, register the start of this step
$MT_MEGATEST -step $stepname :state start :status n/a 

# Second, run the command (the remaining stuff on the command line after the stepname)
# We could put the results in a log file for processing but we are relying on logpro...
# $* 2>&1 ${stepname}.log

# So lets use a pipe to logpro, put the output from logpro into stepname_logpro.log
$* 2>&1| logpro ${stepname}.logpro ${stepname}.html 2>&1 ${stepname}_logpro.log 

# Finally, log the step completion and exit status
$MT_MEGATEST -step $stepname :state end :status ${PIPESTATUS[*]}

Modified utils/mtutils.csh from [d975762c89] to [23f4997ab4].




1
2
3
4
5
6
7



alias mt_runstep 'set argv=(\!*); \
 set stepname = $1;shift; \
 megatest -runstep $stepname -logpro ${stepname}.logpro "$*" || exit $?'

alias mt_laststep 'set argv=(\!*);set stepname = $1;shift; \
 megatest -runstep $stepname -logpro ${stepname}.logpro "$*" ; \
 set exitstatus = $? ; \
>
>
>







1
2
3
4
5
6
7
8
9
10
# Better to use the mt_* snippet scripts in utils 
#   To use the snippets set PREFIX then install with "make installall"

alias mt_runstep 'set argv=(\!*); \
 set stepname = $1;shift; \
 megatest -runstep $stepname -logpro ${stepname}.logpro "$*" || exit $?'

alias mt_laststep 'set argv=(\!*);set stepname = $1;shift; \
 megatest -runstep $stepname -logpro ${stepname}.logpro "$*" ; \
 set exitstatus = $? ; \