forked from schuellerf/xfce-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
140 lines (110 loc) · 4.98 KB
/
Makefile
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
.PHONY: build xephyr setup exec-only all manual-session
# resolution of the test X server
# TBD: define what the minimal supported resolution is
export RESOLUTION=1024x768
# use this X display number for the tests
export DISPLAY_NUM=1
# set SCREENSHOTS to ALWAYS to get screenshots during behave tests
export SCREENSHOTS=NONE
export FFMPEG_CMD=$(shell which ffmpeg || echo NO_FFMPEG)
export FFPLAY_CMD=$(shell which ffplay || echo NO_FFPLAY)
# for experimenting you might want to start with
# make manual-session
$(info Don't forget to run make build or make pull)
all: behave-tests
check_env:
if [ -z SRC_DIR ]; then echo "Please, set SRC_DIR where your sources are"; exit 1; fi
#use this to compile a git directory you have locally (even maybe modified)
compile-local: check_env xephyr
-docker run --tty --interactive \
--env DISPLAY=":$(DISPLAY_NUM)" \
--env SCREENSHOTS=$(SCREENSHOTS) \
--volume /tmp/.X11-unix:/tmp/.X11-unix --volume $(SRC_DIR):/data \
schuellerf/xfce-test:latest /bin/bash
# see compile-local
# this starts as root to be able to install stuff with apt
compile-local-root: check_env xephyr
-docker run --tty --interactive --user 0:0 \
--name xfce-test \
--env DISPLAY=":$(DISPLAY_NUM)" \
--env SCREENSHOTS=$(SCREENSHOTS) \
--volume /tmp/.X11-unix:/tmp/.X11-unix --volume $(SRC_DIR):/data \
schuellerf/xfce-test:latest /bin/bash
test: behave-tests
#only a helper for ubuntu
setup:
sudo apt install -y xserver-xephyr docker.io
sudo apt install -y xvfb ffmpeg
behave-tests: test-setup run-behave-tests test-teardown
debug: test-setup debug-behave-tests test-teardown
xephyr:
-killall -q Xephyr
Xephyr :$(DISPLAY_NUM) -ac -screen $(RESOLUTION) &
pull:
docker pull schuellerf/xfce-test
build:
docker build --build-arg DOWNLOAD_DATE=$(shell date +%Y%m%d) --tag schuellerf/xfce-test:latest .
test-setup: xephyr
-docker rm xfce-test
-docker run --name xfce-test --detach \
--env DISPLAY=":$(DISPLAY_NUM)" \
--env LDTP_DEBUG=2 \
--env SCREENSHOTS=$(SCREENSHOTS) \
--volume $(shell pwd):/data \
--volume /tmp/.X11-unix:/tmp/.X11-unix:z \
schuellerf/xfce-test:latest
test-teardown:
-docker exec xfce-test xfce4-session-logout --logout
-docker stop xfce-test
-docker rm xfce-test
-docker exec xfce-test-travis xfce4-session-logout --logout
-docker stop xfce-test-travis
-docker rm xfce-test-travis
-killall -q Xephyr
-sudo rm -rf /tmp/.X11-unix/X$(DISPLAY_NUM) /tmp/.X$(DISPLAY_NUM)-lock
manual-session: test-setup run-manual-session test-teardown
run-manual-session:
-docker exec --tty --interactive xfce-test /bin/bash
run-behave-tests:
docker exec --tty xfce-test bash -c "cd /data/behave;behave"
docker exec --tty xfce-test bash -c "cat ~xfce-test_user/version_info.txt"
debug-behave-tests:
docker exec --tty xfce-test bash -c "cd /data/behave;behave -D DEBUG_ON_ERROR"
docker exec --tty xfce-test bash -c "cat ~xfce-test_user/version_info.txt"
$(FFMPEG_CMD):
echo Please install ffmpeg
exit 1
$(FFPLAY_CMD):
echo Please install ffplay
exit 1
recording-test: $(FFMPEG_CMD) $(FFPLAY_CMD)
Xvfb :99 -ac -screen 0 800x600x24 &
docker run --name xfce-test-travis --detach --env DISPLAY=:99.0 --volume /tmp/.X11-unix:/tmp/.X11-unix schuellerf/xfce-test:latest /usr/bin/dbus-run-session /usr/bin/ldtp
sleep 5
echo "Starting testframework..." > text.txt
ifdef DEBUG
ffmpeg -y -r 30 -f x11grab -s 800x600 -i :99.0 -vf "drawtext=fontfile=Vera.ttf:textfile=text.txt:reload=1:fontcolor=white: fontsize=12: box=1: [email protected]:y=500" -c:v libx264 -f mpegts - 2>video_log | tee video.ts |ffplay - &
else
ffmpeg -y -r 30 -f x11grab -s 800x600 -i :99.0 -vf "drawtext=fontfile=Vera.ttf:textfile=text.txt:reload=1:fontcolor=white: fontsize=12: box=1: [email protected]:y=500" -c:v libx264 -f mpegts - 2>video_log > video.ts &
endif
sleep 5
docker exec --detach xfce-test-travis xfce4-session
docker cp behave xfce-test-travis:/tmp
# we need to use the mv command to avoid ffmpeg crashes
docker exec xfce-test-travis bash -c "cd /tmp/behave;behave -D DEBUG_ON_ERROR"|while read LINE; do echo "$$LINE" | tee -a text_all.txt; tail -n5 text_all.txt > text_cut.txt;mv text_cut.txt text.txt; done
-kill $$(cat /tmp/.X99-lock)
-docker stop xfce-test-travis
-docker rm xfce-test-travis
-killall -q ffmpeg ffplay
# internal function - call screenshots instead
do-screenshots:
docker exec --tty xfce-test bash -c "cd /data/behave; behave -i screenshots"
docker exec --tty xfce-test bash -c "cat ~xfce-test_user/version_info.txt"
docker exec xfce-test xfce4-session-logout --logout
screenshots: test-setup do-screenshots test-teardown
do-language-test:
mkdir -p lang-screenshots
chmod a+rwx lang-screenshots
docker exec --tty xfce-test bash -c "cd /data/lang-screenshots; /data/container_scripts/all_langs.sh"
docker exec xfce-test xfce4-session-logout --logout
language-test: test-setup do-language-test test-teardown