Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topotato: Added command for selftest #114

Open
wants to merge 2 commits into
base: topotato-base
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 50 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,64 @@
v := vagrant
vu := $(v) up
vh := $(v) halt
vr := $(v) reload
vs := $(v) ssh
vsc := $(vs) -c
t := ./run_userns.sh --frr-builddir=/home/vagrant/frr --log-cli-level=DEBUG -v -v -x
cwd := cd /home/vagrant/dev/topotato
build:
VAGRANT_STATUS := $(shell vagrant status --machine-readable | awk -F',' '{ print $$4 }')
v := vagrant
vu := $(v) up
vh := $(v) halt
vr := $(v) reload
vs := $(v) ssh
vsc := $(vs) -c
t := ./run_userns.sh --frr-builddir=$(FRR_BUILD_PATH) --log-cli-level=DEBUG -v -v -x
st := python -m pytest
cwd := cd /home/vagrant/dev/topotato
FRR_BUILD_PATH := /home/vagrant/frr

ifeq ($(VAGRANT_STATUS),running)
ENVIRONMENT := vagrant
else
ENVIRONMENT := host
FRR_BUILD_PATH := $(shell echo $$FRR_BUILD_PATH)
endif

vagrant-build:
$(vu) --provision

reload:
vagrant-reload:
$(vr)
$(vs)

start:
vagrant-start:
$(vu)

bash:
$(vs) -c '$(cwd) && bash'
vagrant-bash:
$(vsc) '$(cwd) && bash'

exec:
$(vs) -c '$(filter-out $@,$(MAKECMDGOALS))'
ifeq ($(ENVIRONMENT),vagrant)
$(vsc) '$(filter-out $@,$(MAKECMDGOALS))'
else
@echo "Command only available in Vagrant environment"
endif

test:
ifeq ($(ENVIRONMENT),vagrant)
$(vsc) '$(cwd) && $(t) $(filter-out $@,$(MAKECMDGOALS))'
else
ifndef FRR_BUILD_PATH
@echo "FRR_BUILD_PATH is not set"
@echo "Run:"

@echo "export FRR_BUILD_PATH='/path/to/frr'"

else
$(t) $(filter-out $@,$(MAKECMDGOALS))
endif
endif

run:
$(vs) -c '$(cwd) && $(t) $(filter-out $@,$(MAKECMDGOALS))'

selftest:
ifeq ($(ENVIRONMENT),vagrant)
$(vsc) '$(cwd) && $(st) $(filter-out $@,$(MAKECMDGOALS))'
else
$(st) $(filter-out $@,$(MAKECMDGOALS))
endif

%:
@: