1 2bad_interp_len_head() 3{ 4 atf_set "descr" "Bad interpreter length" 5} 6bad_interp_len_body() 7{ 8 atf_check -s exit:1 -e 'match:No such file or directory' -o empty \ 9 -x "cd $(atf_get_srcdir) && ./execve_helper bad_interp_len" 10} 11 12empty_head() 13{ 14 atf_set "descr" "Empty file" 15} 16empty_body() 17{ 18 atf_check -s exit:1 -e 'match:Exec format error' -o empty \ 19 -x "cd $(atf_get_srcdir) && ./execve_helper empty" 20} 21 22good_aout_head() 23{ 24 atf_set "descr" "Good a.out" 25} 26good_aout_body() 27{ 28 atf_check -s exit:0 -e empty -o 'match:succeeded' \ 29 -x "cd $(atf_get_srcdir) && ./execve_helper ./good_aout" 30} 31 32good_script_head() 33{ 34 atf_set "descr" "Good script" 35} 36good_script_body() 37{ 38 atf_check -s exit:0 -e empty -o 'match:succeeded' \ 39 -x "cd $(atf_get_srcdir) && ./execve_helper good_script" 40} 41 42non_exist_head() 43{ 44 atf_set "descr" "Non-existent file" 45} 46non_exist_body() 47{ 48 atf_check -s exit:1 -e 'match:No such file or directory' -o empty \ 49 -x "cd $(atf_get_srcdir) && ./execve_helper non_exist" 50} 51 52non_exist_shell_head() 53{ 54 atf_set "descr" "Non-existent shell" 55} 56non_exist_shell_body() 57{ 58 atf_check -s exit:1 -e 'match:No such file or directory' -o empty \ 59 -x "cd $(atf_get_srcdir) && ./execve_helper non_exist_shell" 60} 61 62script_arg_head() 63{ 64 atf_set "descr" "-x in the shebang" 65} 66script_arg_body() 67{ 68 atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \ 69 -x "cd $(atf_get_srcdir) && ./execve_helper script_arg" 70} 71 72script_arg_nospace_head() 73{ 74 atf_set "descr" '-x in the shebang; no space between #! and /bin/sh' 75} 76script_arg_nospace_body() 77{ 78 atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \ 79 -x "cd $(atf_get_srcdir) && ./execve_helper script_arg_nospace" 80} 81 82sparse_aout_head() 83{ 84 atf_set "descr" 'Sparse file' 85} 86sparse_aout_body() 87{ 88 atf_check -s exit:1 -e 'match:Exec format error' -o empty \ 89 -x "cd $(atf_get_srcdir) && ./execve_helper sparse_aout" 90} 91 92trunc_aout_head() 93{ 94 atf_set "descr" 'Truncated file' 95} 96trunc_aout_body() 97{ 98 atf_check -s exit:1 -e 'match:Exec format error' -o empty \ 99 -x "cd $(atf_get_srcdir) && ./execve_helper trunc_aout" 100} 101 102empty_args_head() 103{ 104 atf_set "descr" "Empty argv behavior" 105} 106empty_args_body() 107{ 108 atf_check -o inline:"1\n" \ 109 -x "cd $(atf_get_srcdir) && ./execve_helper execve_argc_helper" 110 111 # Historically we allowed argc == 0, while execve(2) claimed we didn't. 112 # execve() should kick back an EINVAL now. We verified the helper was 113 # there/working in the check just above. 114 atf_check -s exit:1 \ 115 -e match:".+Invalid argument$" \ 116 -x "cd $(atf_get_srcdir) && ./execve_helper -n execve_argc_helper" 117} 118 119atf_init_test_cases() 120{ 121 atf_add_test_case bad_interp_len 122 atf_add_test_case empty 123 atf_add_test_case good_aout 124 atf_add_test_case good_script 125 atf_add_test_case non_exist 126 atf_add_test_case non_exist_shell 127 atf_add_test_case script_arg 128 atf_add_test_case script_arg_nospace 129 atf_add_test_case sparse_aout 130 atf_add_test_case trunc_aout 131 atf_add_test_case empty_args 132 133} 134