]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - tests/sys/kern/execve/execve_test.sh
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / tests / sys / kern / execve / execve_test.sh
1
2 bad_interp_len_head()
3 {
4         atf_set "descr" "Bad interpreter length"
5 }
6 bad_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
12 empty_head()
13 {
14         atf_set "descr" "Empty file"
15 }
16 empty_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
22 good_aout_head()
23 {
24         atf_set "descr" "Good a.out"
25 }
26 good_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
32 good_script_head()
33 {
34         atf_set "descr" "Good script"
35 }
36 good_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
42 non_exist_head()
43 {
44         atf_set "descr" "Non-existent file"
45 }
46 non_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
52 non_exist_shell_head()
53 {
54         atf_set "descr" "Non-existent shell"
55 }
56 non_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
62 script_arg_head()
63 {
64         atf_set "descr" "-x in the shebang"
65 }
66 script_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
72 script_arg_nospace_head()
73 {
74         atf_set "descr" '-x in the shebang; no space between #! and /bin/sh'
75 }
76 script_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
82 sparse_aout_head()
83 {
84         atf_set "descr" 'Sparse file'
85 }
86 sparse_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
92 trunc_aout_head()
93 {
94         atf_set "descr" 'Truncated file'
95 }
96 trunc_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
102 atf_init_test_cases()
103 {
104         atf_add_test_case bad_interp_len
105         atf_add_test_case empty
106         atf_add_test_case good_aout
107         atf_add_test_case good_script
108         atf_add_test_case non_exist
109         atf_add_test_case non_exist_shell
110         atf_add_test_case script_arg
111         atf_add_test_case script_arg_nospace
112         atf_add_test_case sparse_aout
113         atf_add_test_case trunc_aout
114
115 }