1*9c5db199SXin Li# Lint as: python3 2*9c5db199SXin Li# Copyright 2020 The Chromium OS Authors. All rights reserved. 3*9c5db199SXin Li# Use of this source code is governed by a BSD-style license that can be 4*9c5db199SXin Li# found in the LICENSE file. 5*9c5db199SXin Li 6*9c5db199SXin Liimport glob 7*9c5db199SXin Liimport os 8*9c5db199SXin Li 9*9c5db199SXin Li# Relative to .star root (in autotest/files). 10*9c5db199SXin LiOUTPUT_FILE = "metadata/tests.star" 11*9c5db199SXin Li 12*9c5db199SXin LiHEADER = """# Copyright 2020 The Chromium OS Authors. All rights reserved. 13*9c5db199SXin Li# Use of this source code is governed by a BSD-style license that can be 14*9c5db199SXin Li# found in the LICENSE file. 15*9c5db199SXin Li 16*9c5db199SXin LiTESTS = [] 17*9c5db199SXin Lidef _append_tests(tests): 18*9c5db199SXin Li for t in tests: 19*9c5db199SXin Li TESTS.append(t) 20*9c5db199SXin Li""" 21*9c5db199SXin Li 22*9c5db199SXin LiTEMPLATE = """ 23*9c5db199SXin Liload("//{path}", {unique_name} = "TESTS") 24*9c5db199SXin Li_append_tests({unique_name}) 25*9c5db199SXin Li""" 26*9c5db199SXin Li 27*9c5db199SXin Lidef main(): 28*9c5db199SXin Li """Main entry point of this script.""" 29*9c5db199SXin Li root_dir = os.path.realpath( 30*9c5db199SXin Li os.path.join(os.path.realpath(__file__), "../../..")) 31*9c5db199SXin Li os.chdir(root_dir) 32*9c5db199SXin Li output = HEADER 33*9c5db199SXin Li for test_type in ["client", "server"]: 34*9c5db199SXin Li for path in glob.iglob(test_type + "/site_tests/*/*.star"): 35*9c5db199SXin Li head, file_name = os.path.split(path) 36*9c5db199SXin Li head, test_folder = os.path.split(head) 37*9c5db199SXin Li unique_name = "_".join( 38*9c5db199SXin Li [test_type, test_folder, file_name[:-len(".star")]]) 39*9c5db199SXin Li output += TEMPLATE.format(path=path, unique_name=unique_name) 40*9c5db199SXin Li 41*9c5db199SXin Li with open(OUTPUT_FILE, 'w') as fh: 42*9c5db199SXin Li fh.write(output) 43*9c5db199SXin Li print("Wrote output to", OUTPUT_FILE) 44*9c5db199SXin Li 45*9c5db199SXin Li 46*9c5db199SXin Liif __name__ == '__main__': 47*9c5db199SXin Li main() 48