Commit 911317ea authored by Vitaly Ostrosablin's avatar Vitaly Ostrosablin Committed by Pavel Emelyanov

test: replace cat in Makefiles with awk

cat *.pid works when we have only one running process at any moment.
That's because pidfiles contain no newlines and cat will just
concatenate content of all files present in directory. So, e.g., if we
have pidfiles:

31338
31359
31880
31884
31889

cat will build following string from those pidfiles:

3133831359318803188431889

Obviously, kill would fail to send signals to processes, because it's
now a single big number, which cannot be unambigously split back in
general case.

That's where awk comes in. We don't need to modify C part of tests to
print newlines at end of file. We just order awk to print content of
each file, which adds a newline at end - problem solved, kill can once
again parse, which PIDs it get and send proper signals to them. Also,
should be completely safe for zdtm.py, because it doesn't use Makefiles
and sends signals on it's own.

travis-ci: success for series starting with [v2,1/2] test: replace cat in Makefiles with awk
Signed-off-by: 's avatarVitaly Ostrosablin <vostrosablin@virtuozzo.com>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 4496bdff
...@@ -365,7 +365,7 @@ start: $(PID) $(STATE) ...@@ -365,7 +365,7 @@ start: $(PID) $(STATE)
check_start: $(PID:%.pid=%.is_running) check_start: $(PID:%.pid=%.is_running)
stop: $(STATE_OUT) stop: $(STATE_OUT)
-kill -TERM `cat *.pid` -kill -TERM `awk '{print}' *.pid`
WAIT_TIME=240 WAIT_TIME=240
%.stop: %.pid % %.stop: %.pid %
...@@ -383,7 +383,7 @@ WAIT_TIME=240 ...@@ -383,7 +383,7 @@ WAIT_TIME=240
wait_stop: wait_stop:
i=0; \ i=0; \
while [ $$i -lt $(WAIT_TIME) ] ; do \ while [ $$i -lt $(WAIT_TIME) ] ; do \
kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \ kill -0 `awk '{print}' *.pid 2>/dev/null` 2>/dev/null || break; \
sleep 1; \ sleep 1; \
i=`expr $$i + 1`; \ i=`expr $$i + 1`; \
done done
......
...@@ -65,12 +65,12 @@ start: $(PID) ...@@ -65,12 +65,12 @@ start: $(PID)
check_start: $(PID:%.pid=%.is_running) check_start: $(PID:%.pid=%.is_running)
stop: stop:
-kill -TERM `cat *.pid` -kill -TERM `awk '{print}' *.pid`
WAIT_TIME=10 WAIT_TIME=10
wait_stop: wait_stop:
-for i in `seq 1 $(WAIT_TIME)`; do \ -for i in `seq 1 $(WAIT_TIME)`; do \
kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \ kill -0 `awk '{print}' *.pid 2>/dev/null` 2>/dev/null || break; \
sleep 1; \ sleep 1; \
done done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment