From af73095979facd1e2b5a5bb4e4c8e485f1d2f204 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Tue, 28 Feb 2023 14:13:38 +0900 Subject: Add apex.use_file_contexts_as_is property When set true, use file_contexts file as is and do not force-label / and /apex_manifest.pb Bug: 268439003 Test: m (soong tests) Change-Id: I252eef9569deeac87bb71a3425a8eb07bab3c634 --- apex/apex_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'apex/apex_test.go') diff --git a/apex/apex_test.go b/apex/apex_test.go index b7febe17f..0dd01176a 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -784,6 +784,43 @@ func TestApexManifestMinSdkVersion(t *testing.T) { } } +func TestFileContexts(t *testing.T) { + for _, useFileContextsAsIs := range []bool{true, false} { + prop := "" + if useFileContextsAsIs { + prop = "use_file_contexts_as_is: true,\n" + } + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + file_contexts: "file_contexts", + updatable: false, + vendor: true, + `+prop+` + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + `, withFiles(map[string][]byte{ + "file_contexts": nil, + })) + + rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("file_contexts") + forceLabellingCommand := "apex_manifest\\\\.pb u:object_r:system_file:s0" + if useFileContextsAsIs { + android.AssertStringDoesNotContain(t, "should force-label", + rule.RuleParams.Command, forceLabellingCommand) + } else { + android.AssertStringDoesContain(t, "shouldn't force-label", + rule.RuleParams.Command, forceLabellingCommand) + } + } +} + func TestBasicZipApex(t *testing.T) { ctx := testApex(t, ` apex { -- cgit v1.2.3-59-g8ed1b