@@ -126,16 +126,27 @@ def no_pass_debug():
126126def randomize_feature_opts ():
127127 global FEATURE_OPTS
128128 FEATURE_OPTS = CONSTANT_FEATURE_OPTS [:]
129- # 1/3 the time apply all the possible opts, 1/3 none of them, to maximize
130- # coverage both ways, and 1/3 pick each one randomly
131- if random .random () < 0.33333 :
132- FEATURE_OPTS += POSSIBLE_FEATURE_OPTS
133- elif random .random () < 0.5 :
134- for possible in POSSIBLE_FEATURE_OPTS :
129+
130+ if random .random () < 0.1 :
131+ # 10% of the time disable all features, i.e., fuzz the MVP featureset.
132+ # Fuzzing that is less and less important as more features get enabled
133+ # by default, but we don't want to lose all coverage for it entirely
134+ # (and the odds of randomly not selecting any feature, below, is too
135+ # small - at 17 features it is far less than 1%).
136+ FEATURE_OPTS += FEATURE_DISABLE_FLAGS
137+ elif random .random () < 0.333 :
138+ # 1/3 of the remaining 90% pick each feature randomly.
139+ for possible in FEATURE_DISABLE_FLAGS :
135140 if random .random () < 0.5 :
136141 FEATURE_OPTS .append (possible )
137142 if possible in IMPLIED_FEATURE_OPTS :
138143 FEATURE_OPTS .extend (IMPLIED_FEATURE_OPTS [possible ])
144+ else :
145+ # 2/3 of the remaining 90% use them all. This is useful to maximize
146+ # coverage, as enabling more features enables more optimizations and
147+ # code paths, and also allows all initial contents to run.
148+ pass
149+
139150 print ('randomized feature opts:' , '\n ' + '\n ' .join (FEATURE_OPTS ))
140151
141152 # Pick closed or open with equal probability as both matter.
@@ -928,9 +939,6 @@ def compare_before_and_after(self, before, after):
928939 if vm in after and vm .can_compare_to_self ():
929940 compare (before [vm ], after [vm ], 'CompareVMs between before and after: ' + vm .name )
930941
931- def can_run_on_feature_opts (self , feature_opts ):
932- return True
933-
934942
935943# Check for determinism - the same command must have the same output.
936944class CheckDeterminism (TestCaseHandler ):
@@ -1591,11 +1599,10 @@ def get_random_opts():
15911599
15921600# main
15931601
1594- # possible feature options that are sometimes passed to the tools. this
1595- # contains the list of all possible feature flags we can disable (after
1596- # we enable all before that in the constant options)
1597- POSSIBLE_FEATURE_OPTS = run ([in_bin ('wasm-opt' ), '--print-features' , in_binaryen ('test' , 'hello_world.wat' )] + CONSTANT_FEATURE_OPTS ).replace ('--enable' , '--disable' ).strip ().split ('\n ' )
1598- print ('POSSIBLE_FEATURE_OPTS:' , POSSIBLE_FEATURE_OPTS )
1602+ # list of all the flags to disable all the features. if all of these are added
1603+ # then we target the MVP.
1604+ FEATURE_DISABLE_FLAGS = run ([in_bin ('wasm-opt' ), '--print-features' , in_binaryen ('test' , 'hello_world.wat' )] + CONSTANT_FEATURE_OPTS ).replace ('--enable' , '--disable' ).strip ().split ('\n ' )
1605+ print ('FEATURE_DISABLE_FLAGS:' , FEATURE_DISABLE_FLAGS )
15991606
16001607# some features depend on other features, so if a required feature is
16011608# disabled, its dependent features need to be disabled as well.
0 commit comments