Ensure each adapter is run as its own make target

Change-Id: I2ba2b0a63ab96caeb36a9e5b2954daf312b9b696
diff --git a/Makefile b/Makefile
index 58fa0cf..f640ab8 100644
--- a/Makefile
+++ b/Makefile
@@ -464,16 +464,23 @@
 		nosetests -s tests --exclude-dir=./tests/itests/run_as_root/
 endif
 
+.PHONY: utest-adapters
 TEST_ADAPTERS := $(shell find ./voltha/adapters -name test.mk)
+TESTABLE_ADAPTERS:= $(patsubst %.mk,%_target,$(TEST_ADAPTERS))
+
+%_target : %.mk
+	@ echo Test Adapter \($<\)
+	@ $(MAKE) -f $<
+
+utest-adapters: $(TESTABLE_ADAPTERS)
+	@ echo Completed utest of Testable Adapters
+
 
 ifneq ($(VOLTHA_BUILD),docker)
 utest: venv protos
 	@ echo "Executing all unit tests"
 	@ . ${VENVDIR}/bin/activate && nosetests ./tests/utests
-	@ for test in $(TEST_ADAPTERS); do \
-			echo Adapter Tests $$test:; \
-			$(MAKE) -f $$test; \
-	  done
+	@ $(MAKE) utest-adapters
 else
 utest: protos test_runner
 	docker run \
