Use correct install paths in generated Android.mk

Extract Soong's install path and put it in the generated Android.mk file
so that tests get installed in the correct place.

Change-Id: Id4726855c5677855406de20773a5da533bdd4cea
diff --git a/cc/androidmk.go b/cc/androidmk.go
index aa5c4dc..8b1b349 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -17,6 +17,7 @@
 import (
 	"fmt"
 	"io"
+	"path/filepath"
 	"strings"
 
 	"android/soong/common"
@@ -105,5 +106,17 @@
 }
 
 func (test *testLinker) AndroidMk(ret *common.AndroidMkData) {
-	ret.Disabled = true
+	test.binaryLinker.AndroidMk(ret)
+	if Bool(test.Properties.Test_per_src) {
+		ret.SubName = test.binaryLinker.Properties.Stem
+	}
+}
+
+func (installer *baseInstaller) AndroidMk(ret *common.AndroidMkData) {
+	ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error {
+		path := installer.path.RelPathString()
+		fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Dir(path))
+		fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+filepath.Base(path))
+		return nil
+	})
 }