mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-04 04:54:12 +00:00
162 lines
4.0 KiB
Plaintext
162 lines
4.0 KiB
Plaintext
|
#
|
||
|
# Build
|
||
|
#
|
||
|
|
||
|
build "core init drivers/timer test/cpu_quota"
|
||
|
|
||
|
#
|
||
|
# Boot image
|
||
|
#
|
||
|
|
||
|
create_boot_directory
|
||
|
|
||
|
install_config {
|
||
|
<config prio_levels="4">
|
||
|
<parent-provides>
|
||
|
<service name="ROM"/>
|
||
|
<service name="RAM"/>
|
||
|
<service name="IRQ"/>
|
||
|
<service name="IO_MEM"/>
|
||
|
<service name="CAP"/>
|
||
|
<service name="PD"/>
|
||
|
<service name="RM"/>
|
||
|
<service name="CPU"/>
|
||
|
<service name="LOG"/>
|
||
|
<service name="SIGNAL"/>
|
||
|
</parent-provides>
|
||
|
<default-route>
|
||
|
<any-service><parent/><any-child/></any-service>
|
||
|
</default-route>
|
||
|
|
||
|
<start name="timer">
|
||
|
<resource name="RAM" quantum="10M"/>
|
||
|
<provides><service name="Timer"/></provides>
|
||
|
</start>
|
||
|
|
||
|
<start name="init_1" priority="-1">
|
||
|
<binary name="init"/>
|
||
|
<resource name="RAM" quantum="10M"/>
|
||
|
<resource name="CPU" quantum="10"/>
|
||
|
<config prio_levels="2">
|
||
|
<parent-provides>
|
||
|
<service name="ROM"/>
|
||
|
<service name="RAM"/>
|
||
|
<service name="IRQ"/>
|
||
|
<service name="IO_MEM"/>
|
||
|
<service name="CAP"/>
|
||
|
<service name="PD"/>
|
||
|
<service name="RM"/>
|
||
|
<service name="CPU"/>
|
||
|
<service name="LOG"/>
|
||
|
<service name="SIGNAL"/>
|
||
|
<service name="Timer"/>
|
||
|
</parent-provides>
|
||
|
<default-route>
|
||
|
<any-service><parent/><any-child/></any-service>
|
||
|
</default-route>
|
||
|
|
||
|
<!-- should receive 10 % of the CPU time -->
|
||
|
<start name="test_slow" priority="-1">
|
||
|
<binary name="test-cpu_quota"/>
|
||
|
<resource name="RAM" quantum="10M"/>
|
||
|
<resource name="CPU" quantum="50"/>
|
||
|
</start>
|
||
|
|
||
|
</config>
|
||
|
</start>
|
||
|
|
||
|
<start name="init_2" priority="-2">
|
||
|
<binary name="init"/>
|
||
|
<resource name="RAM" quantum="100M"/>
|
||
|
<resource name="CPU" quantum="80"/>
|
||
|
<config>
|
||
|
<parent-provides>
|
||
|
<service name="ROM"/>
|
||
|
<service name="RAM"/>
|
||
|
<service name="CPU"/>
|
||
|
<service name="RM"/>
|
||
|
<service name="CAP"/>
|
||
|
<service name="PD"/>
|
||
|
<service name="LOG"/>
|
||
|
<service name="SIGNAL"/>
|
||
|
<service name="Timer"/>
|
||
|
</parent-provides>
|
||
|
<default-route>
|
||
|
<any-service><parent/></any-service>
|
||
|
</default-route>
|
||
|
|
||
|
<!-- should receive 25 % of the CPU time -->
|
||
|
<start name="test_middle">
|
||
|
<binary name="test-cpu_quota"/>
|
||
|
<resource name="RAM" quantum="10M"/>
|
||
|
<resource name="CPU" quantum="25"/>
|
||
|
</start>
|
||
|
|
||
|
<!-- should receive 65 % of the CPU time -->
|
||
|
<start name="test_fast">
|
||
|
<binary name="test-cpu_quota"/>
|
||
|
<resource name="RAM" quantum="10M"/>
|
||
|
<resource name="CPU" quantum="75"/>
|
||
|
</start>
|
||
|
|
||
|
</config>
|
||
|
</start>
|
||
|
</config>
|
||
|
}
|
||
|
|
||
|
build_boot_image "core init timer test-cpu_quota"
|
||
|
|
||
|
#
|
||
|
# Execution
|
||
|
#
|
||
|
|
||
|
append qemu_args "-nographic -m 64"
|
||
|
|
||
|
run_genode_until "test.*\n.*test.*\n.*test.*\n" 60
|
||
|
|
||
|
#
|
||
|
# Conclusion
|
||
|
#
|
||
|
|
||
|
set slow_opt 0.10
|
||
|
set middle_opt 0.25
|
||
|
set fast_opt 0.65
|
||
|
set err 0.02
|
||
|
|
||
|
regexp {[0-9]+} [regexp -inline {slow.*[0-9]+} $output] slow_cnt
|
||
|
regexp {[0-9]+} [regexp -inline {middle.*[0-9]+} $output] middle_cnt
|
||
|
regexp {[0-9]+} [regexp -inline {fast.*[0-9]+} $output] fast_cnt
|
||
|
set total_cnt [expr $fast_cnt + $middle_cnt + $slow_cnt]
|
||
|
|
||
|
set slow_fac [expr $slow_cnt / double($total_cnt) ]
|
||
|
set middle_fac [expr $middle_cnt / double($total_cnt) ]
|
||
|
set fast_fac [expr $fast_cnt / double($total_cnt) ]
|
||
|
|
||
|
set failed 0
|
||
|
if {[expr $slow_fac > $slow_opt + $err || $slow_fac < $slow_opt - $err]} {
|
||
|
set is_pc [expr round($slow_fac * 10000) / 100]
|
||
|
set opt_pc [expr round($slow_opt * 10000) / 100]
|
||
|
puts stderr "Error: Slow counter received $is_pc% of the CPU time."
|
||
|
puts stderr " Should receive $opt_pc%."
|
||
|
set failed 1
|
||
|
}
|
||
|
if {[expr $middle_fac > $middle_opt + $err || $middle_fac < $middle_opt - $err]} {
|
||
|
set is_pc [expr round($middle_fac * 10000) / 100]
|
||
|
set opt_pc [expr round($middle_opt * 10000) / 100]
|
||
|
puts stderr "Error: Middle counter received $is_pc% of the CPU time."
|
||
|
puts stderr " Should receive $opt_pc%."
|
||
|
set failed 1
|
||
|
}
|
||
|
if {[expr $fast_fac > $fast_opt + $err || $fast_fac < $fast_opt - $err]} {
|
||
|
set is_pc [expr round($fast_fac * 10000) / 100]
|
||
|
set opt_pc [expr round($fast_opt * 10000) / 100]
|
||
|
puts stderr "Error: Fast counter received $is_pc% of the CPU time."
|
||
|
puts stderr " Should receive $opt_pc%."
|
||
|
set failed 1
|
||
|
}
|
||
|
if {$failed} {
|
||
|
exit -1
|
||
|
} else {
|
||
|
puts "Test succeeded"
|
||
|
}
|