-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_loader.sh
More file actions
executable file
·70 lines (60 loc) · 1.4 KB
/
test_loader.sh
File metadata and controls
executable file
·70 lines (60 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /bin/bash
assert() {
if ! "$@"; then
echo "Assertion failed: $@" >&2
echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]}" >&2
exit 1
fi
}
pushd build
# Unit Test
./unit_test
assert [ $? == 0 ]
# Env Test
assert [ "`./linloader ./env | wc -c`" == "8" ]
assert [ "`./linloader ./env x`" == $'2\n./env\nx' ]
# String Test
expected=`cat <<EOF
inline string
CONST_STRING const string
CONST_ZERO 0
CONST_ONE 1
data_int 1
data_string string
bss_int 0
bss_string (null)
malloc_string abcd
lib test_number_data: 12345
lib test_number_data: 54321
lib test_number_bss: 0
lib test_number_bss: 1
lib get_test_number_data: 54321
EOF
`
assert [ "`./linloader string`" == "$expected" ]
assert [ "`./linloader string_pie`" == "$expected" ]
# Dynamic Test
expected=`cat <<EOF
1st call
2nd call
16 + 16 = 32
2nd shared lib length of 'how now brown cow': 17
dynamic_var_data: 12345
dynamic_var_data: 54321
dynamic_var_bss: 0
dynamic_var_bss: 54321
get_test_number_data_internal_ref: 12345
get_test_number_data_internal_ref: 54321
malloc: ok
add_many_result: 36
EOF
`
assert [ "`./linloader ./dynamic`" == "$expected" ]
assert [ "`./linloader ./dynamic_pie`" == "$expected" ]
result=`./linloader ./tinyfetch`
assert [ $? == 0 ]
expected="Hello Tiny Wine!"
assert [ "`./linloader ./linux_static_hello_printf`" == "$expected" ]
assert [ "`./linloader ./linux_dyn_hello_printf`" == "$expected" ]
echo All tests passed
popd