forked from KolibriOS/kolibrios
[KERNEL][TEST] Embrase test code
git-svn-id: svn://kolibrios.org@9313 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f4d71d2b55
commit
16fd3a9980
@ -75,78 +75,78 @@ def check_tools(tools):
|
|||||||
draw_line()
|
draw_line()
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Check available tools
|
||||||
|
tools = (("mcopy", "mtools"),
|
||||||
|
("qemu-system-i386", "qemu-system-x86"),
|
||||||
|
("wget", "wget"),
|
||||||
|
("fasm", "fasm"))
|
||||||
|
check_tools(tools)
|
||||||
|
|
||||||
# Check available tools
|
# Get IMG
|
||||||
tools = (("mcopy", "mtools"),
|
if not os.path.exists("kolibri_test.img"):
|
||||||
("qemu-system-i386", "qemu-system-x86"),
|
if len(sys.argv) == 1:
|
||||||
("wget", "wget"),
|
execute("wget -q --show-progress http://builds.kolibrios.org/eng/data/data/kolibri.img -O kolibri_test.img")
|
||||||
("fasm", "fasm"))
|
else:
|
||||||
check_tools(tools)
|
builds_eng = sys.argv[1]
|
||||||
|
execute(f"cp {builds_eng}/data/data/kolibri.img kolibri_test.img")
|
||||||
|
|
||||||
# Get IMG
|
# Remove old kernel (may fail if we removed it before so no check here)
|
||||||
if not os.path.exists("kolibri_test.img"):
|
os.system("mdel -i kolibri_test.img ::kernel.mnt > /dev/null")
|
||||||
if len(sys.argv) == 1:
|
|
||||||
execute("wget -q --show-progress http://builds.kolibrios.org/eng/data/data/kolibri.img -O kolibri_test.img")
|
|
||||||
else:
|
|
||||||
builds_eng = sys.argv[1]
|
|
||||||
execute(f"cp {builds_eng}/data/data/kolibri.img kolibri_test.img")
|
|
||||||
|
|
||||||
# Remove old kernel (may fail if we removed it before so no check here)
|
# Check free space after kernel remove
|
||||||
os.system("mdel -i kolibri_test.img ::kernel.mnt > /dev/null")
|
free_clusters = int(subprocess.check_output("mdu -i kolibri_test.img :: -s", shell=True).split()[-1])
|
||||||
|
floppy_image_clusters = 2880
|
||||||
|
if floppy_image_clusters - free_clusters < 500:
|
||||||
|
# Remove unuseful files from IMG if lesser than 500 sectors
|
||||||
|
execute("mdeltree -i kolibri_test.img ::GAMES", mute = True)
|
||||||
|
execute("mdeltree -i kolibri_test.img ::DEMOS", mute = True)
|
||||||
|
execute("mdeltree -i kolibri_test.img ::3D", mute = True)
|
||||||
|
|
||||||
# Check free space after kernel remove
|
# Get test kernel
|
||||||
free_clusters = int(subprocess.check_output("mdu -i kolibri_test.img :: -s", shell=True).split()[-1])
|
if not os.path.exists("kernel.mnt.pretest"):
|
||||||
floppy_image_clusters = 2880
|
if len(sys.argv) == 1:
|
||||||
if floppy_image_clusters - free_clusters < 500:
|
with open("lang.inc", "w") as lang_inc:
|
||||||
# Remove unuseful files from IMG if lesser than 500 sectors
|
lang_inc.write("lang fix en\n")
|
||||||
execute("mdeltree -i kolibri_test.img ::GAMES", mute = True)
|
execute("fasm bootbios.asm bootbios.bin.pretest -dpretest_build=1")
|
||||||
execute("mdeltree -i kolibri_test.img ::DEMOS", mute = True)
|
execute("fasm -m 65536 kernel.asm kernel.mnt.pretest -dpretest_build=1 -ddebug_com_base=0xe9")
|
||||||
execute("mdeltree -i kolibri_test.img ::3D", mute = True)
|
else:
|
||||||
|
builds_eng = sys.argv[1]
|
||||||
|
execute(f"cp {builds_eng}/data/kernel/trunk/kernel.mnt.pretest kernel.mnt.pretest", mute = True)
|
||||||
|
|
||||||
# Get test kernel
|
# Put the kernel into IMG
|
||||||
if not os.path.exists("kernel.mnt.pretest"):
|
execute("mcopy -D o -i kolibri_test.img kernel.mnt.pretest ::kernel.mnt", mute = True)
|
||||||
if len(sys.argv) == 1:
|
|
||||||
with open("lang.inc", "w") as lang_inc:
|
|
||||||
lang_inc.write("lang fix en\n")
|
|
||||||
execute("fasm bootbios.asm bootbios.bin.pretest -dpretest_build=1")
|
|
||||||
execute("fasm -m 65536 kernel.asm kernel.mnt.pretest -dpretest_build=1 -ddebug_com_base=0xe9")
|
|
||||||
else:
|
|
||||||
builds_eng = sys.argv[1]
|
|
||||||
execute(f"cp {builds_eng}/data/kernel/trunk/kernel.mnt.pretest kernel.mnt.pretest", mute = True)
|
|
||||||
|
|
||||||
# Put the kernel into IMG
|
# Collect tests from test folder (not recursively yet)
|
||||||
execute("mcopy -D o -i kolibri_test.img kernel.mnt.pretest ::kernel.mnt", mute = True)
|
for test_folder in os.listdir("test"):
|
||||||
|
test_folder_path = f"test/{test_folder}"
|
||||||
|
test_file = f"{test_folder_path}/test.py"
|
||||||
|
|
||||||
# Collect tests from test folder (not recursively yet)
|
if not os.path.isdir(test_folder_path):
|
||||||
for test_folder in os.listdir("test"):
|
continue
|
||||||
test_folder_path = f"test/{test_folder}"
|
|
||||||
test_file = f"{test_folder_path}/test.py"
|
|
||||||
|
|
||||||
if not os.path.isdir(test_folder_path):
|
if os.path.exists(test_file):
|
||||||
continue
|
tests.append(test_folder_path)
|
||||||
|
|
||||||
if os.path.exists(test_file):
|
# Execute each test
|
||||||
tests.append(test_folder_path)
|
test_number = 1
|
||||||
|
for test in tests:
|
||||||
|
test_dir = f"{root_dir}/{test}"
|
||||||
|
|
||||||
# Execute each test
|
os.chdir(test_dir)
|
||||||
test_number = 1
|
print(f"[{test_number}/{len(tests)}] {test}... ", end = "", flush=True)
|
||||||
for test in tests:
|
start = timeit.default_timer()
|
||||||
test_dir = f"{root_dir}/{test}"
|
try:
|
||||||
|
SourceFileLoader("test", "test.py").load_module().run()
|
||||||
|
except common.TestTimeoutException:
|
||||||
|
result = "TIMEOUT"
|
||||||
|
except common.TestFailureException:
|
||||||
|
result = "FAILURE"
|
||||||
|
else:
|
||||||
|
result = "SUCCESS"
|
||||||
|
finish = timeit.default_timer()
|
||||||
|
print(f"{result} ({finish - start:.2f} seconds)")
|
||||||
|
os.chdir(root_dir)
|
||||||
|
|
||||||
os.chdir(test_dir)
|
test_number += 1
|
||||||
print(f"[{test_number}/{len(tests)}] {test}... ", end = "", flush=True)
|
|
||||||
start = timeit.default_timer()
|
|
||||||
try:
|
|
||||||
SourceFileLoader("test", "test.py").load_module().run()
|
|
||||||
except common.TestTimeoutException:
|
|
||||||
result = "TIMEOUT"
|
|
||||||
except common.TestFailureException:
|
|
||||||
result = "FAILURE"
|
|
||||||
else:
|
|
||||||
result = "SUCCESS"
|
|
||||||
finish = timeit.default_timer()
|
|
||||||
print(f"{result} ({finish - start:.2f} seconds)")
|
|
||||||
os.chdir(root_dir)
|
|
||||||
|
|
||||||
test_number += 1
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user