forked from OERV-BSP/u-boot
test/py: Add tests for the SquashFS commands
Add Python scripts to test 'ls' and 'load' commands. The scripts generate a SquashFS image and clean the directory after the assertions, or if an exception is raised. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
This commit is contained in:
committed by
Tom Rini
parent
02c366b5d5
commit
f428e33b6b
42
test/py/tests/test_fs/test_squashfs/sqfs_common.py
Normal file
42
test/py/tests/test_fs/test_squashfs/sqfs_common.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2020 Bootlin
|
||||
# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
|
||||
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
|
||||
def sqfs_get_random_letters(size):
|
||||
letters = []
|
||||
for i in range(0, size):
|
||||
letters.append(random.choice(string.ascii_letters))
|
||||
|
||||
return ''.join(letters)
|
||||
|
||||
def sqfs_generate_file(path, size):
|
||||
content = sqfs_get_random_letters(size)
|
||||
file = open(path, "w")
|
||||
file.write(content)
|
||||
file.close()
|
||||
|
||||
# generate image with three files and a symbolic link
|
||||
def sqfs_generate_image():
|
||||
src = "test/py/tests/test_fs/test_squashfs/sqfs_src/"
|
||||
dest = "test/py/tests/test_fs/test_squashfs/sqfs"
|
||||
os.mkdir(src)
|
||||
sqfs_generate_file(src + "frag_only", 100)
|
||||
sqfs_generate_file(src + "blks_frag", 5100)
|
||||
sqfs_generate_file(src + "blks_only", 4096)
|
||||
os.symlink("frag_only", src + "sym")
|
||||
os.system("mksquashfs " + src + " " + dest + " -b 4096 -always-use-fragments")
|
||||
|
||||
# removes all files created by sqfs_generate_image()
|
||||
def sqfs_clean():
|
||||
src = "test/py/tests/test_fs/test_squashfs/sqfs_src/"
|
||||
dest = "test/py/tests/test_fs/test_squashfs/sqfs"
|
||||
os.remove(src + "frag_only")
|
||||
os.remove(src + "blks_frag")
|
||||
os.remove(src + "blks_only")
|
||||
os.remove(src + "sym")
|
||||
os.rmdir(src)
|
||||
os.remove(dest)
|
||||
Reference in New Issue
Block a user