Skip to content

Commit

Permalink
Update btrfstests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewc12 committed Aug 3, 2023
1 parent aa2993a commit d0811ff
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions contrib/windows/tests/btrfstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@


def parse_arguments():
parser = argparse.ArgumentParser(description='Process command line arguments.')
parser = argparse.ArgumentParser(description='Process command line ' + \
'arguments.')
parser.add_argument('-path', type=dir_path, required=True)
return parser.parse_args()

Expand All @@ -30,7 +31,8 @@ def dir_path(path):
if os.path.isdir(path):
return path
else:
raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path")
raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid"
"path")


def get_DeviceId():
Expand All @@ -40,10 +42,11 @@ def get_DeviceId():
stderr=subprocess.PIPE
)

#https://github.com/sir-ragna/dddddd
#get DeviceId
# https://github.com/sir-ragna/dddddd
# get DeviceId

a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict').replace("\r\r\n", "\r\n")
a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict')
b = a.replace("\r\r\n", "\r\n")

c = a.splitlines()

Expand All @@ -53,17 +56,17 @@ def get_DeviceId():

e.sort()

#print(e)
# print(e)

#print([x.encode(encoding='UTF-8') for x in e])
# print([x.encode(encoding='UTF-8') for x in e])

#import csv
# import csv

#with open('csv_file.csv', 'w', encoding='UTF8') as f:
# writer = csv.writer(f, dialect='excel', quoting=csv.QUOTE_ALL)
#
# for row in e:
# writer.writerow([row])
# with open('csv_file.csv', 'w', encoding='UTF8') as f:
# writer = csv.writer(f, dialect='excel', quoting=csv.QUOTE_ALL)
#
# for row in e:
# writer.writerow([row])

return e

Expand All @@ -90,8 +93,7 @@ def get_driveletters():

# b'test01 H:\\ \r\ntest02 I:\\ \r\n'


a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict')
a = magic_number_process.stdout.decode(encoding='UTF-8', errors='strict')

c = a.splitlines()

Expand All @@ -110,19 +112,25 @@ def get_driveletters():

def create_pool(name, file):
magic_number_process = subprocess.run(
["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", "create", "-f", name, file],
["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", \
"create", "-f", name, file],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

return magic_number_process


def destroy_pool(name):
magic_number_process = subprocess.run(
["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", "destroy", "-f", name],
["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", \
"destroy", "-f", name],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

return magic_number_process


def zpool(*args):
magic_number_process = subprocess.run(
Expand All @@ -145,7 +153,8 @@ def zfs(*args):


def run(args):
d = {"zfs": "C:\\Program Files\\OpenZFS On Windows\\zfs.exe", "zpool": "C:\\Program Files\\OpenZFS On Windows\\zpool.exe"}
d = {"zfs": "C:\\Program Files\\OpenZFS On Windows\\zfs.exe", \
"zpool": "C:\\Program Files\\OpenZFS On Windows\\zpool.exe"}
l = list(args)
try:
cmd = d[l[0]]
Expand Down Expand Up @@ -219,15 +228,17 @@ def main():
for test in ['create', 'supersede', 'overwrite', 'open_id', 'io', 'mmap', 'rename', 'rename_ex', 'delete', 'delete_ex', 'links', 'links_ex', 'oplock_i', 'oplock_ii', 'oplock_batch', 'oplock_filter', 'oplock_r', 'oplock_rw', 'oplock_rh', 'oplock_rwh', 'cs', 'reparse', 'streams', 'fileinfo', 'ea']:
preTest(str(test) + " tests:")
f = PureWindowsPath(get_driveletters()[0][1])
ret = runWithPrint([str(p.joinpath("winbtrfs", "test.exe")), str(test), str(f)])
ret = runWithPrint([str(p.joinpath("winbtrfs", "test.exe")), \
str(test), str(f)])
time.sleep(10)
if ret.returncode != 0:
print("FAIL")
postTest()

print(ret.stdout.decode())

out = " ".join([str(test), ret.stdout.decode().splitlines()[-1]])
out = " ".join([str(test), \
ret.stdout.decode().splitlines()[-1]])

print(out)
log_file.write(out)
Expand All @@ -240,5 +251,6 @@ def main():

# delete_file(f1)


if __name__ == "__main__":
main()

0 comments on commit d0811ff

Please sign in to comment.