NAME=fatmach0 string location
FILE=bins/mach0/BatteryLife
CMDS=<<EOF
s str.batteryLevel
ps
EOF
EXPECT=<<EOF
batteryLevel
EOF
RUN

NAME=fatmach0 -b64
FILE=bins/mach0/BatteryLife
ARGS=-aarm -b64
CMDS=<<EOF
e asm.bits
e asm.bytes=0
e asm.flags=0
e asm.lines.bb=0
pd 1
EOF
EXPECT=<<EOF
64
  0x100010f7c      stp   x22, x21, [sp, -0x30]!
EOF
RUN

NAME=fatmach0 arm64
FILE=bins/mach0/BatteryLife.arm_64.1
CMDS=<<EOF
e asm.bytes=0
e asm.flags=0
e asm.lines.bb=0
pd 1
EOF
EXPECT=<<EOF
  0x100010f7c      stp   x22, x21, [sp, -0x30]!
EOF
RUN

NAME=fatmach0 arm32 string location
FILE=bins/mach0/BatteryLife.arm_32.0
CMDS=<<EOF
s str.batteryLevel
ps
EOF
EXPECT=<<EOF
batteryLevel
EOF
RUN

NAME=fatmach0 arm16 symbol alignment
ARGS=-aarm -b32
FILE=bins/mach0/a.out
CMDS=<<EOF
s sym._call
pi 1
EOF
EXPECT=<<EOF
push {r7, lr}
EOF
RUN

NAME=mach0 arm16 symbol alignment
FILE=bins/mach0/a.out.fat/a.out.arm_32.0
CMDS=<<EOF
s sym._call
pi 1
EOF
EXPECT=<<EOF
push {r7, lr}
EOF
RUN

NAME=fatmach0 arm64 symbol alignment
FILE=bins/mach0/a.out
ARGS=-a arm -b 64
CMDS=<<EOF
s sym._call
pi 1
EOF
EXPECT=<<EOF
stp x29, x30, [sp, -0x10]!
EOF
RUN

NAME=mach0 arm64 symbol alignment
FILE=bins/mach0/a.out.fat/a.out.arm_64.1
CMDS=<<EOF
s sym._call
pi 1
EOF
EXPECT=<<EOF
stp x29, x30, [sp, -0x10]!
EOF
RUN

NAME=fatmach0 entry0
FILE=bins/mach0/fatmach0-3true
CMDS=?v entry0
EXPECT=<<EOF
0x100000ef8
EOF
RUN

NAME=fatmach0 entry0 data
FILE=bins/mach0/fatmach0-3true
CMDS=p8 16 @ entry0
EXPECT=<<EOF
6a004889e54883e4f0488b7d08488d75
EOF
RUN

NAME=fatmach0 entry1
FILE=bins/mach0/fatmach0-3true
ARGS=-a x86 -b 32
CMDS=?v entry0
EXPECT=<<EOF
0x1f44
EOF
RUN

NAME=fatmach0 entry1 data
FILE=bins/mach0/fatmach0-3true
ARGS=-a x86 -b 32
CMDS=p8 16 @ entry0
EXPECT=<<EOF
6a0089e583e4f083ec108b5d04891c24
EOF
RUN

NAME=fatmach0 entry1 rz-bin
FILE=bins/mach0/fatmach0-3true
ARGS=-n
CMDS=!rz-bin -a x86 -b 32 -qe bins/mach0/fatmach0-3true
EXPECT=<<EOF
0x00001f44
EOF
RUN

NAME=fatmach0 entry1 rz-bin
FILE=bins/mach0/fatmach0-3true
ARGS=-n
CMDS=!rz-bin -p -a x86 -b 32 -qe bins/mach0/fatmach0-3true
EXPECT=<<EOF
0x00005f44
EOF
RUN

NAME=fatmach0 entry1 rz-bin (2)
FILE=bins/mach0/fatmach0-3true
ARGS=-n
CMDS=!rz-bin -a x86 -b 32 -e bins/mach0/fatmach0-3true | grep paddr=
EXPECT=<<EOF
vaddr=0x00001f44 paddr=0x00005f44 haddr=0x00000420 type=program
EOF
RUN

NAME=fatmach0 entry2
FILE=bins/mach0/fatmach0-3true
ARGS=-a ppc -b 32
CMDS=?v entry0
EXPECT=<<EOF
0x1f64
EOF
RUN

