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-test-debug",
111            "qemu-generic-arm64-test-debug",
112            "qemu-generic-arm64u32-test-debug",
113        ],
114        tests=[
115            # Boot tests (test-runner + kernel only)
116            boottests([
117                include("trusty/kernel/build-config-kerneltests"),
118                include("trusty/user/base/build-config-usertests"),
119                include("trusty/user/app/sample/build-config-boottests"),
120            ]),
121            # Android shell port tests - same as above, but triggered with
122            # Linux + android userspace present
123            androidporttests([
124                include("trusty/kernel/build-config-kerneltests"),
125                include("trusty/user/base/build-config-usertests"),
126            ]),
127
128            # Trusty linux driver tests. Unbind and bind to trigger remove and
129            # probe function.
130            androidtest(name="irq-driver",
131                        command="echo 'trusty:irq' >"
132                                "/sys/bus/platform/drivers/trusty-irq/unbind"
133                                "&&"
134                                "echo 'trusty:irq' >"
135                                "/sys/bus/platform/drivers/trusty-irq/bind"),
136
137            androidtest(name="log-driver",
138                        command="echo 'trusty:log' >"
139                                "/sys/bus/platform/drivers/trusty-log/unbind"
140                                "&&"
141                                "echo 'trusty:log' >"
142                                "/sys/bus/platform/drivers/trusty-log/bind"),
143
144            androidtest(name="virtio-driver",
145                        # virtio remove currently hangs (bug: 142275662).
146                        # Disable test until fixed
147                        enabled=False,
148                        command="echo 'trusty:virtio' >"
149                                "/sys/bus/platform/drivers/trusty-virtio/unbind"
150                                "&&"
151                                "echo 'trusty:virtio' >"
152                                "/sys/bus/platform/drivers/trusty-virtio/bind"),
153
154            androidtest(name="trusty-driver",
155                        # virtio remove currently hangs (bug: 142275662).
156                        # Disable affected test until fixed
157                        enabled=False,
158                        command="echo trusty >"
159                                "/sys/bus/platform/drivers/trusty/unbind"
160                                "&&"
161                                "echo trusty >"
162                                "/sys/bus/platform/drivers/trusty/bind"),
163
164            # test that trusty driver started and got a version string
165            androidtest(name="trusty-driver-version",
166                        command="TRUSTY_VERSION=$(cat /sys/bus/platform/"
167                                "devices/trusty/trusty_version)"
168                                "&&"
169                                "echo Trusty version: ${TRUSTY_VERSION}"
170                                "&&"
171                                "if [[ \"${TRUSTY_VERSION}\" != \"Project:\"* ]];"
172                                "then "
173                                "echo Unexpected trusty version string;"
174                                "exit 1;"
175                                "fi"),
176
177            androidtest(name="untainted-linux",
178                        command="TAINTED=$(cat /proc/sys/kernel/tainted)"
179                                "&&"
180                                "if [[ \"${TAINTED}\" != \"0\" ]];"
181                                "then "
182                                "echo Linux kernel tainted ${TAINTED};"
183                                "exit 1;"
184                                "fi"),
185
186            # stdcall test with shared memory buffers.
187            # Each test run takes up to 4 arguments:
188            # <obj_size>,<obj_count=1>,<repeat_share=1>,<repeat_access=3>
189            #
190            # Test single 4K shared memory object.
191            # Test 10 8MB objects, shared twice, each accessed twice. (8MB non-
192            # contiguous object is large enough to need several 4KB messages to
193            # describe)
194            # Test sharing 2 8MB objects 100 times without accessing it.
195            # Test 10 4K shared memory objects, shared 10 times, each accessed
196            # 10 times.
197            androidtest(name="stdcalltest",
198                        command="echo '0x1000 "
199                                "0x800000,10,2,2 "
200                                "0x800000,2,100,0 "
201                                "0x1000,10,10,10' >"
202                                "'/sys/devices/platform/trusty/"
203                                "trusty:test/trusty_test_run'"),
204
205            # TIPC tests
206            androidtest(name="tipc:ta2ta",
207                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
208                                "-t ta2ta-ipc"),
209
210            # TIPC linux to trusty echo test
211            androidtest(name="tipc:echo",
212                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
213                                "-t echo -r 100"),
214
215            # TIPC linux to trusty echo test repeat so 16 bit virtio index wraps
216            # Timeout is set to 15 minutes due to b/258851590.
217            androidtest(name="tipc:echo-long",
218                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
219                                "-t echo -r 65537",
220                        timeout=(15 * 60)),
221
222            # NS shares NS memory with S
223            androidtest(name="tipc:send-fd",
224                        command="/data/nativetest64/vendor/tipc-test/tipc-test "
225                                "-t send-fd"),
226
227            # Storage proxy restart test. The keymaster storage wrapper keeps a
228            # persistent connection to the storage server. Test that this
229            # connection gets re-established when the storage proxy restarts.
230            androidtest(name="storage-proxy-restart",
231                        command="/vendor/bin/trusty-ut-ctrl "
232                                "com.android.keymaster-unittest"
233                                "&&"
234                                "stop storageproxyd"
235                                "&&"
236                                "("
237                                "sleep 5"
238                                "&&"
239                                "start storageproxyd"
240                                "&"
241                                "/vendor/bin/trusty-ut-ctrl "
242                                "com.android.keymaster-unittest"
243                                "&&"
244                                "wait"
245                                ")"
246                                "&&"
247                                "/vendor/bin/trusty-ut-ctrl "
248                                "com.android.keymaster-unittest"),
249
250            # Test automatic clearing of td filesystem when userdata is cleared
251            # - Stage 1
252            # -- Simulate user-data wipe (by removing data/vendor/ss/0 and
253            #    restarting storageproxyd)
254            # -- Create a valid filesystem (with both superblocks written)
255            #
256            # - Stage 2
257            # -- Simulate user-data wipe
258            # -- Create a valid filesystem (with a single committed superblock)
259            # -- Simulate reboot (by restarting storageproxyd)
260            # -- Check that filesystem is accessible (with a small uncommitted
261            #    transaction to more avoid super block updates)
262            #
263            #    If only one super block was written, it could have used the
264            #    wrong version. If the new filesystem always writes superblock
265            #    version 1, then it will fail if the old version was 2 or 3 as
266            #    those two starting points have version 2 in the first
267            #    superblock. Stage one will leave the filesystem at version 2 if
268            #    b/190109878 has not been fixed or at version 3 if it has been
269            #    partially fixed.
270            #
271            # - Stage 3
272            # -- Simulate user-data wipe
273            # -- Write to the filesystem without commiting anything
274            # -- Simulate reboot (Should trigger cleanup path for b/190109878
275            #    bugfix as generated initial superblock is not needed)
276            #
277            # - Stage 4
278            # -- Write a large transaction to the filesystem without commiting
279            #    anything
280            # -- Simulate reboot
281            # -- Check that filesystem is accessible. If superblock was not
282            #    written (b/190109878) this step would fail as the data file is
283            #    no longer empty, but the old super blocks refer to data in the
284            #    previous deleted file.
285            # -- Trigger cleanup in test app.
286            androidtest(name="storage-td-clear-test",
287                        command="function storage-unittest { "
288                                "/vendor/bin/trusty-ut-ctrl "
289                                "com.android.storage-unittest.$1"
290                                ";}"
291                                "&&"
292                                "function wipe-restart-storageproxyd { "
293                                "echo '[ -------- ] wipe-restart-storageproxyd'"
294                                "&&"
295                                "stop storageproxyd"
296                                "&&"
297                                "rm /data/vendor/ss/0"
298                                "&&"
299                                "start storageproxyd"
300                                ";}"
301                                "&&"
302                                "function restart-storageproxyd { "
303                                "echo '[ -------- ] restart-storageproxyd'"
304                                "&&"
305                                "stop storageproxyd"
306                                "&&"
307                                "start storageproxyd"
308                                ";}"
309                                "&&"
310                                "echo '[ -------- ] Stage 1 - 2 commit setup'"
311                                "&&"
312                                "wipe-restart-storageproxyd"
313                                "&&"
314                                "storage-unittest td.init"
315                                "&&"
316                                "storage-unittest td.init"
317                                "&&"
318                                "echo '[ -------- ] Stage 2 - 1 commit setup'"
319                                "&&"
320                                "wipe-restart-storageproxyd"
321                                "&&"
322                                "storage-unittest td.init"
323                                "&&"
324                                "restart-storageproxyd"
325                                "&&"
326                                "storage-unittest td.initnocommitsmall"
327                                "&&"
328                                "echo '[ -------- ] Stage 3 - no commit small'"
329                                "&&"
330                                "wipe-restart-storageproxyd"
331                                "&&"
332                                "storage-unittest td.initnocommitsmall"
333                                "&&"
334                                "restart-storageproxyd"
335                                "&&"
336                                "echo '[ -------- ] Stage 4 - no commit large'"
337                                "&&"
338                                "storage-unittest td.initnocommitlarge"
339                                "&&"
340                                "restart-storageproxyd"
341                                "&&"
342                                "storage-unittest td.initnocommitsmall"
343                                "&&"
344                                "storage-unittest td.initnocommitcleanup"),
345
346            # Test confirmation UI
347            androidtest(name="vts:confirmationui@1.0",
348                        command="/data/nativetest64/"
349                                "VtsHalConfirmationUIV1_0TargetTest/"
350                                "VtsHalConfirmationUIV1_0TargetTest"),
351
352            # Test gatekeeper
353            androidtest(name="vts:gatekeeper@1.0",
354                        command="/data/nativetest64/"
355                                "VtsHalGatekeeperV1_0TargetTest/"
356                                "VtsHalGatekeeperV1_0TargetTest"),
357
358            # Test RKP
359            # TODO(b/235265072): re-enable once Android changes propagate to
360            # Trusty repo.
361            #androidtest(name="vts:rkp",
362            #            command="if [ \"`getprop ro.boot.verifiedbootstate`\" != \"fake\" ]; then "
363            #                    "setprop ro.boot.verifiedbootstate fake; "
364            #                    "fi "
365            #                    "&&"
366            #                    "/data/nativetest64/"
367            #                    "VtsHalRemotelyProvisionedComponentTargetTest/"
368            #                    "VtsHalRemotelyProvisionedComponentTargetTest"
369            #                    " --gtest_filter=\""
370            #                    "-"
371            #                    # We can not satisfy the requirements of
372            #                    # prodMode attestation.
373            #                    "*.generateAndUseEcdsaP256Key_prodMode/*:"
374            #                    # TODO:
375            #                    # bootloader/test-runner/test-runner.c in
376            #                    # trusty/external/trusty needs to properly set
377            #                    # the boot flags for the following tests to pass
378            #                    "*.EmptyRequest_testMode/*:"
379            #                    "*.NewKeyPerCallInTestMode/*:"
380            #                    "*.NonEmptyRequest_testMode/*"
381            #                    "\""),
382
383            # Test keymint attestation key provisioning
384            androidtest(name="keymint-set-attestation-keys",
385                        command="/vendor/bin/"
386                                "trusty_keymaster_set_attestation_key "
387                                "/vendor/etc/"
388                                "keymaster_soft_attestation_keys.xml"),
389
390            # Test keymint wrapped attestation key provisioning
391            androidtest(name="keymint-wrapped-vts",
392                        command="/vendor/bin/"
393                                "trusty_keymaster_set_attestation_key "
394                                "/vendor/etc/"
395                                "keymaster_soft_wrapped_attestation_keys.xml"
396                                "&&"
397                                "if [ \"`getprop ro.boot.verifiedbootstate`\" != \"fake\" ]; then "
398                                "setprop ro.boot.verifiedbootstate fake; "
399                                "fi "
400                                "&&"
401                                "/data/nativetest64/"
402                                "VtsAidlKeyMintTargetTest/"
403                                "VtsAidlKeyMintTargetTest"
404                                " --gtest_filter=\""
405                                "*/AttestKeyTest.*:"
406                                "-"
407                                "*/AttestKeyTest.AllRsaSizes*:"
408                                "*/AttestKeyTest.RsaAttestedAttestKeys*:"
409                                "*/AttestKeyTest.RsaAttestKeyChaining*:"
410                                "*/AttestKeyTest.EcAttestKeyChaining*:"
411                                "*/AttestKeyTest.AlternateAttestKeyChaining*:"
412                                "*/AttestKeyTest.AllEcCurves*:"
413                                "*/AttestKeyTest.EcdsaAttestationID*"
414                                "\""),
415
416            # Test keymint
417            #
418            # ClearOperationsTest.TooManyOperations is excluded from testing
419            # because KM4 VTS leaks operation slots on Trusty (b/146083990).
420            #
421            # EarlyBootKeyTest.UseEarlyBootKeyFailure and
422            # EarlyBootKeyTest.ImportEarlyBootKeyFailure test cases are exluded
423            # because keystore (not present on Trusty emulator image) is needed
424            # to propagate earlyBootEnded signal.
425            #
426            # TODO(b/208872187): Remove --skip_boot_pl_check once we have boot
427            # patchlevel configured.
428            androidtest(name="vts:keymint",
429                        command="if [ \"`getprop ro.boot.verifiedbootstate`\" != \"fake\" ]; then "
430                                "setprop ro.boot.verifiedbootstate fake; "
431                                "fi "
432                                "&&"
433                                "/data/nativetest64/"
434                                "VtsAidlKeyMintTargetTest/"
435                                "VtsAidlKeyMintTargetTest"
436                                " --skip_boot_pl_check"
437                                " --gtest_filter=\""
438                                "-"
439                                "*/ClearOperationsTest.TooManyOperations/*:"
440                                "*/EarlyBootKeyTest.UseEarlyBootKeyFailure/*:"
441                                "*/EarlyBootKeyTest.ImportEarlyBootKeyFailure/*:"
442                                "*SecureElementProvisioningTest.TeeOnly*:"
443                                "*/AttestKeyTest.AllRsaSizes*:"
444                                "*/AttestKeyTest.RsaAttestedAttestKeys*:"
445                                "*/AttestKeyTest.RsaAttestKeyChaining*:"
446                                "*/AttestKeyTest.EcAttestKeyChaining*:"
447                                "*/AttestKeyTest.AlternateAttestKeyChaining*:"
448                                "*/AttestKeyTest.AllEcCurves*:"
449                                "*/AttestKeyTest.EcdsaAttestationID*:"
450                                "*/NewKeyGenerationTest.RsaWithAttestation*:"
451                                "*/NewKeyGenerationTest.RsaEncryptionWithAttestation*:"
452                                "*/NewKeyGenerationTest.LimitedUsageRsaWithAttestation*:"
453                                "*/NewKeyGenerationTest.EcdsaAttestation*:"
454                                "*/NewKeyGenerationTest.EcdsaAttestationCurve25519*:"
455                                "*/NewKeyGenerationTest.EcdsaAttestationTags*:"
456                                "*/NewKeyGenerationTest.EcdsaAttestationIdTags*:"
457                                "*/NewKeyGenerationTest.EcdsaAttestationUniqueId*:"
458                                "*/NewKeyGenerationTest.EcdsaAttestationTagNoApplicationId*:"
459                                "*/NewKeyGenerationTest.AttestationApplicationIDLengthProperlyEncoded*:"
460                                "*/BootloaderStateTest.VbStateIsUnverified*:"
461                                "*/BootloaderStateTest.VbmetaDigest*:"
462                                "*InstanceTest.AidlVersionInFeature*:"
463                                "*InstanceTest.FeatureVersionInAidl*:"
464                                "\"",
465                        timeout=(60 * 60)),
466
467            # Busy test validating that linux acts upon the
468            # trusty thread priority or the high-priority workqueue setting
469            androidtest(name="busy-test-high-to-low-priority-workqueue",
470                        command="nice -n -20 top -b -m 5 -n 11 -d 2 &"
471                                "echo 0 >/sys/module/trusty_core/parameters/use_high_wq"
472                                ";"
473                                "timeout 10 trusty-ut-ctrl com.android.kernel.busy-test"
474                                ";"
475                                "echo 1 > /sys/module/trusty_core/parameters/use_high_wq"
476                                ";"
477                                "timeout 10 trusty-ut-ctrl com.android.kernel.busy-test"
478                                ";"
479                                "echo 0 >/sys/module/trusty_core/parameters/use_high_wq"
480                                "&&"
481                                "wait"),
482
483            # Test Binder RPC between Android and Trusty
484            androidtest(name="binder-rpc-to-trusty-test",
485                        command="/data/nativetest64/vendor/"
486                                "binderRpcToTrustyTest/"
487                                "binderRpcToTrustyTest"),
488        ],
489    ),
490]
491