File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use crate::system_config::SystemConfig;
44
55mod amdaemon;
66mod loading;
7+ mod platform;
78
89crate :: config_section! {
910 pub struct TestSectionConfig => TEST_SECTION {
Original file line number Diff line number Diff line change @@ -76,14 +76,4 @@ fn required_internal_sections_are_not_emitted() {
7676 assert ! ( output. contains( "[PCBID]" ) ) ;
7777 assert ! ( output. contains( "[VFS]" ) ) ;
7878 assert ! ( output. contains( "[SliderDevice]" ) ) ;
79- assert ! ( !output
80- . split( "[PCBID]" )
81- . nth( 1 )
82- . unwrap( )
83- . starts_with( "\n Enable" ) ) ;
84- assert ! ( !output
85- . split( "[VFS]" )
86- . nth( 1 )
87- . unwrap( )
88- . starts_with( "\n Enable" ) ) ;
8979}
Original file line number Diff line number Diff line change 1+ use super :: Config ;
2+
3+ #[ test]
4+ fn platform_hook_sections_are_public_and_enabled_by_default ( ) {
5+ // Given: 用户没有覆盖平台 hook 的默认状态。
6+ let config = Config :: parse ( "." , "ConfigVersion = 1\n " ) . expect ( "测试配置必须有效" ) ;
7+
8+ // When: 配置被规范化保存。
9+ let output = config. to_toml ( ) ;
10+
11+ // Then: VFS 与 PCBID 都公开默认启用开关。
12+ assert ! ( output. contains( "[PCBID]\n Enable = true\n " ) ) ;
13+ assert ! ( output. contains( "[VFS]\n Enable = true\n " ) ) ;
14+ }
15+
16+ #[ test]
17+ fn platform_hook_modules_follow_explicit_enable_state ( ) {
18+ // Given: 用户明确关闭 VFS 与 PCBID hook。
19+ let config = Config :: parse (
20+ "." ,
21+ "ConfigVersion = 1\n [PCBID]\n Enable = false\n [VFS]\n Enable = false\n " ,
22+ )
23+ . expect ( "测试配置必须有效" ) ;
24+
25+ // When: 模块注册表计算两个 init 的启用状态。
26+ let modules = crate :: module_registry:: registered_modules ( ) ;
27+ let pcbid = modules
28+ . iter ( )
29+ . find ( |module| module. name . ends_with ( "platform::pcbid::init" ) )
30+ . expect ( "PCBID 模块必须完成注册" ) ;
31+ let vfs = modules
32+ . iter ( )
33+ . find ( |module| module. name . ends_with ( "platform::vfs::init" ) )
34+ . expect ( "VFS 模块必须完成注册" ) ;
35+
36+ // Then: 两个 hook 初始化入口都被配置门控阻止。
37+ assert ! ( !( pcbid. enabled) ( & config) ) ;
38+ assert ! ( !( vfs. enabled) ( & config) ) ;
39+ }
Original file line number Diff line number Diff line change @@ -19,8 +19,7 @@ crate::config_section! {
1919 order: 960 ,
2020 default_on: true ,
2121 always_enabled: false ,
22- hidden: true ,
23- export: true ,
22+ hidden: false ,
2423 comment: "机台序列号模拟" ,
2524 fields: {
2625 pub serial_no: String = String :: from( "ACAE01A99999999" ) ,
Original file line number Diff line number Diff line change @@ -35,8 +35,7 @@ crate::config_section! {
3535 order: 970 ,
3636 default_on: true ,
3737 always_enabled: false ,
38- hidden: true ,
39- export: true ,
38+ hidden: false ,
4039 comment: "虚拟文件系统" ,
4140 fields: {
4241 pub amfs: String = String :: from( "amfs" ) ,
You can’t perform that action at this time.
0 commit comments