okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6ca60e9a0
main
1// pick_window_victim (include/strata/core/window_evict.hpp): CPU only (#3702). 2#include "strata/core/window_evict.hpp" 3 4#include <cstdio> 5#include <cstdlib> 6 7using strata::core::pick_window_victim ; 8 9namespace { 10int checks = 0 ; 11void check (bool ok ,const char * label ) { 12++ checks ; 13if (!ok ) { std::fprintf (stderr ,"FAIL: %s\n" ,label ); std::exit (1 ); } 14} 15}// namespace 16 17int main () { 18bool have [9 ]= {}; 19check (pick_window_victim (have ,8 ,5 ,0 )== 0 ,"nothing captured: nothing to free" ); 20have [2 ]= have [3 ]= have [5 ]= true; 21check (pick_window_victim (have ,8 ,6 ,0 )== 5 ,"the largest captured size goes first" ); 22check (pick_window_victim (have ,8 ,5 ,0 )== 3 ,"never the size being captured" ); 23check (pick_window_victim (have ,8 ,5 ,3 )== 2 ,"never the prelaunched size" ); 24check (pick_window_victim (have ,4 ,1 ,0 )== 3 ,"sizes above max_t are not considered" ); 25have [5 ]= false; 26check (pick_window_victim (have ,8 ,3 ,2 )== 0 ,"only the kept and the pinned sizes are left: nothing" ); 27have [2 ]= have [3 ]= false; 28have [1 ]= true; 29check (pick_window_victim (have ,8 ,7 ,0 )== 1 ,"size 1 can be freed" ); 30check (pick_window_victim (have ,8 ,1 ,0 )== 0 ,"size 1 kept" ); 31 std::printf ("window_evict_test: %d checks passed\n" ,checks ); 32return 0 ; 33}