-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntest.sh
88 lines (78 loc) · 2.04 KB
/
runtest.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
#!/bin/bash
# Copyright (c) 2017-2021, Virtuozzo International GmbH
#
# Our contact details: Virtuozzo International GmbH, Vordergasse 59, 8200
# Schaffhausen, Switzerland.
usage() {
[ $# == 1 ] && echo -e "$1"
cat <<EOT
usage:
$0 [service] [package] [distro-release]
$0 [apps] [package] [distro-release]
$0 [add user $(whoami) to docker group]
$0 [example: sh runtest.sh apps firefox vl7] or [sh runtest.sh service realmd vl7] or [sh runtest.sh binapps vim-enhanced vl7]
EOT
}
# package to check
PKG="$2"
IRUN="$1"
DISTRO_RELEASE="$3"
check_in_list() {
if [[ "$IRUN" == "apps" ]]; then
FILE_PREFIX="desktop"
fi
if [[ "$IRUN" == "service" ]]; then
FILE_PREFIX="service"
fi
PATTERN="$PKG"
FILE=""$FILE_PREFIX"-"$DISTRO_RELEASE".list"
if grep -q $PATTERN $FILE;
then
echo "Here are the Strings with the Pattern '$PATTERN':"
echo "proceed normal test"
else
echo "Error: The Pattern '$PATTERN' was NOT Found in '$FILE'"
echo "Exiting..."
exit 0
fi
}
run_service() {
echo "check that service exist in service-vl7.list"
check_in_list
# need to run container with systemd-stuff
docker run --privileged -td --name servicetest -v /tmp/results:/tmp/results/ vzlinux/servicetest /sbin/init
# attach to container and exec script
docker exec -it servicetest /run-service.sh "$PKG"
# stop docker container before destroying
docker stop servicetest
# wipe used docker container, we always need clean environment
docker rm -v $(docker ps -a -q -f status=exited)
}
run_apps() {
# run app check
echo "compare app with list desktop-vl7.list"
check_in_list
docker run -it --rm --privileged=true -e PKG="$PKG" -v /tmp/results:/tmp/results/ vzlinux/apptest
}
run_binapps() {
# run app check
echo "test app not from *desktop lists files"
docker run -it --rm --privileged=true -e PKG="$PKG" -v /tmp/results:/tmp/results/ vzlinux/binapps
}
main() {
if [[ "$1" == "service" ]]; then
run_service $@
fi
if [[ "$1" == "apps" ]]; then
run_apps $@
fi
if [[ "$1" == "binapps" ]]; then
run_binapps $@
fi
# help
if [ "$1" == "-h" ]; then
usage
exit 0
fi
}
main "$@"