Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c1fabbb authored by Anton Hansson's avatar Anton Hansson Committed by Gerrit Code Review
Browse files

Merge "Write out module owner for prebuilt_etc"

parents a2aca287 ce0e2589
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -145,6 +145,9 @@ func (p *PrebuiltEtc) AndroidMk() AndroidMkData {
			fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
			fmt.Fprintln(w, "LOCAL_MODULE :=", name+nameSuffix)
			fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC")
			if p.commonProperties.Owner != nil {
				fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", *p.commonProperties.Owner)
			}
			fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional")
			fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.outputFilePath.String())
			fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
+47 −0
Original line number Diff line number Diff line
@@ -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())
		}
	}
}