1# Copyright (C) 2018 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5#  You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# This file lists projects with optional hosttests and unittests to run for
16# those projects in the following format:
17# [
18#     # Add projects to, or remove projects from, list of projects to build.
19#     # Does not affect builds where the project list is passed on the command
20#     # line.
21#     build(
22#         # List of projects that this build entry applies to. Required.
23#         projects=[
24#             "<project>",
25#             ...
26#         ]
27#         # If enabled is set to True or ommitted, add projects to list of
28#         # projects to build. If enabled is set to False, remove projects from
29#         # list of projects to build.
30#         enabled=<True|False>
31#     ),
32#     ...
33#     # Specify tests to run for specific projects.
34#     testmap(
35#         # List of projects that this testmap entry applies to. Required.
36#         projects=[
37#             "<project>",
38#             ...
39#         ]
40#         # List of host-tests to run. Optional
41#         tests=[
42#             # Run a program on the host
43#             hosttest("some_host_binary"),
44#             # Run test on device or in emulator. Porttests run in one of two
45#             # contexts:
46#             # 1. In a minimal
47#             #    bootloader environment (when porttest is nested within
48#             #    in a boottests element), or
49#             # 2. with a full Android userspace present (when nested within an
50#             #    androidporttests element).
51#             porttest("port.under.test"),
52#             # Run a shell command inside Android
53#             androidtest(name="test_name", command="command to run"),
54#             # Run a sequence of test and commands in the given order
55#             # Ensure that test environment is rebooted before second port test
56#             compositetest(name="testname", sequence=[
57#                 hosttest("some_host_binary"),
58#                 porttest("port.under.test"),
59#                 # a reboot may only be requested inside composite tests
60#                 reboot(),
61#                 porttest("another.port.under.test"),
62#                 ...
63#              ]
64#            ...
65#         ],
66#     ),
67#     ...
68#     # Include another configuration file. If optional is True, and the file
69#     # does not exist, the include statement is ignored.
70#     include(<file>, optional=<True|False>),
71# ]
72
73[
74    testmap(
75        projects=[
76            "qemu-generic-arm64-test-debug-release",
77            "qemu-generic-arm32-test-debug-release",
78        ],
79        tests=[
80            boottests([
81                include("trusty/user/base/build-config-usertests-release"),
82            ]),
83        ],
84    ),
85
86
87    testmap(
88        projects=[
89            "generic-arm64-test-debug",
90        ],
91        tests=[
92            hosttest("avb_test"),
93            hosttest("cbor_test"),
94            hosttest("keymaster_test"),
95            hosttest("mock_storage_test"),
96            hosttest("storage_block_test"),
97            hosttest("storage_host_test"),
98            hosttests([
99                include("trusty/kernel/build-config-kerneltests"),
100                include("trusty/user/base/build-config-usertests"),
101            ]),
102        ],
103    ),
104    include("../../proprietary/scripts/build-config", optional=True),
105    testmap(
106        projects=[
107            "qemu-generic-arm32-gicv3-test-debug",
108            "qemu-generic-arm32-test-debug",
109            "qemu-generic-arm64-fuzz-test-debug",
110            "qemu-generic-arm64-gicv3-spd-ffa-test-debug",
111            "qemu-generic-arm64-gicv3-spd-noffa-test-debug",
112            "qemu-generic-arm64-gicv3-test-debug",
113            "qemu-generic-arm64-test-debug",
114            "qemu-generic-arm64u32-test-debug",
115        ],
116        tests=[
117            # Boot tests (test-runner + kernel only)
118            boottests([
119                include("trusty/kernel/build-config-kerneltests"),
120                include("trusty/user/base/build-config-usertests"),
121                include("trusty/user/app/sample/build-config-boottests"),
122            ]),
123            # Android shell port tests - same as above, but triggered with
124            # Linux + android userspace present
125            androidporttests([
126                include("trusty/kernel/build-config-kerneltests"),
127                include("trusty/user/base/build-config-usertests"),
128
129                # Test automatic clearing of td filesystem when userdata is cleared
130                # - Stage 1
131                # -- Wipe user-data and reboot
132                # -- Create a valid filesystem (with both superblocks written)
133                #
134                # - Stage 2
135                # -- Wipe user-data and reboot
136                # -- Create a valid filesystem (with a single committed superblock)
137                # -- Reboot (keep all data)
138                # -- Check that filesystem is accessible (with a small uncommitted
139                #    transaction to more avoid super block updates)
140                #
141                #    If only one super block was written, it could have used the
142                #    wrong version. If the new filesystem always writes superblock
143                #    version 1, then it will fail if the old version was 2 or 3 as
144                #    those two starting points have version 2 in the first
145                #    superblock. Stage one will leave the filesystem at version 2 if
146                #    b/190109878 has not been fixed or at version 3 if it has been
147                #    partially fixed.
148                #
149                # - Stage 3
150                # -- Wipe user-data and reboot
151                # -- Write to the filesystem without commiting anything
152                # -- Reboot (Should trigger cleanup path for b/190109878
153                #    bugfix as generated initial superblock is not needed)
154                #
155                # - Stage 4
156                # -- Write a large transaction to the filesystem without commiting
157                #    anything
158                # -- Reboot
159                # -- Check that filesystem is accessible. If superblock was not
160                #    written (b/190109878) this step would fail as the data file is
161                #    no longer empty, but the old super blocks refer to data in the
162                #    previous deleted file.
163                # -- Trigger cleanup in test app.
164                compositetest(
165                    name="storage-td-clear-test",
166                    sequence=[
167                        print("[ -------- ] Stage 1 - 2 commit setup"),
168                        reboot(mode=RebootMode.FACTORY_RESET),
169                        porttest("com.android.storage-unittest.td.init"),
170                        porttest("com.android.storage-unittest.td.init"),
171                        print("[ -------- ] Stage 2 - 1 commit setup"),
172                        reboot(mode=RebootMode.FACTORY_RESET),
173                        porttest("com.android.storage-unittest.td.init"),
174                        reboot(mode=RebootMode.REGULAR),
175                        porttest("com.android.storage-unittest.td.initnocommitsmall"),
176                        print("[ -------- ] Stage 3 - no commit small"),
177                        reboot(mode=RebootMode.FACTORY_RESET),
178                        porttest("com.android.storage-unittest.td.initnocommitsmall"),
179                        reboot(mode=RebootMode.REGULAR),
180                        print("[ -------- ] Stage 4 - no commit large"),
181                        porttest("com.android.storage-unittest.td.initnocommitlarge"),
182                        reboot(mode=RebootMode.REGULAR),
183                        porttest("com.android.storage-unittest.td.initnocommitsmall"),
184                        porttest("com.android.storage-unittest.td.initnocommitcleanup"),
185                    ]
186                ).needs(storage_full=True),
187            ]),
188
189            # Trusty linux driver tests. Unbind and bind to trigger remove and
190            # probe function.
191            androidtest(name="irq-driver",
192                        command="TRUSTY_DEV=$(basename /sys/bus/platform/devices/"
193                                "?(*:)trusty?(-core):irq)"
194                                "&&"
195                                "echo $TRUSTY_DEV >"
196                                "/sys/bus/platform/drivers/trusty-irq/unbind"
197                                "&&"
198                                "echo $TRUSTY_DEV >"
199                                "/sys/bus/platform/drivers/trusty-irq/bind"),
200
201            androidtest(name="log-driver",
202                        command="TRUSTY_DEV=$(basename /sys/bus/platform/devices/"
203                                "?(*:)trusty?(-core):log)"
204                                "&&"
205                                "echo $TRUSTY_DEV >"
206                                "/sys/bus/platform/drivers/trusty-log/unbind"
207                                "&&"
208                                "echo $TRUSTY_DEV >"
209                                "/sys/bus/platform/drivers/trusty-log/bind"),
210
211            androidtest(name="virtio-driver",
212                        # virtio remove currently hangs (bug: 142275662).
213                        # Disable test until fixed
214                        enabled=False,
215                        command="TRUSTY_DEV=$(basename /sys/bus/platform/devices/"
216                                "?(*:)trusty?(-core):virtio)"
217                                "&&"
218                                "echo $TRUSTY_DEV >"
219                                "/sys/bus/platform/drivers/trusty-virtio/unbind"
220                                "&&"
221                                "echo $TRUSTY_DEV >"
222                                "/sys/bus/platform/drivers/trusty-virtio/bind"),
223
224            androidtest(name="trusty-driver",
225                        # virtio remove currently hangs (bug: 142275662).
226                        # Disable affected test until fixed
227                        enabled=False,
228                        command="TRUSTY_DEV=$(basename /sys/bus/platform/devices/"
229                                "?(*:)trusty?(-core))"
230                                "&&"
231                                "echo $TRUSTY_DEV >"
232                                "$(echo /sys/bus/platform/drivers/trusty?(-core)/unbind)"
233                                "&&"
234                                "echo $TRUSTY_DEV >"
235                                "$(echo /sys/bus/platform/drivers/trusty?(-core)/bind)"),
236
237            # test that trusty driver started and got a version string
238            androidtest(name="trusty-driver-version",
239                        command="TRUSTY_VERSION=$(cat /sys/bus/platform/"
240                                "devices/?(*:)trusty?(-core)/trusty_version)"
241                                "&&"
242                                "echo Trusty version: ${TRUSTY_VERSION}"
243                                "&&"
244                                "if [[ \"${TRUSTY_VERSION}\" != \"Project:\"* ]];"
245                                "then "
246                                "echo Unexpected trusty version string;"
247                                "exit 1;"
248                                "fi"),
249
250            # Check whether the kernel has been tainted, ignoring
251            # certain causes like out-of-tree and unsigned modules.
252            androidtest(name="untainted-linux",
253                        command="TAINTED=$(cat /proc/sys/kernel/tainted)"
254                                "&&"
255                                "if (( ${TAINTED} & ~0x3000 ));"
256                                "then "
257                                "echo Linux kernel tainted ${TAINTED};"
258                                "exit 1;"
259                                "fi"),
260
261            # stdcall test with shared memory buffers.
262            # Each test run takes up to 4 arguments:
263            # <obj_size>,<obj_count=1>,<repeat_share=1>,<repeat_access=3>
264            #
265            # Test single 4K shared memory object.
266            # Test 10 8MB objects, shared twice, each accessed twice. (8MB non-
267            # contiguous object is large enough to need several 4KB messages to
268            # describe)
269            # Test sharing 2 8MB objects 100 times without accessing it.
270            # Test 10 4K shared memory objects, shared 10 times, each accessed
271            # 10 times.
272            androidtest(name="stdcalltest",
273                        command="echo '0x1000 "
274                                "0x800000,10,2,2 "
275                                "0x800000,2,100,0 "
276                                "0x1000,10,10,10' >"
277                                "$(echo /sys/bus/platform/devices/"
278                                "?(*:)trusty?(-core):test/trusty_test_run)"),
279
280            androidtest(name="fpsimdtest",
281                        command="echo 'fpsimd:1000' >"
282                                "$(echo /sys/bus/platform/devices/"
283                                "?(*:)trusty?(-core):test/trusty_test_run)"),
284
285            # TIPC tests
286            androidtest(name="tipc:ta2ta",
287                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
288                                "-t ta2ta-ipc"),
289
290            # TIPC linux to trusty echo test
291            androidtest(name="tipc:echo",
292                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
293                                "-t echo -r 100"),
294
295            # TIPC linux to trusty echo test repeat so 16 bit virtio index wraps
296            # Timeout is set to 15 minutes due to b/258851590.
297            androidtest(name="tipc:echo-long",
298                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
299                                "-t echo -r 65537",
300                        timeout=(15 * 60)),
301
302            # NS shares NS memory with S
303            androidtest(name="tipc:send-fd",
304                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
305                                "-t send-fd"),
306
307            # Storage proxy restart test. The keymaster storage wrapper keeps a
308            # persistent connection to the storage server. Test that this
309            # connection gets re-established when the storage proxy restarts.
310            androidtest(name="storage-proxy-restart",
311                        command="/vendor/bin/trusty-ut-ctrl "
312                                "com.android.keymaster-unittest"
313                                "&&"
314                                "stop storageproxyd"
315                                "&&"
316                                "("
317                                "sleep 5"
318                                "&&"
319                                "start storageproxyd"
320                                "&"
321                                "/vendor/bin/trusty-ut-ctrl "
322                                "com.android.keymaster-unittest"
323                                "&&"
324                                "wait"
325                                ")"
326                                "&&"
327                                "/vendor/bin/trusty-ut-ctrl "
328                                "com.android.keymaster-unittest"),
329
330            # Test that storage sessions behave correctly when proxy restarts
331            androidtest(
332                name="com.android.storage-reconnect-test.tp.reconnect",
333                command="/vendor/bin/trusty-ut-ctrl "
334                        "com.android.storage-reconnect-test.tp.before "
335                        "&&"
336                        "stop storageproxyd"
337                        "&&"
338                        "/vendor/bin/trusty-ut-ctrl "
339                        "com.android.storage-reconnect-test.tp.during "
340                        "&&"
341                        "start storageproxyd"
342                        "&&"
343                        "/vendor/bin/trusty-ut-ctrl "
344                        "com.android.storage-reconnect-test.tp.after "),
345            androidtest(
346                name="com.android.storage-reconnect-test.td.reconnect",
347                command="/vendor/bin/trusty-ut-ctrl "
348                        "com.android.storage-reconnect-test.td.before "
349                        "&&"
350                        "stop storageproxyd"
351                        "&&"
352                        "/vendor/bin/trusty-ut-ctrl "
353                        "com.android.storage-reconnect-test.td.during "
354                        "&&"
355                        "start storageproxyd"
356                        "&&"
357                        "/vendor/bin/trusty-ut-ctrl "
358                        "com.android.storage-reconnect-test.td.after "),
359            androidtest(
360                name="com.android.storage-reconnect-test.tdp.reconnect",
361                command="/vendor/bin/trusty-ut-ctrl "
362                        "com.android.storage-reconnect-test.tdp.before "
363                        "&&"
364                        "stop storageproxyd"
365                        "&&"
366                        "/vendor/bin/trusty-ut-ctrl "
367                        "com.android.storage-reconnect-test.tdp.during "
368                        "&&"
369                        "start storageproxyd"
370                        "&&"
371                        "/vendor/bin/trusty-ut-ctrl "
372                        "com.android.storage-reconnect-test.tdp.after "),
373
374            # Test confirmation UI
375            androidtest(name="vts:[email protected]",
376                        command="/data/nativetest64/"
377                                "VtsHalConfirmationUIV1_0TargetTest/"
378                                "VtsHalConfirmationUIV1_0TargetTest"),
379
380            # Test gatekeeper
381            androidtest(name="vts:[email protected]",
382                        command="/data/nativetest64/"
383                                "VtsHalGatekeeperV1_0TargetTest/"
384                                "VtsHalGatekeeperV1_0TargetTest"),
385
386            # Test RKP
387            # TODO(b/235265072): re-enable once Android changes propagate to
388            # Trusty repo.
389            #androidtest(name="vts:rkp",
390            #            command="if [ \"`getprop ro.boot.verifiedbootstate`\" != \"fake\" ]; then "
391            #                    "setprop ro.boot.verifiedbootstate fake; "
392            #                    "fi "
393            #                    "&&"
394            #                    "/data/nativetest64/"
395            #                    "VtsHalRemotelyProvisionedComponentTargetTest/"
396            #                    "VtsHalRemotelyProvisionedComponentTargetTest"
397            #                    " --gtest_filter=\""
398            #                    "-"
399            #                    # We can not satisfy the requirements of
400            #                    # prodMode attestation.
401            #                    "*.generateAndUseEcdsaP256Key_prodMode/*:"
402            #                    # TODO:
403            #                    # bootloader/test-runner/test-runner.c in
404            #                    # trusty/external/trusty needs to properly set
405            #                    # the boot flags for the following tests to pass
406            #                    "*.EmptyRequest_testMode/*:"
407            #                    "*.NewKeyPerCallInTestMode/*:"
408            #                    "*.NonEmptyRequest_testMode/*"
409            #                    "\""),
410
411            # Test keymint attestation key provisioning
412            androidtest(name="keymint-set-attestation-keys",
413                        command="/vendor/bin/"
414                                "trusty_keymaster_set_attestation_key "
415                                "/vendor/etc/"
416                                "keymaster_soft_attestation_keys.xml"),
417
418            # Test keymint wrapped attestation key provisioning
419            androidtest(name="keymint-wrapped-vts",
420                        command="/vendor/bin/"
421                                "trusty_keymaster_set_attestation_key "
422                                "/vendor/etc/"
423                                "keymaster_soft_wrapped_attestation_keys.xml"
424                                "&&"
425                                "if [ \"`getprop ro.boot.verifiedbootstate`\" != \"fake\" ]; then "
426                                "setprop ro.boot.verifiedbootstate fake; "
427                                "fi "
428                                "&&"
429                                "/data/nativetest64/"
430                                "VtsAidlKeyMintTargetTest/"
431                                "VtsAidlKeyMintTargetTest"
432                                " --gtest_filter=\""
433                                "*/AttestKeyTest.*:"
434                                "-"
435                                "*/AttestKeyTest.AllRsaSizes*:"
436                                "*/AttestKeyTest.RsaAttestedAttestKeys*:"
437                                "*/AttestKeyTest.RsaAttestKeyChaining*:"
438                                "*/AttestKeyTest.EcAttestKeyChaining*:"
439                                "*/AttestKeyTest.AlternateAttestKeyChaining*:"
440                                "*/AttestKeyTest.AllEcCurves*:"
441                                "*/AttestKeyTest.EcdsaAttestationID*"
442                                "\""),
443
444            # Test keymint
445            #
446            # ClearOperationsTest.TooManyOperations is excluded from testing
447            # because KM4 VTS leaks operation slots on Trusty (b/146083990).
448            #
449            # EarlyBootKeyTest.UseEarlyBootKeyFailure and
450            # EarlyBootKeyTest.ImportEarlyBootKeyFailure test cases are exluded
451            # because keystore (not present on Trusty emulator image) is needed
452            # to propagate earlyBootEnded signal.
453            #
454            # TODO(b/208872187): Remove --skip_boot_pl_check once we have boot
455            # patchlevel configured.
456            androidtest(name="vts:keymint",
457                        command="if [ \"`getprop ro.boot.verifiedbootstate`\" != \"fake\" ]; then "
458                                "setprop ro.boot.verifiedbootstate fake; "
459                                "fi "
460                                "&&"
461                                "/data/nativetest64/"
462                                "VtsAidlKeyMintTargetTest/"
463                                "VtsAidlKeyMintTargetTest"
464                                " --skip_boot_pl_check"
465                                " --gtest_filter=\""
466                                "-"
467                                "*/ClearOperationsTest.TooManyOperations/*:"
468                                "*/EarlyBootKeyTest.UseEarlyBootKeyFailure/*:"
469                                "*/EarlyBootKeyTest.ImportEarlyBootKeyFailure/*:"
470                                "*SecureElementProvisioningTest.TeeOnly*:"
471                                "*/AttestKeyTest.AllRsaSizes*:"
472                                "*/AttestKeyTest.RsaAttestedAttestKeys*:"
473                                "*/AttestKeyTest.RsaAttestKeyChaining*:"
474                                "*/AttestKeyTest.EcAttestKeyChaining*:"
475                                "*/AttestKeyTest.AlternateAttestKeyChaining*:"
476                                "*/AttestKeyTest.AllEcCurves*:"
477                                "*/AttestKeyTest.EcdsaAttestationID*:"
478                                "*/NewKeyGenerationTest.RsaWithAttestation*:"
479                                "*/NewKeyGenerationTest.RsaEncryptionWithAttestation*:"
480                                "*/NewKeyGenerationTest.LimitedUsageRsaWithAttestation*:"
481                                "*/NewKeyGenerationTest.EcdsaAttestation*:"
482                                "*/NewKeyGenerationTest.EcdsaAttestationCurve25519*:"
483                                "*/NewKeyGenerationTest.EcdsaAttestationTags*:"
484                                "*/NewKeyGenerationTest.EcdsaAttestationIdTags*:"
485                                "*/NewKeyGenerationTest.EcdsaAttestationUniqueId*:"
486                                "*/NewKeyGenerationTest.EcdsaAttestationTagNoApplicationId*:"
487                                "*/NewKeyGenerationTest.AttestationApplicationIDLengthProperlyEncoded*:"
488                                "*/BootloaderStateTest.VbStateIsUnverified*:"
489                                "*/BootloaderStateTest.VbmetaDigest*:"
490                                "*InstanceTest.AidlVersionInFeature*:"
491                                "*InstanceTest.FeatureVersionInAidl*:"
492                                "\"",
493                        timeout=(60 * 60)),
494
495            # Busy test validating that linux acts upon the
496            # trusty thread priority or the high-priority workqueue setting
497            androidtest(name="busy-test-high-to-low-priority-workqueue",
498                        command="nice -n -20 top -b -m 5 -n 11 -d 2 &"
499                                "echo 0 >/sys/module/trusty_core/parameters/use_high_wq"
500                                ";"
501                                "timeout 10 trusty-ut-ctrl com.android.kernel.busy-test"
502                                ";"
503                                "echo 1 > /sys/module/trusty_core/parameters/use_high_wq"
504                                ";"
505                                "timeout 10 trusty-ut-ctrl com.android.kernel.busy-test"
506                                ";"
507                                "echo 0 >/sys/module/trusty_core/parameters/use_high_wq"
508                                "&&"
509                                "wait"),
510
511            # Test Binder RPC between Android and Trusty
512            androidtest(name="binder-rpc-to-trusty-test",
513                        command="/data/nativetest64/vendor/"
514                                "binderRpcToTrustyTest/"
515                                "binderRpcToTrustyTest64"),
516        ],
517    ),
518]
519