Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9922 → Rev 9923

/kernel/trunk/runtests.py
38,12 → 38,6
exit(-1)
 
 
def stage(name, command, mute=False):
print(f"{name}... ", end="")
execute(command, mute=mute)
print("Done.")
 
 
def download(link, path):
log(f"Downloading {path}... ", end="")
urllib.request.urlretrieve(link, path)
181,6 → 175,7
traceback.print_tb(exception.__traceback__)
print(f"\nQemu command:\n {exception.cmd()}\n")
 
 
def run_tests_serially(tests, root_dir):
thread = Thread(target=run_tests_serially_thread, args=(tests, root_dir))
thread.start()
187,147 → 182,25
return thread
 
 
def build_umka_asm(object_output_dir):
umka_o = f"{object_output_dir}/umka.o"
kolibri_kernel_trunk_runtests_py = os.path.abspath(__file__)
kolibri_kernel_trunk = os.path.dirname(kolibri_kernel_trunk_runtests_py)
kolibri_kernel = os.path.dirname(kolibri_kernel_trunk)
kolibrios_folder = os.path.dirname(kolibri_kernel)
def build_umka():
kolibrios_dir = os.path.abspath("../../")
env = os.environ
libcrash = "programs/develop/libraries/libcrash/hash"
env["INCLUDE"] = ""
env["INCLUDE"] += f"{kolibrios_folder}/kernel/trunk;"
env["INCLUDE"] += f"{kolibrios_folder}/{libcrash}"
command = "fasm "
command += "-dWIN32=1 " if sys.platform == "win32" else ""
command += "-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 "
command += "umka/umka.asm umka/build/umka.o -s umka/build/umka.fas "
command += "-m 2000000 "
print(command)
stdout = subprocess.check_output(command, shell=True, env=env)
print(stdout.decode("ascii"))
return umka_o
env["KOLIBRIOS"] = kolibrios_dir
env["HOST"] = "linux"
env["CC"] = "clang"
popen = subprocess.Popen(shlex.split("make -C umka umka_shell"), env = env)
if popen.wait() != 0:
subprocess.Popen(shlex.split("make -C umka clean"), env = env)
 
 
def cc(src, obj, include_path):
if tool_exists("i686-w64-mingw32-gcc"):
compiler = "i686-w64-mingw32-gcc"
elif tool_exists("clang"):
compiler = "clang"
else:
print("No compiler found to compile UMKa (tried i686-w64-mingw32-gcc and clang)")
print(" Please make sure you have installed llvm-mingw or clang")
print(" If they're installled consider updating PATH variable")
command = f"{compiler} "
command += "-Wno-everything -std=c11 -g -O0 -fno-pie -m32 -masm=intel -c "
command += "-D_FILE_OFFSET_BITS=64 -DNDEBUG -D_POSIX_C_SOURCE=200809L "
command += f"-I {include_path} {src} -o {obj}"
print(command)
if os.system(command) != 0:
exit()
 
 
def link(objects):
if tool_exists("i686-w64-mingw32-gcc"):
compiler = "i686-w64-mingw32-gcc"
elif tool_exists("clang"):
compiler = "clang"
else:
print("No compiler found to compile UMKa (tried i686-w64-mingw32-gcc and clang)")
print(" Please make sure you have installed llvm-mingw or clang")
print(" If they're installled consider updating PATH variable")
if sys.platform == "linux" or sys.platform == "linux2":
linker_script = "-T umka/umka.ld"
else:
linker_script = "-Wl,/ALIGN:65536 -Wl,/MAP:umka.map "
command = f"{compiler} "
command += "-Wno-everything "
command += f"-no-pie -m32 -o umka_shell.exe -static {linker_script} "
command += " ".join(objects)
print(command)
if os.system(command) != 0:
exit()
 
 
def build_umka():
if not use_umka:
return
 
os.makedirs("umka/build", exist_ok=True)
 
platform = "win32" if sys.platform == "win32" else "linux"
 
os.makedirs(f"umka/build/{platform}", exist_ok=True)
 
c_sources = [
"umka_shell.c",
"shell.c",
"trace.c",
"trace_lbr.c",
"vdisk.c",
"vnet.c",
"getopt.c",
"isatty.c",
"lodepng.c",
f"{platform}/pci.c",
f"{platform}/thread.c",
"util.c",
]
 
src_obj_pairs = [
(f"umka/{source}", f"umka/build/{source}.o") for source in c_sources
]
 
for src, obj in src_obj_pairs:
cc(src, obj, "umka/linux")
 
umka_o = build_umka_asm("umka/build")
 
objects = [obj for src, obj in src_obj_pairs] + [umka_o]
link(objects)
 
os.chdir("umka/test")
for test in [t for t in os.listdir(".") if t.endswith(".t")]:
out_log = f"{test[:-2]}.out.log"
ref_log = f"{test[:-2]}.ref.log"
cmd_umka = f"..{os.sep}..{os.sep}umka_shell.exe < {test} > {out_log}"
print(cmd_umka)
os.system(cmd_umka)
with open(out_log, "rb") as f:
crlf = bytes([0x0D, 0x0A])
lf = bytes([0x0A])
out_log_contents = f.read().replace(crlf, lf)
with open(out_log, "wb") as f:
f.write(out_log_contents)
with open(ref_log, "rb") as f:
ref_log_contents = f.read()
if out_log_contents != ref_log_contents:
print("FAILURE")
exit()
os.chdir("../../")
print("SUCCESS")
 
 
def download_umka():
if not use_umka:
return
 
if not os.path.exists("umka"):
if os.system("git clone https://github.com/KolibriOS/umka") != 0:
print("Couldn't clone UMKa repo")
exit()
os.chdir("umka")
if os.system("git checkout trunk") != 0:
print("Couldn't checkout trunk branch of UMKa")
exit()
os.system("git pull")
os.chdir("../")
 
 
def download_umka_imgs():
if not use_umka:
return
 
imgs = [
"fat32_test0.img",
"jfs.img",
354,15 → 227,19
root_dir = os.getcwd()
 
# Check available tools
tools = [["qemu-system-i386", "qemu-system-x86"],
["fasm", "fasm"]]
tools = [
["qemu-system-i386", "qemu-system-x86"],
["fasm", "fasm"],
["tup", "tup"],
]
if use_umka:
tools.append(["git", "git"]);
tools.append(["git", "git"])
tools.append(["make", "make"])
check_tools(tools)
 
prepare_test_img()
if use_umka:
download_umka()
download_umka_imgs()
build_umka()
tests = collect_tests()
serial_executor_thread = run_tests_serially(tests, root_dir)