Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ed5cd34

Browse files
committed
Run engine unit tests on mac host_debug_unopt_arm64
1 parent a04fba4 commit ed5cd34

File tree

4 files changed

+125
-95
lines changed

4 files changed

+125
-95
lines changed

ci/builders/mac_unopt.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,21 @@
142142
"$flutter/osx_sdk": {
143143
"sdk_version": "15a240d"
144144
}
145-
}
145+
},
146+
"tests": [
147+
{
148+
"language": "python3",
149+
"name": "Host Tests for host_debug_unopt_arm64",
150+
"script": "flutter/testing/run_tests.py",
151+
"parameters": [
152+
"--variant",
153+
"host_debug_unopt_arm64",
154+
"--type",
155+
"dart,dart-host,engine",
156+
"--engine-capture-core-dump"
157+
]
158+
}
159+
]
146160
},
147161
{
148162
"properties": {

shell/platform/embedder/tests/embedder_unittests.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,14 @@ TEST_F(EmbedderTest, VMAndIsolateSnapshotSizesAreRedundantInAOTMode) {
646646
///
647647
TEST_F(EmbedderTest,
648648
CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor) {
649+
// TODO(143940): Convert this test to use SkiaGold.
650+
#if FML_OS_MACOSX && FML_ARCH_CPU_ARM64
651+
{
652+
GTEST_SKIP() << "Skipping golen test on arm64 macOS";
653+
return;
654+
}
655+
#endif // FML_OS_MACOSX && FML_ARCH_CPU_ARM64
656+
649657
auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
650658

651659
EmbedderConfigBuilder builder(context);

testing/run_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,10 @@ def main():
12601260

12611261
variants_to_skip = ['host_release', 'host_profile']
12621262
if ('engine' in types or 'font-subset' in types) and args.variant not in variants_to_skip:
1263-
run_cmd(['python3', 'test.py'], cwd=FONT_SUBSET_DIR)
1263+
cmd = ['python3', 'test.py', '--variant', args.variant]
1264+
if 'arm64' in args.variant:
1265+
cmd += ['--target-cpu', 'arm64']
1266+
run_cmd(cmd, cwd=FONT_SUBSET_DIR)
12641267

12651268
if 'impeller-golden' in types:
12661269
run_impeller_golden_tests(build_dir)

tools/font_subset/test.py

Lines changed: 98 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,17 @@
88
Tests for font-subset
99
'''
1010

11+
import argparse
1112
import filecmp
1213
import os
1314
import subprocess
1415
import sys
1516
from zipfile import ZipFile
1617

17-
# Dictionary to map the platform name to the output directory
18-
# of the font artifacts.
19-
PLATFORM_2_PATH = {
20-
'darwin': 'darwin-x64',
21-
'linux': 'linux-x64',
22-
'linux2': 'linux-x64',
23-
'cygwin': 'windows-x64',
24-
'win': 'windows-x64',
25-
'win32': 'windows-x64',
26-
}
27-
2818
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
2919
SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, '..', '..', '..'))
3020
MATERIAL_TTF = os.path.join(SCRIPT_DIR, 'fixtures', 'MaterialIcons-Regular.ttf')
3121
VARIABLE_MATERIAL_TTF = os.path.join(SCRIPT_DIR, 'fixtures', 'MaterialSymbols-Variable.ttf')
32-
IS_WINDOWS = sys.platform.startswith(('cygwin', 'win'))
33-
EXE = '.exe' if IS_WINDOWS else ''
34-
BAT = '.bat' if IS_WINDOWS else ''
35-
FONT_SUBSET = os.path.join(SRC_DIR, 'out', 'host_debug', 'font-subset' + EXE)
36-
FONT_SUBSET_ZIP = os.path.join(
37-
SRC_DIR, 'out', 'host_debug', 'zip_archives', PLATFORM_2_PATH.get(sys.platform, ''),
38-
'font-subset.zip'
39-
)
40-
if not os.path.isfile(FONT_SUBSET):
41-
FONT_SUBSET = os.path.join(SRC_DIR, 'out', 'host_debug_unopt', 'font-subset' + EXE)
42-
FONT_SUBSET_ZIP = os.path.join(
43-
SRC_DIR, 'out', 'host_debug_unopt', 'zip_archives', PLATFORM_2_PATH.get(sys.platform, ''),
44-
'font-subset.zip'
45-
)
46-
if not os.path.isfile(FONT_SUBSET):
47-
raise Exception(
48-
'Could not locate font-subset%s in host_debug or host_debug_unopt - build before running this script.'
49-
% EXE
50-
)
5122

5223
COMPARE_TESTS = (
5324
(True, '1.ttf', MATERIAL_TTF, [r'57347']),
@@ -91,59 +62,61 @@
9162
]),
9263
)
9364

94-
FAIL_TESTS = [
95-
([FONT_SUBSET, 'output.ttf', 'does-not-exist.ttf'], [
96-
'1',
97-
]), # non-existent input font
98-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [
99-
'0xFFFFFFFF',
100-
]), # Value too big.
101-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [
102-
'-1',
103-
]), # invalid value
104-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [
105-
'foo',
106-
]), # no valid values
107-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [
108-
'0xE003',
109-
'0x12',
110-
'0xE004',
111-
]), # codepoint not in font
112-
([FONT_SUBSET, 'non-existent-dir/output.ttf', MATERIAL_TTF], [
113-
'0xE003',
114-
]), # dir doesn't exist
115-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [
116-
' ',
117-
]), # empty input
118-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], []), # empty input
119-
([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], ['']), # empty input
120-
# repeat tests with variable input font
121-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [
122-
'0xFFFFFFFF',
123-
]), # Value too big.
124-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [
125-
'-1',
126-
]), # invalid value
127-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [
128-
'foo',
129-
]), # no valid values
130-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [
131-
'0xE003',
132-
'0x12',
133-
'0xE004',
134-
]), # codepoint not in font
135-
([FONT_SUBSET, 'non-existent-dir/output.ttf', VARIABLE_MATERIAL_TTF], [
136-
'0xE003',
137-
]), # dir doesn't exist
138-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [
139-
' ',
140-
]), # empty input
141-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], []), # empty input
142-
([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], ['']), # empty input
143-
]
144-
145-
146-
def RunCmd(cmd, codepoints, fail=False):
65+
66+
def fail_tests(font_subset):
67+
return [
68+
([font_subset, 'output.ttf', 'does-not-exist.ttf'], [
69+
'1',
70+
]), # non-existent input font
71+
([font_subset, 'output.ttf', MATERIAL_TTF], [
72+
'0xFFFFFFFF',
73+
]), # Value too big.
74+
([font_subset, 'output.ttf', MATERIAL_TTF], [
75+
'-1',
76+
]), # invalid value
77+
([font_subset, 'output.ttf', MATERIAL_TTF], [
78+
'foo',
79+
]), # no valid values
80+
([font_subset, 'output.ttf', MATERIAL_TTF], [
81+
'0xE003',
82+
'0x12',
83+
'0xE004',
84+
]), # codepoint not in font
85+
([font_subset, 'non-existent-dir/output.ttf', MATERIAL_TTF], [
86+
'0xE003',
87+
]), # dir doesn't exist
88+
([font_subset, 'output.ttf', MATERIAL_TTF], [
89+
' ',
90+
]), # empty input
91+
([font_subset, 'output.ttf', MATERIAL_TTF], []), # empty input
92+
([font_subset, 'output.ttf', MATERIAL_TTF], ['']), # empty input
93+
# repeat tests with variable input font
94+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [
95+
'0xFFFFFFFF',
96+
]), # Value too big.
97+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [
98+
'-1',
99+
]), # invalid value
100+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [
101+
'foo',
102+
]), # no valid values
103+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [
104+
'0xE003',
105+
'0x12',
106+
'0xE004',
107+
]), # codepoint not in font
108+
([font_subset, 'non-existent-dir/output.ttf', VARIABLE_MATERIAL_TTF], [
109+
'0xE003',
110+
]), # dir doesn't exist
111+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [
112+
' ',
113+
]), # empty input
114+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], []), # empty input
115+
([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], ['']), # empty input
116+
]
117+
118+
119+
def run_cmd(cmd, codepoints, fail=False):
147120
print('Running command:')
148121
print(' %s' % ' '.join(cmd))
149122
print('STDIN: "%s"' % ' '.join(codepoints))
@@ -169,34 +142,66 @@ def RunCmd(cmd, codepoints, fail=False):
169142
return p.returncode
170143

171144

172-
def TestZip():
173-
with ZipFile(FONT_SUBSET_ZIP, 'r') as zip:
145+
def test_zip(font_subset_zip, exe):
146+
with ZipFile(font_subset_zip, 'r') as zip:
174147
files = zip.namelist()
175-
if 'font-subset%s' % EXE not in files:
176-
print('expected %s to contain font-subset%s' % (files, EXE))
148+
if 'font-subset%s' % exe not in files:
149+
print('expected %s to contain font-subset%s' % (files, exe))
177150
return 1
178151
return 0
179152

180153

154+
# Maps the platform name to the output directory of the font artifacts.
155+
def platform_to_path(os, cpu):
156+
d = {
157+
'darwin': 'darwin-',
158+
'linux': 'linux-',
159+
'linux2': 'linux-',
160+
'cygwin': 'windows-',
161+
'win': 'windows-',
162+
'win32': 'windows-',
163+
}
164+
return d[os] + cpu
165+
166+
181167
def main():
182-
print('Using font subset binary at %s (%s)' % (FONT_SUBSET, FONT_SUBSET_ZIP))
168+
parser = argparse.ArgumentParser(description='Runs font-subset tests.')
169+
parser.add_argument('--variant', type=str, required=True)
170+
parser.add_argument('--target-cpu', type=str, default='x64')
171+
args = parser.parse_args()
172+
variant = args.variant
173+
174+
is_windows = sys.platform.startswith(('cygwin', 'win'))
175+
exe = '.exe' if is_windows else ''
176+
font_subset = os.path.join(SRC_DIR, 'out', variant, 'font-subset' + exe)
177+
font_subset_zip = os.path.join(
178+
SRC_DIR, 'out', variant, 'zip_archives', platform_to_path(sys.platform, args.target_cpu),
179+
'font-subset.zip'
180+
)
181+
if not os.path.isfile(font_subset):
182+
raise Exception(
183+
'Could not locate font-subset%s in host_debug or host_debug_unopt - build before running this script.'
184+
% exe
185+
)
186+
187+
print('Using font subset binary at %s (%s)' % (font_subset, font_subset_zip))
183188
failures = 0
184189

185-
failures += TestZip()
190+
failures += test_zip(font_subset_zip, exe)
186191

187192
for should_pass, golden_font, input_font, codepoints in COMPARE_TESTS:
188193
gen_ttf = os.path.join(SCRIPT_DIR, 'gen', golden_font)
189194
golden_ttf = os.path.join(SCRIPT_DIR, 'fixtures', golden_font)
190-
cmd = [FONT_SUBSET, gen_ttf, input_font]
191-
RunCmd(cmd, codepoints)
195+
cmd = [font_subset, gen_ttf, input_font]
196+
run_cmd(cmd, codepoints)
192197
cmp = filecmp.cmp(gen_ttf, golden_ttf, shallow=False)
193198
if (should_pass and not cmp) or (not should_pass and cmp):
194199
print('Test case %s failed.' % cmd)
195200
failures += 1
196201

197202
with open(os.devnull, 'w') as devnull:
198-
for cmd, codepoints in FAIL_TESTS:
199-
if RunCmd(cmd, codepoints, fail=True) == 0:
203+
for cmd, codepoints in fail_tests(font_subset):
204+
if run_cmd(cmd, codepoints, fail=True) == 0:
200205
failures += 1
201206

202207
if failures > 0:

0 commit comments

Comments
 (0)