@@ -486,10 +493,7 @@
 		${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
 		bash -c \
 		'. ${VENVDIR}/bin/activate && nosetests ./tests/utests; \
-		for test in $(TEST_ADAPTERS); do \
-			echo Adapter Tests $$test:; \
-			$(MAKE) -f $$test; \
-		done'
+		$(MAKE) utest-adapters'
 endif
 
 COVERAGE_OPTS=--with-xcoverage --with-xunit --cover-package=voltha,common,ofagent --cover-html\
@@ -498,10 +502,7 @@
 utest-with-coverage: venv protos
 	@ echo "Executing all unit tests and producing coverage results"
 	@ . ${VENVDIR}/bin/activate && nosetests $(COVERAGE_OPTS) ./tests/utests
-	@ for test in $(TEST_ADAPTERS); do \
-		echo Adapter Tests $$test:; \
-		$(MAKE) -f $$test; \
-	done
+	@ $(MAKE) utest-adapters
 else
 utest-with-coverage: protos test_runner
 	@echo "Executing all unit tests and producing coverage results"
@@ -515,10 +516,7 @@
 		${REGISTRY}${REPSOITORY}voltha-test_runner:${TAG} \
 		bash -c \
 		'nosetests ${COVERAGE_OPTS} ./tests/utests; \
-		 for test in $(TEST_ADAPTERS); do \
-			echo Adapter Tests $$test:; \
-			$(MAKE) -f $$test; \
-		 done'
+		 $(MAKE) utest-adapters'
 endif
 
 ifneq ($(VOLTHA_BUILD),docker)
diff --git a/voltha/adapters/adtran_olt/.gitignore b/voltha/adapters/adtran_olt/.gitignore
index 88158a1..a56c3d0 100644
--- a/voltha/adapters/adtran_olt/.gitignore
+++ b/voltha/adapters/adtran_olt/.gitignore
@@ -1,2 +1,3 @@
 htmlcov/
 prof/
+junit-report.xml
\ No newline at end of file
diff --git a/voltha/adapters/adtran_olt/flow/evc_map.py b/voltha/adapters/adtran_olt/flow/evc_map.py
index 8dc601a..0d338a6 100644
--- a/voltha/adapters/adtran_olt/flow/evc_map.py
+++ b/voltha/adapters/adtran_olt/flow/evc_map.py
@@ -247,8 +247,7 @@
             first_gem_id = True
             gem_ids = gem_ids_and_vid[0]
             vid = gem_ids_and_vid[1]
-            ident = '{}.{}'.format(self._pon_id, onu_or_vlan_id) if vid is None \
-                else onu_or_vlan_id
+            ident = '{}.{}'.format(self._pon_id, onu_or_vlan_id)
 
             for gem_id in gem_ids:
                 xml += '<evc-map{}>'.format('' if not create else ' xc:operation="create"')
diff --git a/voltha/adapters/adtran_olt/pytest.ini b/voltha/adapters/adtran_olt/pytest.ini
index 79ffd10..c812f01 100644
--- a/voltha/adapters/adtran_olt/pytest.ini
+++ b/voltha/adapters/adtran_olt/pytest.ini
@@ -14,7 +14,7 @@
 
 [pytest]
 addopts = --cov=. --cov-config=.coveragerc --cov-report html --cov-report term-missing
-          --doctest-modules -vv --junit-xml junit-coverage.xml
+          --doctest-modules -vv --junit-xml junit-report.xml
 doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
 norecursedirs=
 
diff --git a/voltha/adapters/adtran_olt/test.mk b/voltha/adapters/adtran_olt/test.mk
index da6b625..09592f5 100644
--- a/voltha/adapters/adtran_olt/test.mk
+++ b/voltha/adapters/adtran_olt/test.mk
@@ -4,7 +4,7 @@
 ADAPTERS_DIR       := $(dir $(patsubst %/,%,$(WORKING_DIR)))
 VOLTHA_DIR         := $(dir $(patsubst %/,%,$(ADAPTERS_DIR)))
 export VOLTHA_BASE := $(VOLTHA_DIR)../
-GIT_DIR           := $(dir $(patsubst %/,%,$(VOLTHA_DIR))).git
+GIT_DIR            := $(dir $(patsubst %/,%,$(VOLTHA_DIR))).git
 
 OPENOLT_DIR        := $(ADAPTERS_DIR)openolt
 OPENOLT_PROTO      := $(shell find $(OPENOLT_DIR)/protos/ -name '*.proto')
@@ -15,21 +15,32 @@
 
 VENVDIR             =$(VOLTHA_BASE)venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
 TESTDIR             =$(WORKING_DIR)test
+
+ifneq ($(VOLTHA_BUILD),docker)
 IN_VENV            :=. '$(VENVDIR)/bin/activate';
 TEST_REQ_INSTALLED := $(VENVDIR)/.$(ADAPTER_NAME)-test
+GIT_COMMIT_MSG_BIN := $(GIT_DIR)/hooks/commit-msg
+else
+IN_VENV            :=
+TEST_REQ_INSTALLED := $(WORKING_DIR)/.$(ADAPTER_NAME)-req-installed
+GIT_COMMIT_MSG_BIN := $(WORKING_DIR)/.commit-msg
+endif
 
 RUN_PYTEST=$(IN_VENV) PYTHONPATH=$(VOLTHA_BASE):$(VOLTHA_DIR)protos/third_party py.test -vvlx
 
 .PHONY: test
 test: requirements hooks
 	@rm -rf $(TESTDIR)/__pycache__
-	@cd $(WORKING_DIR); $(RUN_PYTEST) $(TESTDIR); coverage xml
+	@-find $(WORKING_DIR) -type f -name '*.pyc' -delete
+	@cd $(WORKING_DIR); $(RUN_PYTEST) $(TESTDIR)
+	@cd $(WORKING_DIR); coverage xml
 
 .PHONY: clean
 clean:
 	@-rm -rf .coverage
 	@-rm -rf htmlcov
 	@-rm -rf *coverage.xml
+	@-rm -rf junit*.xml
 	@-rm -rf .pytest_cache
 	@-find $(WORKING_DIR) -type f -name '*.pyc' -delete
 	@-find $(VOLTHA_DIR)protos -type f -name '*_pb2.py' -delete
@@ -56,17 +67,17 @@
 
 $(TEST_REQ_INSTALLED): $(WORKING_DIR)test_requirements.txt \
                        $(VOLTHA_BASE)requirements.txt
-	@$(IN_VENV) pip install --upgrade -r $(WORKING_DIR)test_requirements.txt
-	@ virtualenv -p python2 --relocatable ${VENVDIR}
-	uname -s > ${@};
+	@ $(IN_VENV) pip install --upgrade -r $(WORKING_DIR)test_requirements.txt
+	@ if [ -f ${VENVDIR} ]; then $(VENV_BIN) -p python2 --relocatable ${VENVDIR}; fi
+	@ uname -s > ${@};
 
 .PHONY: requirements
 requirements: create-venv $(OPENOLT_PB2) $(VOLTHA_PB2) $(TEST_REQ_INSTALLED)
 
 .PHONY: hooks
-hooks: $(GIT_DIR)/hooks/commit-msg
+hooks: $(GIT_COMMIT_MSG_BIN)
 	@echo "Commit hooks installed"
 
-$(GIT_DIR)/hooks/commit-msg:
-	@curl https://gerrit.opencord.org/tools/hooks/commit-msg > $(GIT_DIR)/hooks/commit-msg
-	@chmod u+x $(GIT_DIR)/hooks/commit-msg
+$(GIT_COMMIT_MSG_BIN):
+	@curl https://gerrit.opencord.org/tools/hooks/commit-msg > $(GIT_COMMIT_MSG_BIN)
+	@chmod u+x $(GIT_COMMIT_MSG_BIN)
diff --git a/voltha/adapters/adtran_onu/.gitignore b/voltha/adapters/adtran_onu/.gitignore
index 88158a1..a56c3d0 100644
--- a/voltha/adapters/adtran_onu/.gitignore
+++ b/voltha/adapters/adtran_onu/.gitignore
@@ -1,2 +1,3 @@
 htmlcov/
 prof/
+junit-report.xml
\ No newline at end of file
diff --git a/voltha/adapters/adtran_onu/pytest.ini b/voltha/adapters/adtran_onu/pytest.ini
index 79ffd10..c812f01 100644
--- a/voltha/adapters/adtran_onu/pytest.ini
+++ b/voltha/adapters/adtran_onu/pytest.ini
@@ -14,7 +14,7 @@
 
 [pytest]
 addopts = --cov=. --cov-config=.coveragerc --cov-report html --cov-report term-missing
-          --doctest-modules -vv --junit-xml junit-coverage.xml
+          --doctest-modules -vv --junit-xml junit-report.xml
 doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
 norecursedirs=
 
diff --git a/voltha/adapters/adtran_onu/test.mk b/voltha/adapters/adtran_onu/test.mk
index da6b625..09592f5 100644
--- a/voltha/adapters/adtran_onu/test.mk
+++ b/voltha/adapters/adtran_onu/test.mk
@@ -4,7 +4,7 @@
 ADAPTERS_DIR       := $(dir $(patsubst %/,%,$(WORKING_DIR)))
 VOLTHA_DIR         := $(dir $(patsubst %/,%,$(ADAPTERS_DIR)))
 export VOLTHA_BASE := $(VOLTHA_DIR)../
-GIT_DIR           := $(dir $(patsubst %/,%,$(VOLTHA_DIR))).git
+GIT_DIR            := $(dir $(patsubst %/,%,$(VOLTHA_DIR))).git
 
 OPENOLT_DIR        := $(ADAPTERS_DIR)openolt
 OPENOLT_PROTO      := $(shell find $(OPENOLT_DIR)/protos/ -name '*.proto')
@@ -15,21 +15,32 @@
 
 VENVDIR             =$(VOLTHA_BASE)venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
 TESTDIR             =$(WORKING_DIR)test
+
+ifneq ($(VOLTHA_BUILD),docker)
 IN_VENV            :=. '$(VENVDIR)/bin/activate';
 TEST_REQ_INSTALLED := $(VENVDIR)/.$(ADAPTER_NAME)-test
+GIT_COMMIT_MSG_BIN := $(GIT_DIR)/hooks/commit-msg
+else
+IN_VENV            :=
+TEST_REQ_INSTALLED := $(WORKING_DIR)/.$(ADAPTER_NAME)-req-installed
+GIT_COMMIT_MSG_BIN := $(WORKING_DIR)/.commit-msg
+endif
 
 RUN_PYTEST=$(IN_VENV) PYTHONPATH=$(VOLTHA_BASE):$(VOLTHA_DIR)protos/third_party py.test -vvlx
 
 .PHONY: test
 test: requirements hooks
 	@rm -rf $(TESTDIR)/__pycache__
-	@cd $(WORKING_DIR); $(RUN_PYTEST) $(TESTDIR); coverage xml
+	@-find $(WORKING_DIR) -type f -name '*.pyc' -delete
+	@cd $(WORKING_DIR); $(RUN_PYTEST) $(TESTDIR)
+	@cd $(WORKING_DIR); coverage xml
 
 .PHONY: clean
 clean:
 	@-rm -rf .coverage
 	@-rm -rf htmlcov
 	@-rm -rf *coverage.xml
+	@-rm -rf junit*.xml
 	@-rm -rf .pytest_cache
 	@-find $(WORKING_DIR) -type f -name '*.pyc' -delete
 	@-find $(VOLTHA_DIR)protos -type f -name '*_pb2.py' -delete
@@ -56,17 +67,17 @@
 
 $(TEST_REQ_INSTALLED): $(WORKING_DIR)test_requirements.txt \
                        $(VOLTHA_BASE)requirements.txt
-	@$(IN_VENV) pip install --upgrade -r $(WORKING_DIR)test_requirements.txt
-	@ virtualenv -p python2 --relocatable ${VENVDIR}
-	uname -s > ${@};
+	@ $(IN_VENV) pip install --upgrade -r $(WORKING_DIR)test_requirements.txt
+	@ if [ -f ${VENVDIR} ]; then $(VENV_BIN) -p python2 --relocatable ${VENVDIR}; fi
+	@ uname -s > ${@};
 
 .PHONY: requirements
 requirements: create-venv $(OPENOLT_PB2) $(VOLTHA_PB2) $(TEST_REQ_INSTALLED)
 
 .PHONY: hooks
-hooks: $(GIT_DIR)/hooks/commit-msg
+hooks: $(GIT_COMMIT_MSG_BIN)
 	@echo "Commit hooks installed"
 
-$(GIT_DIR)/hooks/commit-msg:
-	@curl https://gerrit.opencord.org/tools/hooks/commit-msg > $(GIT_DIR)/hooks/commit-msg
-	@chmod u+x $(GIT_DIR)/hooks/commit-msg
+$(GIT_COMMIT_MSG_BIN):
+	@curl https://gerrit.opencord.org/tools/hooks/commit-msg > $(GIT_COMMIT_MSG_BIN)
+	@chmod u+x $(GIT_COMMIT_MSG_BIN)