18,9 → 18,11 |
|
use_umka = False |
|
|
def log(s, end = "\n"): |
print(s, end = end, flush = True) |
|
|
def execute(s, mute = False): |
mute = ">/dev/null" if mute else "" |
code = os.system(f"{s}{mute}") |
28,20 → 30,24 |
print(f"Command returned {code}: \"{s}\"") |
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) |
log("Done.") |
|
|
def tool_exists(name): |
assert(type(name) == str) |
return which(name) != None |
return which(name) is not None |
|
|
def check_tools(tools): |
assert(type(tools) == tuple) |
for name_package_pair in tools: |
69,7 → 75,8 |
max_name_len = len(name) |
|
def draw_row(name, package): |
log(f" | {name.ljust(max_name_len)} | {package.ljust(max_package_name_len)} |") |
log((f" | {name.ljust(max_name_len)}" + |
f" | {package.ljust(max_package_name_len)} |")) |
|
def draw_line(): |
log(f" +-{'-' * max_name_len}-+-{'-' * max_package_name_len}-+") |
82,12 → 89,14 |
draw_line() |
exit() |
|
|
def prepare_test_img(): |
# TODO: Always recompile the kernel (after build system is done?) |
# Get IMG |
if not os.path.exists("kolibri_test.img"): |
if len(sys.argv) == 1: |
download("http://builds.kolibrios.org/eng/data/data/kolibri.img", "kolibri_test.img") |
download("http://builds.kolibrios.org/eng/data/data/kolibri.img", |
"kolibri_test.img") |
else: |
builds_eng = sys.argv[1] |
execute(f"cp {builds_eng}/data/data/kolibri.img kolibri_test.img") |
108,10 → 117,16 |
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") |
command = "fasm " |
command += "-dpretest_build=1 -ddebug_com_base=0xe9 " |
command += "-m 65536 " |
command += "kernel.asm kernel.mnt.pretest" |
execute(command) |
else: |
builds_eng = sys.argv[1] |
execute(f"cp {builds_eng}/data/kernel/trunk/kernel.mnt.pretest kernel.mnt.pretest", mute = True) |
kernel_mnt_pretest_subpath = "data/kernel/trunk/kernel.mnt.pretest" |
kernel_mnt_pretest = f"{builds_eng}/{kernel_mnt_pretest_subpath}" |
execute(f"cp {kernel_mnt_pretest} kernel.mnt.pretest", mute=True) |
|
# Put the kernel into IMG |
with open("kernel.mnt.pretest", "rb") as kernel_mnt_pretest: |
119,6 → 134,7 |
img.add_file_path("KERNEL.MNT", kernel_mnt_pretest_data) |
img.save("kolibri_test.img") |
|
|
def collect_tests(): |
tests = [] |
|
134,6 → 150,7 |
tests.append(test_folder_path) |
return tests |
|
|
def run_tests_serially_thread(test, root_dir): |
test_number = 1 |
for test in tests: |
142,7 → 159,8 |
print(f"[{test_number}/{len(tests)}] {test}... ", end = "", flush=True) |
start = timeit.default_timer() |
try: |
SourceFileLoader("test", f"{test_dir}/test.py").load_module().run(root_dir, test_dir) |
loader = SourceFileLoader("test", f"{test_dir}/test.py") |
loader.load_module().run(root_dir, test_dir) |
except common.TestTimeoutException: |
result = "TIMEOUT" |
except common.TestFailureException: |
154,37 → 172,51 |
|
test_number += 1 |
|
|
def run_tests_serially(tests, root_dir): |
thread = Thread(target = run_tests_serially_thread, args = (tests, root_dir)) |
thread.start() |
return thread |
|
|
def build_umka_asm(object_output_dir): |
umka_o = f"{object_output_dir}/umka.o" |
kolibrios_folder = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
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) |
env = os.environ |
libcrash = "programs/develop/libraries/libcrash/hash" |
env["INCLUDE"] = "" |
env["INCLUDE"] += f"{kolibrios_folder}/kernel/trunk;" |
env["INCLUDE"] += f"{kolibrios_folder}/programs/develop/libraries/libcrash/hash" |
stdout = subprocess.check_output(f"fasm -dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 umka/umka.asm umka/build/umka.o -s umka/build/umka.fas -m 2000000", shell = True, env = env) |
env["INCLUDE"] += f"{kolibrios_folder}/{libcrash}" |
command = "fasm " |
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 " |
stdout = subprocess.check_output(command, shell=True, env=env) |
print(stdout) |
return umka_o |
|
|
def cc(src, obj, include_path): |
command = "clang " |
command += "-Wno-everything -std=c11 -g -O0 -fno-pie -m32 -c " |
command += "-D_FILE_OFFSET_BITS=64 -DNDEBUG -masm=intel -D_POSIX_C_SOURCE=200809L " |
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}" |
if os.system(command) != 0: |
exit() |
|
|
def link(objects): |
command = "clang " |
command += "-Wno-everything -no-pie -m32 -o umka_shell -static -T umka/umka.ld " |
command += "-Wno-everything " |
command += "-no-pie -m32 -o umka_shell -static -T umka/umka.ld " |
command += " ".join(objects) |
if os.system(command) != 0: |
exit() |
|
|
def build_umka(): |
if not use_umka: |
return |
204,7 → 236,9 |
"util.c", |
] |
|
src_obj_pairs = [ (f"umka/{source}", f"umka/{source}.o") for source in c_sources ] |
src_obj_pairs = [ |
(f"umka/{source}", f"umka/{source}.o") for source in c_sources |
] |
|
for src, obj in src_obj_pairs: |
cc(src, obj, "umka/linux") |
243,4 → 277,3 |
tests = collect_tests() |
serial_executor_thread = run_tests_serially(tests, root_dir) |
serial_executor_thread.join() |
|