#!/usr/bin/env python3 # SPDX-License-Identifier: MIT import importlib.util from pathlib import Path import struct import subprocess import sys import unittest ROOT=Path(__file__).resolve().parents[1] sys.path.insert(0,str(ROOT/'probes')) import run import xnuboot as xb class StockCPU(unittest.TestCase): def test_target_registry_and_disjoint_results(self): binary=ROOT/'build/test-cpu' subprocess.run(['clang','-std=c11','-O1','-g','-fsanitize=address,undefined', '-fno-sanitize-recover=all','-Wall','-Wextra','-Werror', str(ROOT/'tools/test-cpu.c'),str(ROOT/'compat/cpu.c'),'-o',str(binary)],check=True) subprocess.run([str(binary)],check=True) def test_selected_shipped_affinity_and_slot_contract(self): spec=importlib.util.spec_from_file_location('kc',ROOT/'tools/kc-load.py') kc=importlib.util.module_from_spec(spec);spec.loader.exec_module(kc) im=kc.Image((ROOT/'downloads/extracted/j700ap/kernelcache.release.mac17p').read_bytes()) def word(low): va=0xfffffe0000000000+low _,base,_,off,_=next(s for s in im.segments if s[1]<=va