101 lines
2.6 KiB
Makefile
101 lines
2.6 KiB
Makefile
# Makefile - Network stack Makefile for Qemu based testing
|
|
|
|
#
|
|
# Copyright (c) 2015 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
PIPE_BASE=/tmp/ip-stack
|
|
|
|
ifeq ($(MAKECMDGOALS),server)
|
|
QEMU_NUM=server
|
|
endif
|
|
ifeq ($(MAKECMDGOALS),client)
|
|
QEMU_NUM=client
|
|
endif
|
|
ifdef QEMU_NUM
|
|
QEMU_EXTRA_FLAGS += -serial none -serial pipe:${PIPE_BASE}-${QEMU_NUM} \
|
|
-pidfile qemu-${QEMU_NUM}.pid
|
|
else
|
|
# QEMU_INSTANCE is a command line argument to make. By appending the instance
|
|
# name to the slip socket we can easily run more instances.
|
|
QEMU_EXTRA_FLAGS += -serial none -serial unix:/tmp/slip.sock$(QEMU_INSTANCE)
|
|
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 $@
|
|
LINK_CLIENT_PIPES:
|
|
ln ${PIPE_SERVER_IN} ${PIPE_CLIENT_OUT}
|
|
ln ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN}
|
|
|
|
.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
|
|
setup_pipes_dual_monitor: ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} \
|
|
${PIPE_CLIENT_IN} ${PIPE_CLIENT_OUT}
|
|
|
|
# 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
|
|
|
|
export QEMU_NUM
|
|
export QEMU_EXTRA_FLAGS
|
|
|
|
PID_FILE=/tmp/monitor_15_4.pid
|
|
NET_TOOLS ?= $(ZEPHYR_BASE)/../net-tools
|
|
|
|
hosttoolsmake = @$(MAKE) -C $(NET_TOOLS) $1
|
|
|
|
${NET_TOOLS}/monitor_15_4:
|
|
$(Q)$(call hosttoolsmake,monitor_15_4)
|
|
|
|
.PHONY: start_monitor
|
|
start_monitor: ${NET_TOOLS}/monitor_15_4
|
|
${NET_TOOLS}/monitor_15_4 \
|
|
${PCAP} \
|
|
${PIPE_BASE}-server ${PIPE_BASE}-client > /dev/null & \
|
|
echo "$$!" > ${PID_FILE}
|
|
|
|
ifeq ($(PCAP),)
|
|
server: remove_pipes setup_pipes $(DOTCONFIG)
|
|
$(Q)$(call zephyrmake,$(O),run); true
|
|
$(Q)stty sane
|
|
else
|
|
server: remove_pipes setup_pipes_dual_monitor start_monitor $(DOTCONFIG)
|
|
$(Q)$(call zephyrmake,$(O),run); true
|
|
$(Q)kill `cat ${PID_FILE}`
|
|
$(Q)rm -f ${PID_FILE}
|
|
-@killall monitor_15_4 > /dev/null 2>&1 ; true
|
|
$(Q)stty sane
|
|
endif
|
|
|
|
client: $(DOTCONFIG)
|
|
$(Q)$(call zephyrmake,$(O),run); true
|
|
$(Q)stty sane
|