NAME=fatmach0 entry2 data
FILE=bins/mach0/fatmach0-3true
ARGS=-a ppc -b 32
CMDS=p8 16 @ entry0
EXPECT=<<EOF
7c3a0b783821fffc5421003438000000
EOF
RUN

NAME=fatmach0 archs iA iAj
FILE=bins/mach0/fatmach0-3true
CMDS=<<EOF
iA
iAj
EOF
EXPECT=<<EOF
000 0x00001000 13792 x86_64 x86 64 all
001 0x00005000 13760 x86_32 386
002 0x00009000 13616 ppc_32 7400
{"bins":[{"arch":"x86","bits":64,"offset":4096,"size":13792,"machine":"x86 64 all"},{"arch":"x86","bits":32,"offset":20480,"size":13760,"machine":"386"},{"arch":"ppc","bits":32,"offset":36864,"size":13616,"machine":"7400"}]}
EOF
RUN

NAME=fatmach0 rz-bin archs
FILE=bins/mach0/fatmach0-3true
CMDS=<<EOF
!rz-bin -A bins/mach0/fatmach0-3true
!rz-bin -Aj bins/mach0/fatmach0-3true
EOF
EXPECT=<<EOF
000 0x00001000 13792 x86_64 x86 64 all
001 0x00005000 13760 x86_32 386
002 0x00009000 13616 ppc_32 7400
{"bins":[{"arch":"x86","bits":64,"offset":4096,"size":13792,"machine":"x86 64 all"},{"arch":"x86","bits":32,"offset":20480,"size":13760,"machine":"386"},{"arch":"ppc","bits":32,"offset":36864,"size":13616,"machine":"7400"}]}
EOF
RUN

NAME=fatmach0 extract
FILE=bins/mach0/fatmach0-3true
ARGS=-n
CMDS=!rz-bin -x bins/mach0/fatmach0-3true;!rm -rf fatmach0-3true.fat
EXPECT=<<EOF
fatmach0-3true.fat/fatmach0-3true.x86_64.0 created (13792)
fatmach0-3true.fat/fatmach0-3true.x86_32.1 created (13760)
fatmach0-3true.fat/fatmach0-3true.ppc_32.2 created (13616)
EOF
RUN

NAME=fatmach0 sections
FILE=bins/mach0/fatmach0-3true
ARGS=-a x86 -b 64
CMDS=om~?
EXPECT=<<EOF
4
EOF
RUN

NAME=fatmach0 rebase
FILE=bins/mach0/fatmach0-3true
ARGS=-a x86 -b32 -B 0x90000000
CMDS=is
EXPECT=<<EOF
[Symbols]

nth paddr       vaddr      bind   type size lib name
----------------------------------------------------
0    0x00005000 0x90000000 GLOBAL FUNC 0        __mh_execute_header
1    0x00005000 0x95613542 LOCAL  FUNC 0        radr://5614542
2    0x00005f94 0x90000f94 LOCAL  FUNC 0        imp.exit
EOF
RUN

NAME=fatmach0 objc
FILE=bins/mach0/modernobjc-noarm64
ARGS=-a arm
CMDS=ic
EXPECT=<<EOF
0x100009298 [0x100001e90 - 0x100001e90]      0 class 0 ViewController
0x100001e90 method 0      viewDidLoad
0x1000092c0 [0x100001ee4 - 0x1000020a4]    448 class 0 AppDelegate
0x100001ee4 method 0      application:didFinishLaunchingWithOptions:
0x100001f74 method 1      application:configurationForConnectingSceneSession:options:
0x1000020a4 method 2      application:didDiscardSceneSessions:
0x100009310 [0x1000021d0 - 0x100002494]    708 class 0 SceneDelegate
0x1000021d0 method 0      scene:willConnectToSession:options:
0x100002280 method 1      sceneDidDisconnect:
0x1000022d4 method 2      sceneDidBecomeActive:
0x100002328 method 3      sceneWillResignActive:
0x10000237c method 4      sceneWillEnterForeground:
0x1000023d0 method 5      sceneDidEnterBackground:
0x100002424 method 6      window
0x100002450 method 7      setWindow:
0x100002494 method 8      .cxx_destruct
EOF
RUN
