提交 0c3fe3cb 编写于 作者: C cuixucui

Code specification rectification

上级 71eb5cb5
......@@ -27,24 +27,24 @@ class Client(object):
"""
upload client
"""
def __init__(self, host, id):
def __init__(self, host, oec_id):
self.host = host
self.id = id
self.id = oec_id
self.form = {}
def upload(self, file, server='localhost'):
def upload(self, files, server='localhost'):
"""
upload client request
:param file:
:param files:
:param server:
:return:
"""
filename = os.path.basename(file)
filename = os.path.basename(files)
try:
job = filename.split('.')[0]
with open(file, 'rb') as f:
with open(files, 'rb') as f:
filetext = base64.b64encode(f.read())
except Exception as e:
except IOError as e:
print(e)
return False
......@@ -70,7 +70,7 @@ class Client(object):
print("Error: upload failed, %s" % res.msg)
return False
return True
except Exception as e:
except HTTPError as e:
print(e)
return False
......@@ -78,6 +78,5 @@ class Client(object):
if __name__ == '__main__':
c = Client(' Taishan 2280', ' Testid-123523')
import sys
file = sys.argv[1]
c.upload(file)
file_name = sys.argv[1]
c.upload(file_name)
......@@ -15,7 +15,7 @@
import json
from .commandUI import CommandUI
from .command import Command, CertCommandError
from .command import Command
from .device import Device
from .sysinfo import SysInfo
from .env import CertEnv
......
......@@ -56,7 +56,6 @@ class Job(object):
"""
discover test
:param testname:
:param device:
:param subtests_filter:
:return:
"""
......@@ -84,7 +83,7 @@ class Job(object):
for thing in dir(module):
test_class = getattr(module, thing)
try:
from types import ClassType as ct
from types import ClassType as classtype
except ImportError:
ct = type
if isinstance(test_class, ct) and issubclass(test_class, Test):
......@@ -111,7 +110,7 @@ class Job(object):
self.test_suite = []
for test in self.test_factory:
if test["run"]:
testclass = self.discover(test["name"], test["device"], subtests_filter)
testclass = self.discover(test["name"], subtests_filter)
if testclass:
testcase = dict()
testcase["test"] = testclass
......@@ -165,6 +164,8 @@ class Job(object):
name = testcase["name"] + "-" + testcase["device"].get_name()
logname = name + ".log"
reboot = None
test = None
logger = None
try:
test = testcase["test"]
logger = Logger(logname, self.job_id, sys.stdout, sys.stderr)
......@@ -253,4 +254,3 @@ class Job(object):
for testcase in self.test_suite:
if test["name"] == testcase["name"] and test["device"].path == testcase["device"].path:
test["status"] = testcase["status"]
......@@ -17,7 +17,7 @@ class Test(object):
"""
Test set template
"""
def __init__(self, name=None):
def __init__(self):
self.pri = 0
self.requirements = list()
self.reboot = False
......
......@@ -31,4 +31,4 @@ class AcpiTest(Test):
return True
except CertCommandError as e:
print(e)
return False
\ No newline at end of file
return False
......@@ -144,11 +144,12 @@ class CDRomTest(Test):
else:
print("Blanking ...")
sys.stdout.flush()
blankCommand = Command("cdrecord -v dev=%s blank=fast" % devname).echo()
# blankCommand = Command("cdrecord -v dev=%s blank=fast" % devname).echo()
Command("cdrecord -v dev=%s blank=fast" % devname).echo()
self.reload_disc(devname)
sys.stdout.flush()
return self.write_test()
except CertCommandError as e:
except CertCommandError:
return False
def write_test(self):
......@@ -165,15 +166,17 @@ class CDRomTest(Test):
sys.stdout.flush()
return True
else:
write_opts ="-sao"
write_opts = "-sao"
try:
command = Command("cdrecord dev=%s -checkdrive" % devname)
modes = command.get_str(regex="^Supported modes[^:]*:(?P<modes>.*$)", regex_group="modes", single_line=False, ignore_errors=True)
modes = command.get_str(regex="^Supported modes[^:]*:(?P<modes>.*$)", regex_group="modes",
single_line=False, ignore_errors=True)
if "TAO" in modes:
write_opts="-tao"
write_opts = "-tao"
if "SAO" in modes:
write_opts="-sao"
flags = command.get_str(regex="^Driver flags[^:]*:(?P<flags>.*$)", regex_group="flags", single_line=False, ignore_errors=True)
write_opts = "-sao"
flags = command.get_str(regex="^Driver flags[^:]*:(?P<flags>.*$)", regex_group="flags",
single_line=False, ignore_errors=True)
if "BURNFREE" in flags:
write_opts += " driveropts=burnfree"
except CertCommandError as e:
......@@ -182,11 +185,12 @@ class CDRomTest(Test):
size = Command("mkisofs -quiet -R -print-size %s " % self.test_dir).get_str()
blocks = int(size)
Command("mkisofs -quiet -R %s | cdrecord -v %s dev=%s fs=32M tsize=%ss -" % (self.test_dir, write_opts, devname, blocks)).echo()
Command("mkisofs -quiet -R %s | cdrecord -v %s dev=%s fs=32M tsize=%ss -" %
(self.test_dir, write_opts, devname, blocks)).echo()
self.reload_disc(devname)
sys.stdout.flush()
return True
except CertCommandError as e:
except CertCommandError:
return False
def read_test(self):
......@@ -244,7 +248,7 @@ class CDRomTest(Test):
try:
Command("diff -r %s %s" % (dir1, dir2)).run()
return True
except CertCommandError as e:
except CertCommandError:
print("Error: file comparison failed.")
return False
......@@ -263,17 +267,16 @@ class CDRomTest(Test):
Command("eject %s" % device).run()
print("tray ejected.")
sys.stdout.flush()
except CertCommandError as e:
except CertCommandError:
pass
try:
Command("eject -t %s" % device).run()
print("tray auto-closed.\n")
sys.stdout.flush()
except CertCommandError as e:
except CertCommandError:
print("Could not auto-close the tray, please close the tray manually.")
self.ui.prompt_confirm("Done well?")
time.sleep(20)
return True
......@@ -20,7 +20,8 @@ def cal():
decimal.getcontext().prec = 1000
one = decimal.Decimal(1)
for i in range(1000):
j = (i * one).sqrt()
# j = (i * one).sqrt()
(i * one).sqrt()
if __name__ == '__main__':
......
......@@ -14,14 +14,12 @@
import os
import sys
import time
import shutil
import string
from hwcompatible.test import Test
from hwcompatible.command import Command, CertCommandError
from hwcompatible.commandUI import CommandUI
from hwcompatible.device import CertDevice, Device
from hwcompatible.device import CertDevice
class DiskTest(Test):
......@@ -32,7 +30,11 @@ class DiskTest(Test):
self.filesystems = ["ext4"]
self.ui = CommandUI()
def setup(self):
def setup(self, args=None):
"""
The Setup before testing
:return:
"""
try:
print("Disk Info:")
Command("fdisk -l").echo(ignore_errors=True)
......@@ -63,7 +65,7 @@ class DiskTest(Test):
self.disks.append("all")
disk = self.ui.prompt_edit("Which disk would you like to test: ", self.disks[0], self.disks)
return_code = True
if disk == "all":
if disk == "all":
for disk in self.disks[:-1]:
if not self.raw_test(disk):
return_code = False
......@@ -126,9 +128,9 @@ class DiskTest(Test):
device = "/dev/" + disk
if not os.path.exists(device):
print("Error: device %s not exists." % device)
proc_path="/sys/block/" + disk
proc_path = "/sys/block/" + disk
if not os.path.exists(proc_path):
proc_path="/sys/block/*/" + disk
proc_path = "/sys/block/*/" + disk
size = Command("cat %s/size" % proc_path).get_str()
size = int(size)/2
if size <= 0:
......@@ -160,9 +162,9 @@ class DiskTest(Test):
device = "/dev/" + disk
if not os.path.exists(device):
print("Error: device %s not exists." % device)
proc_path="/sys/block/" + disk
proc_path = "/sys/block/" + disk
if not os.path.exists(proc_path):
proc_path="/sys/block/*/" + disk
proc_path = "/sys/block/*/" + disk
size = Command("cat %s/size" % proc_path).get_str()
size = int(size)/2/2
if size <= 0:
......@@ -219,8 +221,5 @@ class DiskTest(Test):
return False
print("\n")
sys.stdout.flush()
bs = bs *2
bs = bs * 2
return True
......@@ -36,10 +36,9 @@ class MemoryTest(Test):
self.retry_list = list()
self.test_dir = os.path.dirname(os.path.realpath(__file__))
def setup(self, args=None):
def setup(self):
"""
Initialization before test
:param args:
:return:
"""
self.get_memory()
......
......@@ -12,11 +12,6 @@
# See the Mulan PSL v2 for more details.
# Create: 2020-04-01
import os
import argparse
from hwcompatible.test import Test
from hwcompatible.command import Command
from rdma import RDMATest
......
......@@ -17,7 +17,6 @@ import sys
import argparse
from hwcompatible.test import Test
from hwcompatible.command import Command, CertCommandError
from hwcompatible.device import CertDevice, Device
class NvmeTest(Test):
......@@ -117,4 +116,3 @@ class NvmeTest(Test):
return True
if os.system("pvs 2>/dev/null | grep -q '/dev/%s'" % disk) == 0:
return True
......@@ -22,6 +22,12 @@ class TapeTest(Test):
"""
Tape test
"""
def __init__(self):
Test.__init__(self)
self.args = None
self.device = None
self.tapeDevice = None
def setup(self, args=None):
"""
Initialization before test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册