-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer_tools.sh
91 lines (71 loc) · 2.79 KB
/
installer_tools.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /bin/bash
# Filesystem function tests
#
# Author: DonTseTse
############# Configuration
test_root_path="/tmp"
############# Preparation
# Refuse symlinks and get the absolute path of the commons directory (this file lies in ./tests/.), load dependancies
set -e
[ -h "${BASH_SOURCE[0]}" ] && echo "Error: called through symlink. Please call directly. Aborting..." && exit 1
commons_path="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && dirname "$(pwd)")"
. "$commons_path/testing.sh"
. "$commons_path/installer_tools.sh"
set +e
initialize_test_session "installer_tools.sh functions"
[ "$UID" -ne 0 ] && echo "Please run as root. Aborting..." && exit 1
echo "*** get_executable_status() ***"
ln -s "/tmp/exec_test" "/usr/bin/exec_test"
echo " - \$> ln -s \"/tmp/exec_test\" \"/usr/bin/exec_test\""
configure_test 3 "/usr/bin/exec_test"
test get_executable_status "exec_test" 1
touch "/tmp/exec_test"
echo " - \$> touch \"/tmp/exec_test\""
configure_test 1 "/tmp/exec_test"
test get_executable_status "exec_test" 1
chmod +x "/tmp/exec_test"
echo " - \$> chmod +x \"/tmp/exec_test\""
configure_test 0 ""
test get_executable_status "exec_test"
configure_test 2 ""
test get_executable_status "unexistant"
configure_test 5 ""
test get_executable_status
rm "/usr/bin/exec_test" "/tmp/exec_test"
echo " - \$> rm \"/usr/bin/exec_test\" \"/tmp/exec_test\""
echo "*** handle_dependency() ***"
configure_test 5 ""
test handle_dependency "exec_test"
ln -s "/tmp/exec_test" "/usr/bin/exec_test"
echo " - \$> ln -s \"/tmp/exec_test\" \"/usr/bin/exec_test\""
configure_test 7 ""
test handle_dependency "exec_test"
touch "/tmp/exec_test"
echo " - \$> touch \"/tmp/exec_test\""
configure_test 2 ""
test handle_dependency "exec_test"
configure_test 1 "exec_test (/usr/bin/exec_test) already installed"
test handle_dependency "exec_test" 1
msg_defs=([1]=" - %command already installed, found under %path")
configure_test 1 " - exec_test already installed, found under /usr/bin/exec_test"
test handle_dependency "exec_test" "msg_defs"
rm "/tmp/exec_test" "/usr/bin/exec_test"
echo " - \$> rm \"/tmp/exec_test\" \"/usr/bin/exec_test\""
function handle_dependency_installation()
{
echo "I'm the installer for $1"
}
echo "Defined function handle_dependency_installation() which prints the message \"I'm the installer for \$1\""
configure_test 0 "I'm the installer for exec_test"
test handle_dependency "exec_test"
configure_test 9 ""
test handle_dependency
configure_test 0 " - sed (/bin/sed) already installed
- echo (/bin/echo) already installed"
test handle_dependencies "sed echo" 1 " - %s\n"
# reset_package_lists() can't be tested because it contains a capture, test() also
#configure_test 0 ""
#test reset_package_lists
#echo "out: $stdout err: $stderr"
[ -d "/tmp/sendmail2mailgun" ] && rm -r "/tmp/sendmail2mailgun"
conclude_test_session