From b9518073037aee71b0ed71cbcd930e44cde0a592 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Fri, 22 Nov 2024 14:05:20 +0900 Subject: Add apex_test.skip_validations Run validations for apex_test modules as well. If a test apex needs to be invalid for testing, it needs to specify which validation it needs to skip. This is to prevent cases like using apex_test to avoid a certain validation, but accidentally skipping all validations. For now, host_apex_verifier/apex_sepolicy_tests can be skipped. Bug: 363090062 Test: m nothing --no-skip-soong-tests Test: mmma system/apex Change-Id: I2d14f25f579eabe92ed2bd0e28b5ed19583df99d --- apex/apex_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'apex/apex_test.go') diff --git a/apex/apex_test.go b/apex/apex_test.go index 5b5fe5ff1..6e9295911 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -7101,6 +7101,51 @@ func TestApexAvailable_PrefixMatch(t *testing.T) { `) } +func TestApexValidation_TestApexCanSkipInitRcCheck(t *testing.T) { + t.Parallel() + ctx := testApex(t, ` + apex_test { + name: "myapex", + key: "myapex.key", + skip_validations: { + host_apex_verifier: true, + }, + updatable: false, + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + `) + + validations := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("signapk").Validations.Strings() + if android.SuffixInList(validations, "host_apex_verifier.timestamp") { + t.Error("should not run host_apex_verifier") + } +} + +func TestApexValidation_TestApexCheckInitRc(t *testing.T) { + t.Parallel() + ctx := testApex(t, ` + apex_test { + name: "myapex", + key: "myapex.key", + updatable: false, + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + `) + + validations := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("signapk").Validations.Strings() + if !android.SuffixInList(validations, "host_apex_verifier.timestamp") { + t.Error("should run host_apex_verifier") + } +} + func TestOverrideApex(t *testing.T) { t.Parallel() ctx := testApex(t, ` -- cgit v1.2.3-59-g8ed1b