2016-08-18 17:45:29 +08:00
|
|
|
# Makefile - Network stack Makefile for Qemu based testing
|
2015-09-25 21:44:12 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright (c) 2015 Intel Corporation
|
|
|
|
#
|
2017-01-19 09:01:01 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2015-09-25 21:44:12 +08:00
|
|
|
#
|
|
|
|
|
|
|
|
PIPE_BASE=/tmp/ip-stack
|
|
|
|
|
|
|
|
ifeq ($(MAKECMDGOALS),server)
|
|
|
|
QEMU_NUM=server
|
|
|
|
endif
|
|
|
|
ifeq ($(MAKECMDGOALS),client)
|
|
|
|
QEMU_NUM=client
|
|
|
|
endif
|
|
|
|
ifdef QEMU_NUM
|
2016-08-18 17:45:29 +08:00
|
|
|
QEMU_EXTRA_FLAGS += -serial none -serial pipe:${PIPE_BASE}-${QEMU_NUM} \
|
|
|
|
-pidfile qemu-${QEMU_NUM}.pid
|
2015-09-25 21:44:12 +08:00
|
|
|
else
|
2016-11-23 18:56:42 +08:00
|
|
|
QEMU_EXTRA_FLAGS += -serial none -serial unix:/tmp/slip.sock
|
2015-09-25 21:44:12 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
PIPE_SERVER_IN=${PIPE_BASE}-server.in
|
|
|
|
PIPE_SERVER_OUT=${PIPE_BASE}-server.out
|
|
|
|
PIPE_CLIENT_IN=${PIPE_BASE}-client.in
|
|
|
|
PIPE_CLIENT_OUT=${PIPE_BASE}-client.out
|
|
|
|
|
|
|
|
.PHONY: remove_pipes
|
|
|
|
remove_pipes:
|
|
|
|
rm -f ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN} \
|
|
|
|
${PIPE_CLIENT_OUT}
|
|
|
|
|
|
|
|
${PIPE_SERVER_IN}:
|
|
|
|
mkfifo $@
|
|
|
|
${PIPE_SERVER_OUT}:
|
|
|
|
mkfifo $@
|
|
|
|
${PIPE_CLIENT_IN}:
|
|
|
|
mkfifo $@
|
|
|
|
${PIPE_CLIENT_OUT}:
|
|
|
|
mkfifo $@
|
2016-03-09 00:35:03 +08:00
|
|
|
LINK_CLIENT_PIPES:
|
|
|
|
ln ${PIPE_SERVER_IN} ${PIPE_CLIENT_OUT}
|
|
|
|
ln ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN}
|
2015-09-25 21:44:12 +08:00
|
|
|
|
|
|
|
.PHONY: PIPE_CLIENT_IN_LINK
|
|
|
|
PIPE_CLIENT_IN_LINK: ${PIPE_SERVER_IN}
|
|
|
|
-ln ${PIPE_SERVER_IN} ${PIPE_CLIENT_OUT}
|
|
|
|
|
|
|
|
.PHONY: PIPE_CLIENT_OUT_LINK
|
|
|
|
PIPE_CLIENT_OUT_LINK: ${PIPE_SERVER_OUT}
|
|
|
|
-ln ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN}
|
|
|
|
|
|
|
|
# Setup the dual qemu test case with pcap support (two qemus passing data
|
|
|
|
# between them and saving data to pcap via help of monitor applicaiton)
|
|
|
|
.PHONY: setup_pipes_dual_monitor
|
2016-08-18 17:45:29 +08:00
|
|
|
setup_pipes_dual_monitor: ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} \
|
|
|
|
${PIPE_CLIENT_IN} ${PIPE_CLIENT_OUT}
|
2015-09-25 21:44:12 +08:00
|
|
|
|
2016-03-09 00:35:03 +08:00
|
|
|
# Setup the dual qemu test case with (two qemus passing data
|
|
|
|
# between them)
|
|
|
|
.PHONY: setup_pipes
|
|
|
|
setup_pipes: ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} LINK_CLIENT_PIPES
|
|
|
|
|
2015-09-25 21:44:12 +08:00
|
|
|
export QEMU_NUM
|
|
|
|
export QEMU_EXTRA_FLAGS
|
|
|
|
|
|
|
|
PID_FILE=/tmp/monitor_15_4.pid
|
|
|
|
|
2016-08-18 17:45:29 +08:00
|
|
|
hosttoolsmake = @$(MAKE) -C $(ZEPHYR_BASE)/net/tools $1
|
2015-09-25 21:44:12 +08:00
|
|
|
|
2016-08-18 17:45:29 +08:00
|
|
|
${ZEPHYR_BASE}/net/tools/monitor_15_4:
|
2015-09-25 21:44:12 +08:00
|
|
|
$(Q)$(call hosttoolsmake,monitor_15_4)
|
|
|
|
|
|
|
|
.PHONY: start_monitor
|
2016-08-18 17:45:29 +08:00
|
|
|
start_monitor: ${ZEPHYR_BASE}/net/tools/monitor_15_4
|
|
|
|
${ZEPHYR_BASE}/net/tools/monitor_15_4 \
|
2016-03-16 19:47:24 +08:00
|
|
|
${PCAP} \
|
2015-09-25 21:44:12 +08:00
|
|
|
${PIPE_BASE}-server ${PIPE_BASE}-client > /dev/null & \
|
|
|
|
echo "$$!" > ${PID_FILE}
|
|
|
|
|
2016-03-16 19:47:24 +08:00
|
|
|
ifeq ($(PCAP),)
|
2016-03-09 00:35:03 +08:00
|
|
|
server: remove_pipes setup_pipes $(DOTCONFIG)
|
2015-09-25 21:44:12 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),qemu); true
|
|
|
|
$(Q)stty sane
|
2016-03-16 19:47:24 +08:00
|
|
|
else
|
|
|
|
server: remove_pipes setup_pipes_dual_monitor start_monitor $(DOTCONFIG)
|
|
|
|
$(Q)$(call zephyrmake,$(O),qemu); true
|
|
|
|
$(Q)kill `cat ${PID_FILE}`
|
|
|
|
$(Q)rm -f ${PID_FILE}
|
|
|
|
-@killall monitor_15_4 > /dev/null 2>&1 ; true
|
|
|
|
$(Q)stty sane
|
|
|
|
endif
|
2015-09-25 21:44:12 +08:00
|
|
|
|
2016-03-09 00:35:03 +08:00
|
|
|
client: $(DOTCONFIG)
|
2015-09-25 21:44:12 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),qemu); true
|
|
|
|
$(Q)stty sane
|