Write out module owner for prebuilt_etc
Translate owner: "x" into LOCAL_MODULE_OWNER := x in prebuilt_etc rules. Test: unit test in CL exercised with m nothing Change-Id: Ic177b61e6f685f7a0263129a34acdf0bd46d16c2
This commit is contained in:
@@ -15,8 +15,11 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -130,3 +133,47 @@ func TestPrebuiltEtcGlob(t *testing.T) {
|
||||
t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcAndroidMk(t *testing.T) {
|
||||
ctx := testPrebuiltEtc(t, `
|
||||
prebuilt_etc {
|
||||
name: "foo",
|
||||
src: "foo.conf",
|
||||
owner: "abc",
|
||||
filename_from_src: true,
|
||||
}
|
||||
`)
|
||||
|
||||
data := AndroidMkData{}
|
||||
data.Required = append(data.Required, "modA", "moduleB")
|
||||
|
||||
expected := map[string]string{
|
||||
"LOCAL_MODULE": "foo",
|
||||
"LOCAL_MODULE_CLASS": "ETC",
|
||||
"LOCAL_MODULE_OWNER": "abc",
|
||||
"LOCAL_INSTALLED_MODULE_STEM": "foo.conf",
|
||||
"LOCAL_REQUIRED_MODULES": "modA moduleB",
|
||||
}
|
||||
|
||||
mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
|
||||
buf := &bytes.Buffer{}
|
||||
mod.AndroidMk().Custom(buf, "foo", "", "", data)
|
||||
for k, expected := range expected {
|
||||
found := false
|
||||
scanner := bufio.NewScanner(bytes.NewReader(buf.Bytes()))
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
tok := strings.Split(line, " := ")
|
||||
if tok[0] == k {
|
||||
found = true
|
||||
if tok[1] != expected {
|
||||
t.Errorf("Incorrect %s '%s', expected '%s'", k, tok[1], expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
t.Errorf("No %s defined, saw %s", k, buf.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user