assert_spec linux set tshark [installed_command tshark] set trafgen [installed_command trafgen] set lx_fs_root "internet_checksum_dir" set lx_fs_dir "bin/$lx_fs_root" set input_file_name "input.pcap" set input_file "bin/$input_file_name" rename exit run_tool_exit proc exit {{code 0}} { global lx_fs_dir global input_file if {[get_cmd_switch --autopilot]} { exec rm -rf $input_file $lx_fs_dir } run_tool_exit $code } build { core init lib/ld lib/vfs test/internet_checksum server/lx_fs } create_boot_directory proc gen_seed { } { set min_seed 0 set max_seed [expr 2**32] return [expr int($min_seed + floor(rand() * $max_seed))] } set seed 0 if {[info exists ::env(SEED)]} { set seed $::env(SEED) } else { # in some cases trafgen generates bad checksums in encapsulated packets set bad_seeds [list 0 875727356 ] while {[lsearch -exact $bad_seeds $seed] != -1} { set seed [gen_seed] } } puts "\nUse script with SEED=$seed in order to get reproducible results\n" install_config { } exec rm -rf $lx_fs_dir exec mkdir -p $lx_fs_dir exec $trafgen --rand --seed $seed --in [genode_dir]/repos/os/src/test/internet_checksum/trafgen.cfg --num 10000 --out $input_file proc assert_no_bad_checksums_in {pcap_file} { global tshark set view_filter "ip.checksum_bad.expert || tcp.checksum_bad.expert || udp.checksum.bad || icmp.checksum_bad" set out "" set out [exec $tshark -o ip.check_checksum:TRUE -o tcp.check_checksum:TRUE -o udp.check_checksum:TRUE -Y "$view_filter" -r $pcap_file] if {$out != ""} { puts "\nError: bad checksums found in $pcap_file\n" exit -1 } } assert_no_bad_checksums_in $input_file build_boot_image [list {*}[build_artifacts] $lx_fs_root $input_file_name] append qemu_args " -nographic " run_genode_until {\[init\] child "test-internet_checksum" exited.*?\n} 30 set output_file "$lx_fs_dir/output.pcap" assert_no_bad_checksums_in $output_file set num_checked_checksums "" set string_buf "" regexp {checked [0-9]+ checksums} $output string_buf regexp {[0-9]+} $string_buf num_checked_checksums set tmp_file "$lx_fs_dir/tmp" exec $tshark -o ip.check_checksum:TRUE -o tcp.check_checksum:TRUE -o udp.check_checksum:TRUE -O ip,tcp,udp,icmp -r $output_file | grep -e "Checksum Status:" -e "Header checksum status:" > $tmp_file set num_output_checksums [exec wc -l < $tmp_file] if {$num_checked_checksums != $num_output_checksums} { puts "\nError: number of checksums in $output_file ($num_output_checksums) differs from number of checked checksums ($num_checked_checksums)\n" exit -1 } grep_output {\[init\] child "test-internet_checksum" exited} compare_output_to {[init] child "test-internet_checksum" exited with exit value 0}