# PR 2142+2610

set test "absentstats"
set script $srcdir/$subdir/$test.stp

if {![installtest_p]} { untested $test; return }

foreach runtime [get_runtime_list] {
    set ok 0
    set ko 0

    set testname $test
    if {$runtime != ""} {
	spawn stap -DMAXERRORS=20 --runtime=$runtime $script
	lappend testname "($runtime)"
    } else {
	spawn stap -DMAXERRORS=20 $script
    }    
    expect {
	-timeout 150
	-re {^ERROR: empty aggregate[^\r]*\r} { incr ko ; exp_continue }
	-re {^WARNING: Number of errors} { incr ko ; exp_continue }
	-re {^0\r} { incr ok ; exp_continue }
	-re {\n} { exp_continue }
	eof { }
    }
    catch close
    wait
    
    # As of stap 1.5, @count and @sum are allowed, the rest fail
    if {$ok == 4 && $ko == 13} {
	pass $testname
    } else {
	fail "$testname ($ok $ko)"
    }
    
    set ok 0
    set ko 0
    
    if {$runtime != ""} {
	spawn stap -DMAXERRORS=20 --runtime=$runtime $script --compatible=1.4
    } else {
	spawn stap -DMAXERRORS=20 $script --compatible=1.4
    }    
    expect {
	-timeout 150
	-re {^ERROR: empty aggregate[^\r]*\r} { incr ko ; exp_continue }
	-re {^WARNING: Number of errors} { incr ko ; exp_continue }
	-re {^0\r} { incr ok ; exp_continue }
	-re {\n} { exp_continue }
	eof { }
    }
    catch close
    wait
    
    # In stap <= 1.4, only @count is allowed, the rest fail
    if {$ok == 2 && $ko == 15} {
	pass "$testname 1.4"
    } else {
	fail "$testname 1.4 ($ok $ko)"
    }
}
