Rev 9387 | Rev 9409 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9387 | Rev 9397 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | import filecmp |
14 | import filecmp |
Line 15... | Line 15... | ||
15 | 15 | ||
16 | sys.path.append('test') |
16 | sys.path.append('test') |
Line -... | Line 17... | ||
- | 17 | import common |
|
- | 18 | ||
17 | import common |
19 | use_umka = False |
18 | 20 | ||
Line 19... | Line 21... | ||
19 | def log(s, end = "\n"): |
21 | def log(s, end = "\n"): |
20 | print(s, end = end, flush = True) |
22 | print(s, end = end, flush = True) |
Line 155... | Line 157... | ||
155 | def run_tests_serially(tests, root_dir): |
157 | def run_tests_serially(tests, root_dir): |
156 | thread = Thread(target = run_tests_serially_thread, args = (tests, root_dir)) |
158 | thread = Thread(target = run_tests_serially_thread, args = (tests, root_dir)) |
157 | thread.start() |
159 | thread.start() |
158 | return thread |
160 | return thread |
Line -... | Line 161... | ||
- | 161 | ||
- | 162 | def build_umka_asm(object_output_dir): |
|
- | 163 | umka_o = f"{object_output_dir}/umka.o" |
|
- | 164 | kolibrios_folder = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|
- | 165 | env = os.environ |
|
- | 166 | env["INCLUDE"] = "" |
|
- | 167 | env["INCLUDE"] += f"{kolibrios_folder}/kernel/trunk;" |
|
- | 168 | env["INCLUDE"] += f"{kolibrios_folder}/programs/develop/libraries/libcrash/hash" |
|
- | 169 | 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) |
|
- | 170 | print(stdout) |
|
- | 171 | return umka_o |
|
- | 172 | ||
- | 173 | def cc(src, obj, include_path): |
|
- | 174 | command = "clang " |
|
- | 175 | command += "-Wno-everything -std=c11 -g -O0 -fno-pie -m32 -c " |
|
- | 176 | command += "-D_FILE_OFFSET_BITS=64 -DNDEBUG -masm=intel -D_POSIX_C_SOURCE=200809L " |
|
- | 177 | command += f"-I {include_path} {src} -o {obj}" |
|
- | 178 | if os.system(command) != 0: |
|
- | 179 | exit() |
|
- | 180 | ||
- | 181 | def link(objects): |
|
- | 182 | command = "clang " |
|
- | 183 | command += "-Wno-everything -no-pie -m32 -o umka_shell -static -T umka/umka.ld " |
|
- | 184 | command += " ".join(objects) |
|
- | 185 | if os.system(command) != 0: |
|
- | 186 | exit() |
|
- | 187 | ||
- | 188 | def build_umka(): |
|
- | 189 | if not use_umka: |
|
- | 190 | return |
|
- | 191 | ||
- | 192 | os.makedirs("umka/build", exist_ok = True) |
|
- | 193 | ||
- | 194 | c_sources = [ |
|
- | 195 | "umka_shell.c", |
|
- | 196 | "shell.c", |
|
- | 197 | "trace.c", |
|
- | 198 | "trace_lbr.c", |
|
- | 199 | "vdisk.c", |
|
- | 200 | "vnet.c", |
|
- | 201 | "lodepng.c", |
|
- | 202 | "linux/pci.c", |
|
- | 203 | "linux/thread.c", |
|
- | 204 | "util.c", |
|
- | 205 | ] |
|
- | 206 | ||
- | 207 | src_obj_pairs = [ (f"umka/{source}", f"umka/{source}.o") for source in c_sources ] |
|
- | 208 | ||
- | 209 | for src, obj in src_obj_pairs: |
|
- | 210 | cc(src, obj, "umka/linux") |
|
- | 211 | ||
- | 212 | umka_o = build_umka_asm("umka/build") |
|
- | 213 | ||
- | 214 | objects = [ obj for src, obj in src_obj_pairs ] + [ umka_o ] |
|
- | 215 | link(objects) |
|
- | 216 | ||
- | 217 | os.chdir("umka/test") |
|
- | 218 | for test in [ t for t in os.listdir(".") if t.endswith(".t") ]: |
|
- | 219 | out_log = f"{test[:-2]}.out.log" |
|
- | 220 | ref_log = f"{test[:-2]}.ref.log" |
|
- | 221 | cmd_umka = f"../../umka_shell < {test} > {out_log}" |
|
- | 222 | print(cmd_umka) |
|
- | 223 | os.system(cmd_umka) |
|
- | 224 | cmd_cmp = f"cmp {out_log} {ref_log}" |
|
- | 225 | print(cmd_cmp) |
|
- | 226 | if os.system(cmd_cmp) != 0: |
|
- | 227 | print("FAILURE") |
|
- | 228 | exit() |
|
- | 229 | os.chdir("../../") |
|
- | 230 | print("SUCCESS") |
|
- | 231 | exit() |
|
159 | 232 | ||
160 | if __name__ == "__main__": |
233 | if __name__ == "__main__": |
Line 161... | Line 234... | ||
161 | root_dir = os.getcwd() |
234 | root_dir = os.getcwd() |
162 | 235 | ||
163 | # Check available tools |
236 | # Check available tools |
164 | tools = (("qemu-system-i386", "qemu-system-x86"), |
237 | tools = (("qemu-system-i386", "qemu-system-x86"), |
Line 165... | Line 238... | ||
165 | ("fasm", "fasm")) |
238 | ("fasm", "fasm")) |
- | 239 | check_tools(tools) |
|
166 | check_tools(tools) |
240 | |
167 | 241 | prepare_test_img() |
|
168 | prepare_test_img() |
242 | build_umka() |