Modify for TCselector Buil Tool performance improve. 15/245815/1
authorYoungGun Chun <jykeon@samsung.com>
Fri, 16 Oct 2020 05:34:35 +0000 (14:34 +0900)
committerYoungGun Chun <jykeon@samsung.com>
Fri, 16 Oct 2020 05:34:35 +0000 (14:34 +0900)
It is improve build scheme based on efl-test-suite path and error handling.

Change-Id: I4c82b2daab26b066bc6bba5aa475b262f258910a

TCSelector-Build/main.py
TCSelector-Build/selector.py
TCSelector-Build/setup.py

index 31b630b05d941dc72c9471dc7ab4e449a01769df..d913fba88df38956e7a988339dc693277c602ae8 100755 (executable)
@@ -1,68 +1,28 @@
 from logger import Logger
 from gbsbuild import GBSBuild
 from setup import Setup
-from selector import Selector
-import os
+from execute import ExecuteRun
 import readline
 
 
 class app:
-    """ This class takes care of user input and use other modules to do everything"""
+    """
+        This class takes care of user input and use other modules to do everything
+    """
 
-    srcpath = ''
     dstpath = '/tmp/'
-    tcs_list = list()
-    """We setup the working directory by using Setup object."""
-
-    def setupworkingenvironment(self):
-        Setup.start(self.srcpath, self.dstpath)
 
     def showhelp(self):
         print('\nCommands:')
-        print('\n\tbuild                     To do gbs build')
-        print('\tbuild clean               To do clean gbs build')
-        print('\tbuild custom               To do custom gbs build')
-        print('\thelp                      To show the help commands')
-        print('\texit                      Exit from the program')
+        print('\n\tbuild                          To do gbs build')
+        print('\tbuild clean                    To do clean gbs build')
+        print('\tbuild custom                   To do custom gbs build')
+        print('\trun <device name>              To execute TCs on device(mobile,wear,rpi), e.g. run mobile')
+        print('\thelp/?                         To show the help commands')
+        print('\tquit/q                         Exit from the program')
         print('\n')
 
-    def processuserinput(self):
-        self.srcpath = input('Enter the path of efl-test-suite: ')
-        while not os.path.isdir(self.srcpath):
-            self.srcpath = input("Path not found!!.. Re-Enter the source path: ")
-
-        self.srcpath = self.srcpath.strip()
-        Logger.warning('path entered: ' + self.srcpath)
-        tclist = input(
-            'Enter the list of TCs to be built(separated by comma, e.g. utc_elm_panes_content_left_size_get_set.c, '
-            'utc_edje_edit_part_exist.c): ')
-        Logger.warning('TCs selected: ' + tclist)
-        self.tcs_list = tclist.split(',')
-
-        self.setupworkingenvironment()
-        index = 0
-        for tc in self.tcs_list:
-            self.tcs_list[index] = tc.strip()
-            index = index + 1
-
-        tmp_list = self.tcs_list
-        for tc in tmp_list:
-            index = tmp_list.index(tc)
-            if Selector.does_tc_exist(tc, self.dstpath):
-                Logger.info(tc + ': added.')
-            else:
-                while True:
-                    testcase = tc
-                    Logger.critical(testcase + ': does not exist')
-                    testcase = input('Enter the incorrect/empty TC again: ')
-                    testcase = testcase.strip()
-                    Logger.warning('TC selected: ' + testcase)
-                    if Selector.does_tc_exist(testcase, self.dstpath):
-                        Logger.info(testcase + ': added.')
-                        self.tcs_list[index] = testcase
-                        break
-
-        self.showhelp()
+        showhelp_again = False
 
         while True:
 
@@ -70,18 +30,32 @@ class app:
             commandentered = commandentered.strip()
 
             if commandentered == 'build':
+                Setup.verifyInputPath(self.dstpath)
                 GBSBuild.build(self.dstpath + 'efl-test-suite/')
             elif commandentered == 'build clean':
+                Setup.verifyInputPath(self.dstpath)
                 GBSBuild.buildclean(self.dstpath + 'efl-test-suite/')
             elif commandentered == 'build custom':
+                Setup.verifyInputPath(self.dstpath)
                 GBSBuild.buildcustom(self.dstpath + 'efl-test-suite/')
-            elif commandentered == 'help':
-                self.showhelp()
-            elif commandentered == 'exit':
+            elif commandentered == 'run mobile':
+                ExecuteRun.run('mobile')
+            elif commandentered == 'run wear':
+                ExecuteRun.run('wear')
+            elif commandentered == 'run rpi':
+                ExecuteRun.run('rpi')
+            elif commandentered == 'help' or commandentered == '?':
+                showhelp_again = True
+                break
+            elif commandentered == 'q' or commandentered == 'quit':
                 break
+            else:
+                Logger.error('Enter the valid command')
+
+        if showhelp_again == True:
+            self.showhelp()
 
 
 if __name__ == '__main__':
     App = app()
-
-    App.processuserinput()
+    App.showhelp()
index 64a0bd0c7850ba5ec3377fd1c6c387355c355f16..3ca32884b1ad48775f09cd0836e790a3762b899b 100755 (executable)
@@ -3,14 +3,42 @@ import os
 
 
 class selector:
-    tc_name = ''
+
     path_elements_list = list()
     path = ''
+    tcs_list = list()
+
+    def inputTcFromUser(self, dst_path):
+        tclist = input(
+            'Enter the list of TCs to be built(separated by comma, e.g. utc_elm_panes_content_left_size_get_set.c, '
+            'utc_edje_edit_part_exist.c): ')
+        Logger.warning('TCs selected: ' + tclist)
+        self.tcs_list = tclist.split(',')
+        index = 0
+        for tc in self.tcs_list:
+            self.tcs_list[index] = tc.strip()
+            index = index + 1
+
+        tmp_list = self.tcs_list
+        for tc in tmp_list:
+            index = tmp_list.index(tc)
+            if self.does_tc_exist(tc, dst_path):
+                Logger.info(tc + ': added.')
+            else:
+                testcase = tc
+                while True:
+                    Logger.critical(testcase + ': does not exist')
+                    testcase = input('Enter the incorrect/empty TC again: ')
+                    testcase = testcase.strip()
+                    Logger.warning('TC selected: ' + testcase)
+                    if self.does_tc_exist(testcase, dst_path):
+                        Logger.info(testcase + ': added.')
+                        self.tcs_list[index] = testcase
+                        break
 
     def does_tc_exist(self, testcase, dst_path):
-        self.tc_name = testcase
-        os.chdir(dst_path + "/efl-test-suite")
-        stream = os.popen("find . -name " + self.tc_name)
+        os.chdir(dst_path)
+        stream = os.popen("find . -name " + testcase)
         output = stream.read().strip()
         if len(output) != 0:
             self.set_tslist_path(testcase, output)
@@ -21,11 +49,11 @@ class selector:
 
     def set_tslist_path(self, testcase, output):
         self.path_elements_list = output.split('/')
-        index = self.path_elements_list.index(self.tc_name)
+        index = self.path_elements_list.index(testcase)
         self.path = "/".join(self.path_elements_list[1:index])
         os.chdir(os.getcwd() + "/" + self.path)
-        Logger.info("TC " + self.tc_name + " added into tslist ")
-        self.tslist_entry(self.tc_name)
+        Logger.info("TC " + testcase + " added into tslist ")
+        self.tslist_entry(testcase)
 
     def tslist_entry(self, testcase):
         file = open('tslist', 'a')
index 67a44b3d14a2c07ac38fe8b2ca7ed9191648541d..ad3f819d533951ef3a30aaf5d154c0727d1001e2 100755 (executable)
@@ -1,33 +1,42 @@
 import os
 from logger import Logger
+from util import util
+from selector import Selector
 
 
 class setup:
 
-       def start(self, src_path, dest_path):
-               if os.path.isfile('/tmp/tslist'):
-                       os.system('rm -rf /tmp/tslist')
-               if os.path.isdir(dest_path + '/efl-test-suite'):
-                       os.system('rm -rf ' + dest_path + '/efl-test-suite')
+    def verifyInputPath(self, dest_path):
+        src_path = input('Enter the path of efl-test-suite: ')
+        while True:
+            src_path = util.expanduser(src_path)
+            if not os.path.isdir(src_path):
+                src_path = input("Path not found!!.. Re-Enter the source path: ")
+            else:
+                Logger.warning('path entered: ' + src_path)
+                break
+        self.start(src_path, dest_path)
 
-               os.system("touch /tmp/tslist")
+    def start(self, src_path, dest_path):
+        if os.path.isfile('/tmp/tslist'):
+            os.system('rm -rf /tmp/tslist')
+        if os.path.isdir(dest_path + '/efl-test-suite'):
+            os.system('rm -rf ' + dest_path + '/efl-test-suite')
 
-               Logger.info('Copying... ' + src_path + ' to ' + dest_path)
+        os.system("touch /tmp/tslist")
 
-               os.system("cp " + src_path + " " + dest_path + " -rf")
-               dest_path += 'efl-test-suite/'
-               os.chdir(dest_path)
+        Logger.info('Copying... ' + src_path + ' to ' + dest_path)
 
-               os.system("find . -name tslist  | xargs -n 1 cp -v /tmp/tslist > /dev/null")
-               Logger.info('Copying done to ' + dest_path)
+        os.system("cp " + src_path + " " + dest_path + " -rf")
+        dest_path += 'efl-test-suite/'
+        os.chdir(dest_path)
 
+        os.system("find . -name tslist  | xargs -n 1 cp -v /tmp/tslist > /dev/null")
+        Logger.info('Copying done to ' + dest_path)
+        Selector.inputTcFromUser(dest_path)
 
-Setup = setup()
 
+Setup = setup()
 
 if __name__ == '__main__':
-    src_path = input("Enter the source path: ")
-    while os.path.isdir(src_path) == False:
-        src_path = input("Path not found!!.. Re-Enter the source path: ")
-
-       #Setup.start(src_path, dest_path)
+    Setup.start(src_path, dest_path)