]> sbz's 6dev Repos - elfdbg/.git/blob - tests/elfdbg_test.sh
Report missing binary if test suite is run w/o prior install
[elfdbg/.git] / tests / elfdbg_test.sh
1 #! /usr/bin/env atf-sh
2
3 . $(atf_get_srcdir)/test_helper.sh
4 elfdbg_path=$(which elfdbg)
5
6 atf_test_case stripped
7
8 stripped_head()
9 {
10     atf_set "descr" "ELF binary test without debug symbols"
11
12 }
13
14 stripped_body()
15 {
16     generate_bin_nodbg
17
18     [ ! -f "${elfdbg_path}" ] && atf_fail "No elfdbg binary found in '$PATH'"
19
20     out=$(${elfdbg_path} bin)
21     expected="NO DEBUG"
22     if [ "$out" == "$expected" ]; then
23         atf_pass
24     else
25         atf_fail "Wrong output w/o debug symbols '$out'"
26     fi
27 }
28
29 stripped_cleanup()
30 {
31     rm -rf bin bin.c
32 }
33
34 atf_test_case not_stripped
35
36 not_stripped_head()
37 {
38     atf_set "descr" "ELF binary test with debug symbols"
39 }
40 not_stripped_body()
41 {
42     generate_bin_dbg
43
44     [ ! -f "${elfdbg_path}" ] && atf_fail "No elfdbg binary found in '$PATH'"
45
46     out=$(${elfdbg_path} bin)
47     expected="HAS DEBUG"
48     if [ "$out" == "$expected" ]; then
49         atf_pass
50     else
51         atf_fail "Wrong output w/ debug symbols '$out'"
52     fi
53 }
54
55 not_stripped_cleanup()
56 {
57     rm -rf bin bin.c
58 }
59
60 atf_init_test_cases()
61 {
62     atf_add_test_case stripped
63     atf_add_test_case not_stripped
64 }