blob: 357a10eb717572250610e782a95cda4ebfe20bb6 [file] [log] [blame]
Kailash92764922019-07-25 08:21:39 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Zack Williamsec53a1b2019-09-16 15:50:52 -070015# use bash for pushd/popd, and to fail quickly. virtualenv's activate
16# has undefined variables, so no -u
17SHELL = bash -e -o pipefail
Andy Bavierba9866b2019-10-11 07:11:53 -070018ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
Kailash92764922019-07-25 08:21:39 -070019
Zack Williamsec53a1b2019-09-16 15:50:52 -070020# Variables
Gilles Depatie6c727ff2019-10-21 16:23:13 -040021LINT_ARGS ?= --verbose --configure LineTooLong:120 --configure TooManyTestSteps:15 \
22 --configure TooFewTestSteps:1 --configure TooFewKeywordSteps:1
Zack Williamsec53a1b2019-09-16 15:50:52 -070023VERSION ?= $(shell cat ./VERSION)
Gilles Depatie45fbe042019-11-11 17:10:06 -050024ROBOT_SANITY_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml
25ROBOT_SANITY_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-2x2.yaml
26ROBOT_SCALE_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-16.yaml
27ROBOT_SCALE_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x2.yaml
Kailash92764922019-07-25 08:21:39 -070028
hwchiu0601ec72019-10-08 00:04:43 +000029.PHONY: gendocs
30
31## Variables for gendocs
32TEST_SOURCE := $(wildcard tests/*/*.robot)
33TEST_BASENAME := $(basename $(TEST_SOURCE))
34TEST_DIRS := $(dir $(TEST_SOURCE))
35
36LIB_SOURCE := $(wildcard libraries/*.robot)
37LIB_BASENAME := $(basename $(LIB_SOURCE))
38LIB_DIRS := $(dir $(LIB_SOURCE))
39
Andy Bavierba9866b2019-10-11 07:11:53 -070040ROBOT_MISC_ARGS ?=
hwchiu0601ec72019-10-08 00:04:43 +000041
Gilles Depatie45fbe042019-11-11 17:10:06 -050042# for backwards compatibility
43sanity-kind: sanity-single-kind
44
45sanity-single-kind: ROBOT_MISC_ARGS += -i sanity
46sanity-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
47sanity-single-kind: bbsim-kind
48
49sanity-multi-kind: ROBOT_MISC_ARGS += -i sanity
50sanity-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
51sanity-multi-kind: bbsim-kind
Andy Bavierba9866b2019-10-11 07:11:53 -070052
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -070053bbsim-kind: ROBOT_MISC_ARGS += -X
Gilles Depatie45fbe042019-11-11 17:10:06 -050054bbsim-kind: ROBOT_FILE := Voltha_PODTests.robot
55bbsim-kind: voltha-test
56
57scale-single-kind: ROBOT_MISC_ARGS += -i active
58scale-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_SINGLE_PON_FILE)
59scale-single-kind: bbsim-scale-kind
60
61scale-multi-kind: ROBOT_MISC_ARGS += -i active
62scale-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_PON_FILE)
63scale-multi-kind: bbsim-scale-kind
64
65bbsim-scale-kind: ROBOT_MISC_ARGS += -X
66bbsim-scale-kind: ROBOT_FILE := Voltha_ScaleFunctionalTests.robot
67bbsim-scale-kind: voltha-test
Zack Williamsec53a1b2019-09-16 15:50:52 -070068
69# virtualenv for the robot tools
70vst_venv:
71 virtualenv $@ ;\
72 source ./$@/bin/activate ;\
73 pip install -r requirements.txt
74
75test: lint
76
77lint: vst_venv
78 source ./vst_venv/bin/activate ;\
79 set -u ;\
80 find . -name *.robot -exec rflint $(LINT_ARGS) {} +
81
82# tidy will be more useful once this issue with removing leading comments is
83# resolved: https://github.com/robotframework/robotframework/issues/3263
84tidy:
85 source ./vst_venv/bin/activate ;\
86 set -u ;\
87 find . -name *.robot -exec python -m robot.tidy --inplace {} \;
88
Gilles Depatie45fbe042019-11-11 17:10:06 -050089voltha-test: vst_venv
Zack Williamsec53a1b2019-09-16 15:50:52 -070090 source ./vst_venv/bin/activate ;\
91 set -u ;\
Andy Bavierba9866b2019-10-11 07:11:53 -070092 cd tests/functional ;\
Gilles Depatie45fbe042019-11-11 17:10:06 -050093 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
hwchiu0601ec72019-10-08 00:04:43 +000094
Zack Williamsec53a1b2019-09-16 15:50:52 -070095gendocs: vst_venv
96 source ./vst_venv/bin/activate ;\
97 set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +000098 mkdir -p $@ ;\
99 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
100 for dir in ${LIB_BASENAME}; do\
101 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
102 done ;\
103 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
104 for dir in ${TEST_BASENAME}; do\
105 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
106 done
Zack Williamsec53a1b2019-09-16 15:50:52 -0700107
108# explore use of --docformat REST - integration w/Sphinx?
109clean:
110 find . -name output.xml -print
111
112clean-all: clean
113 rm -rf vst_venv gendocs