File tree Expand file tree Collapse file tree 5 files changed +53
-15
lines changed Expand file tree Collapse file tree 5 files changed +53
-15
lines changed Original file line number Diff line number Diff line change @@ -275,27 +275,41 @@ def parse_args():
275
275
post_process (cl_args )
276
276
return cl_args
277
277
278
- # Extract a list of args based on given config toml
278
+
279
279
def extract_flags_from_toml (path ):
280
+ """Extract a list of args based on given config toml
281
+ RMC can be configured in the following tables:
282
+ - rmc
283
+ - workspace.metadata.rmc
284
+ - package.metadata.rmc
285
+ The only field supported today is flags.
286
+ """
280
287
# Load the flag data from toml
281
288
data = toml .load (path )
282
289
283
- # Extract the rmc flags from the toml, if any present
284
- if ("rmc" not in data ) or ("flags" not in data ["rmc" ]):
285
- # If no flags are present, just return none
290
+ # Extract the rmc flags from the toml, if any of the supported tables are present
291
+ rmc_data = dict ()
292
+ tables = ["workspace.metadata.rmc" , "package.metadata.rmc" , "rmc" ]
293
+ for table_name in tables :
294
+ table = data
295
+ for section in table_name .split ("." ):
296
+ table = table .get (section , dict ())
297
+ rmc_data .update (table )
298
+
299
+ if "flags" not in rmc_data :
286
300
return []
287
- rmc_data = data [ "rmc" ]
301
+
288
302
flag_data = rmc_data ["flags" ]
289
303
290
304
# Extract nested flags
291
305
flags = dict ()
292
306
293
- def find_flags (map ):
294
- for key in map :
295
- if isinstance (map [key ], dict ):
296
- find_flags (map [key ])
307
+ def find_flags (args ):
308
+ for key in args :
309
+ if isinstance (args [key ], dict ):
310
+ find_flags (args [key ])
297
311
else :
298
- flags [key ] = map [key ]
312
+ flags [key ] = args [key ]
299
313
find_flags (flag_data )
300
314
301
315
# Add config toml flags to flag list
Original file line number Diff line number Diff line change 24
24
//!
25
25
//! Speical [id]s include:
26
26
//! 1. [Empty] and [Nil] behaves like [null].
27
- #![ feature( rustc_private) ]
28
27
29
28
mod env;
30
29
pub mod goto_program;
@@ -36,7 +35,5 @@ pub use machine_model::{MachineModel, RoundingMode};
36
35
mod cbmc_string;
37
36
pub use cbmc_string:: { InternString , InternStringOption , InternedString } ;
38
37
39
- extern crate rustc_data_structures;
40
-
41
38
// Rust has difficulty resolving types for None option values: this gives rustc a hint.
42
39
pub const NO_PRETTY_NAME : Option < InternedString > = None ;
Original file line number Diff line number Diff line change 5
5
#![ feature( crate_visibility_modifier) ]
6
6
#![ feature( extern_types) ]
7
7
#![ feature( in_band_lifetimes) ]
8
- #![ feature( iter_zip) ]
9
8
#![ feature( nll) ]
10
9
#![ recursion_limit = "256" ]
11
- #![ feature( destructuring_assignment) ]
12
10
#![ feature( box_patterns) ]
13
11
#![ feature( once_cell) ]
14
12
#![ feature( rustc_private) ]
Original file line number Diff line number Diff line change
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
3
+ [package ]
4
+ name = " check-config"
5
+ version = " 0.1.0"
6
+ edition = " 2018"
7
+
8
+ [dependencies ]
9
+
10
+ [package .metadata .rmc ]
11
+ flags ={unwind = " 5" , unwinding-checks = false , function =" check_config" }
12
+
Original file line number Diff line number Diff line change
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3
+
4
+ //! This testcase requires an unwind threshold of less than 10 and no-unwind-checks in order to
5
+ //! succeed. These parameters are set inside Cargo.toml.
6
+
7
+ #[ cfg( rmc) ]
8
+ mod rmc_tests {
9
+ #[ rmc:: proof]
10
+ fn check_config ( ) {
11
+ let mut counter = 0 ;
12
+ while rmc:: any ( ) {
13
+ counter += 1 ;
14
+ assert ! ( counter < 10 , "Cargo.toml should've configure rmc to stop at iteration 5" ) ;
15
+ }
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments