Update test_passwd.py

This commit is contained in:
Feng Chao 2024-11-05 20:25:02 +08:00 committed by GitHub
parent 9003883edc
commit 0d5d88086a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 3 deletions

View File

@ -6,15 +6,37 @@ from frame.caseBase import *
from frame.epath import *
from frame import *
class TDTestCase(TBase):
def apiPath(self):
apiPath = None
currentFilePath = os.path.dirname(os.path.realpath(__file__))
if ("community/tests" in currentFilePath):
testFilePath = currentFilePath[:currentFilePath.find("community/tests")]
else:
testFilePath = currentFilePath[:currentFilePath.find("TDengine/tests")]
for root, dirs, files in os.walk(testFilePath):
if ("passwdTest.c" in files):
apiPath = root
break
return apiPath
def run(self):
c_file_path = os.sep.join([binPath(), "passwdTest localhost"])
p = subprocess.Popen(c_file_path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
apiPath = self.apiPath()
if apiPath:
p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if 0 != p.returncode:
tdLog.exit("Test script passwdTest.c make failed")
test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"])
else:
tdLog.exit("passwdTest.c not found")
p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if 0 != p.returncode:
tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err))
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())