set self semok

proc dyninst_kfails {test} {
    # Use setup_kfail <pr number> <target triplet> for known bugs.
    #
    # (Note that tcl doesn't like comments directly inside the switch
    # statement, but comments can go in sub-blocks.)
    switch $test {
	semok/badvar.stp -
	semok/badvar_undefined.stp -
	semok/bz10475.stp -
	semok/context-globals.stp -
	semok/defined_list_vars.stp -
	semok/doubleglob.stp -
	semok/entry01.stp -
	semok/entry02.stp -
	semok/entry03.stp -
	semok/entry04.stp -
	semok/gurufunc.stp -
	semok/kretprobe-data.stp -
	semok/nodwf01.stp -
	semok/nodwf02.stp -
	semok/nodwf03.stp -
	semok/nodwf04.stp -
	semok/nodwf05.stp -
	semok/nodwf06.stp -
	semok/nodwf07.stp -
	semok/netfilter01.stp -
	semok/pretty.stp -
	semok/pretty2.stp -
	semok/seventeen.stp -
	semok/target_addr.stp -
	semok/thirteen.stp -
	semok/thirtyeight.stp -
	semok/thirtyfive.stp -
	semok/thirtyfour.stp -
	semok/thirtynine.stp -
	semok/thirtyone.stp -
	semok/thirtysix.stp -
	semok/thirtythree.stp -
	semok/thirtytwo.stp -
	semok/twelve.stp -
	semok/twentyeight.stp -
	semok/twentyfive.stp -
	semok/twentyfour.stp -
	semok/twentynine.stp -
	semok/twentyseven.stp {
	    # Use setup_kfail DYNINST <target triplet> for known
	    # failures when running with the dyninst runtime (scripts
	    # that use kernel features or kernel-only tapset
	    # functions).
	    setup_kfail DYNINST *-*-*
	}

	semok/thirtysix-utrace.stp {
	    # Use setup_kfail 14708 <target triplet> for known
	    # failures when running with the dyninst runtime (scripts
	    # that use utrace-like probes)
	    setup_kfail 14708 *-*-*
	}
    }
}

set uprobes_p [uprobes_p]
set utrace_p [utrace_p]
set plt_probes_p [plt_probes_p]
foreach runtime [get_runtime_list] {
    foreach file [lsort [glob -nocomplain $srcdir/$self/*.stp]] {
	set test $self/[file tail $file]
	if {$runtime != ""} {
	    verbose -log "Running $file ($runtime)"
	    set rc [stap_run_batch $file --runtime=$runtime]
	    if {$rc != 0} { ${runtime}_kfails $test }
	    lappend test "($runtime)"
	} else {
	    switch $test {
		semok/thirtysix-utrace.stp -
		semok/utrace01.stp {
		    # These tests need utrace
		    if {!$utrace_p} { untested $test; continue } }
		
		semok/bz11911.stp -
		semok/mangled.stp -
		semok/pretty-uprobes.stp {
		    # These tests need uprobes
		    if {!$uprobes_p} { untested $test; continue } }
		
		semok/plt1.stp -
		semok/plt2.stp {
		    if {!$plt_probes_p} { untested $test; continue } }
	    }
	    verbose -log "Running $file"
	    set rc [stap_run_batch $file]
	}
	if {$rc == 0} { pass $test } else { fail $test }
    }
}
