1159097Smaxim
2281464Sngiebad_interp_len_head()
3281464Sngie{
4281464Sngie	atf_set "descr" "Bad interpreter length"
5281464Sngie}
6281464Sngiebad_interp_len_body()
7281464Sngie{
8281464Sngie	atf_check -s exit:1 -e 'match:No such file or directory' -o empty \
9281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper bad_interp_len"
10281464Sngie}
11159097Smaxim
12281464Sngieempty_head()
13281464Sngie{
14281464Sngie	atf_set "descr" "Empty file"
15281464Sngie}
16281464Sngieempty_body()
17281464Sngie{
18281464Sngie	atf_check -s exit:1 -e 'match:Exec format error' -o empty \
19281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper empty"
20281464Sngie}
21159097Smaxim
22281464Sngiegood_aout_head()
23281464Sngie{
24281464Sngie	atf_set "descr" "Good a.out"
25281464Sngie}
26281464Sngiegood_aout_body()
27281464Sngie{
28281464Sngie	atf_check -s exit:0 -e empty -o 'match:succeeded' \
29281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper ./good_aout"
30281464Sngie}
31159097Smaxim
32281464Sngiegood_script_head()
33281464Sngie{
34281464Sngie	atf_set "descr" "Good script"
35281464Sngie}
36281464Sngiegood_script_body()
37281464Sngie{
38281464Sngie	atf_check -s exit:0 -e empty -o 'match:succeeded' \
39281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper good_script"
40281464Sngie}
41159097Smaxim
42281464Sngienon_exist_head()
43281464Sngie{
44281464Sngie	atf_set "descr" "Non-existent file"
45281464Sngie}
46281464Sngienon_exist_body()
47281464Sngie{
48281464Sngie	atf_check -s exit:1 -e 'match:No such file or directory' -o empty \
49281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper non_exist"
50281464Sngie}
51159097Smaxim
52281464Sngienon_exist_shell_head()
53281464Sngie{
54281464Sngie	atf_set "descr" "Non-existent shell"
55281464Sngie}
56281464Sngienon_exist_shell_body()
57281464Sngie{
58281464Sngie	atf_check -s exit:1 -e 'match:No such file or directory' -o empty \
59281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper non_exist_shell"
60281464Sngie}
61281464Sngie
62281464Sngiescript_arg_head()
63281464Sngie{
64281464Sngie	atf_set "descr" "-x in the shebang"
65281464Sngie}
66281464Sngiescript_arg_body()
67281464Sngie{
68281464Sngie	atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \
69281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper script_arg"
70281464Sngie}
71281464Sngie
72281464Sngiescript_arg_nospace_head()
73281464Sngie{
74281464Sngie	atf_set "descr" '-x in the shebang; no space between #! and /bin/sh'
75281464Sngie}
76281464Sngiescript_arg_nospace_body()
77281464Sngie{
78281464Sngie	atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \
79281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper script_arg_nospace"
80281464Sngie}
81281464Sngie
82281464Sngiesparse_aout_head()
83281464Sngie{
84281464Sngie	atf_set "descr" 'Sparse file'
85281464Sngie}
86281464Sngiesparse_aout_body()
87281464Sngie{
88281464Sngie	atf_check -s exit:1 -e 'match:Exec format error' -o empty \
89281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper sparse_aout"
90281464Sngie}
91281464Sngie
92281464Sngietrunc_aout_head()
93281464Sngie{
94281464Sngie	atf_set "descr" 'Truncated file'
95281464Sngie}
96281464Sngietrunc_aout_body()
97281464Sngie{
98281464Sngie	atf_check -s exit:1 -e 'match:Exec format error' -o empty \
99281464Sngie	    -x "cd $(atf_get_srcdir) && ./execve_helper trunc_aout"
100281464Sngie}
101281464Sngie
102281464Sngieatf_init_test_cases()
103281464Sngie{
104281464Sngie	atf_add_test_case bad_interp_len
105281464Sngie	atf_add_test_case empty
106281464Sngie	atf_add_test_case good_aout
107281464Sngie	atf_add_test_case good_script
108281464Sngie	atf_add_test_case non_exist
109281464Sngie	atf_add_test_case non_exist_shell
110281464Sngie	atf_add_test_case script_arg
111281464Sngie	atf_add_test_case script_arg_nospace
112281464Sngie	atf_add_test_case sparse_aout
113281464Sngie	atf_add_test_case trunc_aout
114281464Sngie
115281464Sngie}
116