From: Abuzar Maqsood Date: Tue, 11 Feb 2025 05:40:22 +0000 (+0530) Subject: [TCT][scripts][Non-ACR] Script to show purpose in report page X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_9.0;p=test%2Ftct%2Fnative%2Fapi.git [TCT][scripts][Non-ACR] Script to show purpose in report page Change-Id: Ifea7dedcf7fafb6a56ee0095560ae2a73a085932 Signed-off-by: Abuzar Maqsood (cherry picked from commit f421bff1105fd3d41627cbd19ea61aedf5c3e075) --- diff --git a/scripts_tpk/tctestsgen.py b/scripts_tpk/tctestsgen.py index fe7bde086..f98ea0525 100755 --- a/scripts_tpk/tctestsgen.py +++ b/scripts_tpk/tctestsgen.py @@ -35,7 +35,6 @@ def gen(tcfile): set='' tfile=open(TFILE) fil=open(FILE, 'w') - # begin fil.write('\n') fil.write(' \n') @@ -56,9 +55,63 @@ def gen(tcfile): for element in feature: fil.write(' \n') fil.write(' \n') + tcname=fields[0] tcname=tcname.strip() + tcpurpose='' + + script_dir = os.path.dirname(os.path.abspath(__file__)) + api_dir = os.path.dirname(script_dir) + path_to_tc = os.path.join(api_dir, f'src/{BUILD_TYPE}/{MODULE_NAME}') + + if os.path.isdir(path_to_tc): + c_files = [f for f in os.listdir(path_to_tc) if f.endswith('.c')] + if c_files: + grep_command = ['grep', '-B', '20', '-w', tcname] + [os.path.join(path_to_tc, f) for f in c_files] + else: + return + else: + return + + try: + result = subprocess.run(grep_command, capture_output=True, text=True, check=True) + except subprocess.CalledProcessError as e: + print("Command failed with error: " + e.stderr + "\n") + + except Exception as e: + print("An unexpected error occurred: " + str(e) + "\n") + + output = result.stdout.strip() + lines = output.split('\n') + reversed_output = '\n'.join(reversed(lines)) + + purpose_pattern = re.compile(r'//& purpose:\s*(.*)') + description_pattern = re.compile(r'\* @description\s*(.*)') + + purpose_match = purpose_pattern.search(reversed_output) + if purpose_match: + tcpurpose = purpose_match.group(1).strip() + if tcpurpose.startswith('/'): + tcpurpose = "" + if tcpurpose == "": + description_match = description_pattern.search(reversed_output) + if description_match: + tcpurpose = description_match.group(1).strip() + else: + tcpurpose = "" + if tcpurpose.startswith('/'): + tcpurpose = "" + + pattern = r'[&]' + tcpurpose = re.sub(pattern, '&', tcpurpose) + pattern = r'[<]' + tcpurpose = re.sub(pattern, '<', tcpurpose) + pattern = r'[>]' + tcpurpose = re.sub(pattern, '>', tcpurpose) + pattern = r'["]' + tcpurpose = re.sub(pattern, '"', tcpurpose) + fil.write(' \n') fil.write(' \n') fil.write(' '+'{DEVICE_SUITE_TARGET_30}/external_wrapper.sh '+MODULE_FULL_NAME+' '+tcname+' '+BUILD_TYPE+'\n') @@ -184,4 +237,4 @@ if os.path.exists('exclude.list'): shutil.copy(NEWFILE,TFILE) #####exclude.list##### -gen(TFILE) +gen(TFILE) \ No newline at end of file