Path: blob/main/tests/sys/kern/execve/execve_test.sh
39488 views
1bad_interp_len_head()2{3atf_set "descr" "Bad interpreter length"4}5bad_interp_len_body()6{7atf_check -s exit:1 -e 'match:No such file or directory' -o empty \8-x "cd $(atf_get_srcdir) && ./execve_helper bad_interp_len"9}1011empty_head()12{13atf_set "descr" "Empty file"14}15empty_body()16{17atf_check -s exit:1 -e 'match:Exec format error' -o empty \18-x "cd $(atf_get_srcdir) && ./execve_helper empty"19}2021good_aout_head()22{23atf_set "descr" "Good a.out"24}25good_aout_body()26{27atf_check -s exit:0 -e empty -o 'match:succeeded' \28-x "cd $(atf_get_srcdir) && ./execve_helper ./good_aout"29}3031good_script_head()32{33atf_set "descr" "Good script"34}35good_script_body()36{37atf_check -s exit:0 -e empty -o 'match:succeeded' \38-x "cd $(atf_get_srcdir) && ./execve_helper good_script"39}4041non_exist_head()42{43atf_set "descr" "Non-existent file"44}45non_exist_body()46{47atf_check -s exit:1 -e 'match:No such file or directory' -o empty \48-x "cd $(atf_get_srcdir) && ./execve_helper non_exist"49}5051non_exist_shell_head()52{53atf_set "descr" "Non-existent shell"54}55non_exist_shell_body()56{57atf_check -s exit:1 -e 'match:No such file or directory' -o empty \58-x "cd $(atf_get_srcdir) && ./execve_helper non_exist_shell"59}6061script_arg_head()62{63atf_set "descr" "-x in the shebang"64}65script_arg_body()66{67atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \68-x "cd $(atf_get_srcdir) && ./execve_helper script_arg"69}7071script_arg_nospace_head()72{73atf_set "descr" '-x in the shebang; no space between #! and /bin/sh'74}75script_arg_nospace_body()76{77atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \78-x "cd $(atf_get_srcdir) && ./execve_helper script_arg_nospace"79}8081sparse_aout_head()82{83atf_set "descr" 'Sparse file'84}85sparse_aout_body()86{87atf_check -s exit:1 -e 'match:Exec format error' -o empty \88-x "cd $(atf_get_srcdir) && ./execve_helper sparse_aout"89}9091trunc_aout_head()92{93atf_set "descr" 'Truncated file'94}95trunc_aout_body()96{97atf_check -s exit:1 -e 'match:Exec format error' -o empty \98-x "cd $(atf_get_srcdir) && ./execve_helper trunc_aout"99}100101empty_args_head()102{103atf_set "descr" "Empty argv behavior"104}105empty_args_body()106{107atf_check -o inline:"1\n" \108-x "cd $(atf_get_srcdir) && ./execve_helper execve_argc_helper"109110# Historically we allowed argc == 0, while execve(2) claimed we didn't.111# execve() should kick back an EINVAL now. We verified the helper was112# there/working in the check just above.113atf_check -s exit:1 \114-e match:".+Invalid argument$" \115-x "cd $(atf_get_srcdir) && ./execve_helper -n execve_argc_helper"116}117118atf_init_test_cases()119{120atf_add_test_case bad_interp_len121atf_add_test_case empty122atf_add_test_case good_aout123atf_add_test_case good_script124atf_add_test_case non_exist125atf_add_test_case non_exist_shell126atf_add_test_case script_arg127atf_add_test_case script_arg_nospace128atf_add_test_case sparse_aout129atf_add_test_case trunc_aout130atf_add_test_case empty_args131132}133134135