@@ -1040,8 +1040,8 @@ def verify_help(node, s):
10401040""" )
10411041
10421042
1043- print ("Testing locations, source/rsource/gsource/grsource, and "
1044- "Kconfig.kconfig_filenames" )
1043+ print ("Testing locations, origins, source/rsource/gsource/grsource, "
1044+ "and Kconfig.kconfig_filenames" )
10451045
10461046 def verify_locations (nodes , * expected_locs ):
10471047 verify (len (nodes ) == len (expected_locs ),
@@ -1173,6 +1173,34 @@ def verify_locations(nodes, *expected_locs):
11731173 else :
11741174 fail ("'rsource' with missing file did not raise exception" )
11751175
1176+ # Tests origins
1177+
1178+ c = Kconfig ("tests/Korigins" , warn = False )
1179+ c .syms ["MAIN_FLAG_SELECT" ].set_value (2 , 'here' )
1180+
1181+ expected = [
1182+ ('MAIN_FLAG' , ('select' , ['MAIN_FLAG_SELECT' ])),
1183+ ('MAIN_FLAG_DEPENDENCY' ,
1184+ ('default' , (os .path .abspath ('Kconfiglib/tests/Korigins' ), 6 ))),
1185+ ('MAIN_FLAG_SELECT' , ('assign' , 'here' )),
1186+ ('SECOND_CHOICE' , ('default' , None )),
1187+ ('UNSET_FLAG' , ('unset' , None )),
1188+ ]
1189+
1190+ for node in c .node_iter (True ):
1191+ if not isinstance (node .item , Symbol ):
1192+ continue
1193+
1194+ if node .item .origin is None :
1195+ continue
1196+
1197+ exp_name , exp_origin = expected .pop (0 )
1198+ verify_equal (node .item .name , exp_name )
1199+ verify_equal (node .item .origin , exp_origin )
1200+
1201+ if len (expected ) != 0 :
1202+ fail ("origin test mismatch" )
1203+
11761204 # Test a tricky case involving symlinks. $srctree is tests/symlink, which
11771205 # points to tests/sub/sub, meaning tests/symlink/.. != tests/. Previously,
11781206 # using 'rsource' from a file sourced with an absolute path triggered an
0 commit comments