NAME=omp twice bug
FILE=malloc://1024
CMDS=<<EOF
omf 1 rw
wx 9090
p8 2
on malloc://1024
p8 2
om
omp 1
om
p8 2
EOF
EXPECT=<<EOF
9090
0000
 2 fd: 4 +0x00000000 0x00000000 - 0x000003ff rw- 
 1 fd: 3 +0x00000000 0x00000000 - 0x000003ff rw- 
 1 fd: 3 +0x00000000 0x00000000 - 0x000003ff rw- 
 2 fd: 4 +0x00000000 0x00000000 - 0x000003ff rw- 
9090
EOF
RUN

NAME=io.maps alloc map
FILE=malloc://1024
CMDS=<<EOF
e io.va=true
s 0
b 100
wox 0x10 @ 0
on malloc://0x1000 0x80000 >/dev/null
p8 4 @ 0x80000
EOF
EXPECT=<<EOF
00000000
EOF
RUN

NAME=io.maps: o 100
FILE=malloc://1024
CMDS=<<EOF
s 0
b 100
wox 0x10 @ 0
o malloc://0x1000 0x80000 > /dev/null
e io.va=true
b 0x1000
wow 20 @ 0x80000
b 20
p8 @ 0
p8 @ 90
p8 @ 0x400
p8 @ 0x80000
EOF
EXPECT=<<EOF
1010101010101010101010101010101010101010
1010101010101010101000000000000000000000
ffffffffffffffffffffffffffffffffffffffff
2020202020202020202020202020202020202020
EOF
RUN

NAME=om 0x100;x@0xff
FILE=-
CMDS=<<EOF
e io.va=false
e file.nowarn=true
e file.loadmethod=append
om `o~[0]` 0x100
w pop @ 1
p8 4 @ 0x100
EOF
EXPECT=<<EOF
00000000
EOF
RUN

NAME=o - 0x9000;x@0x8f00
FILE=-
CMDS=<<EOF
o malloc://128 0x9000 > /dev/null
e io.va=true
x 32 @ 0x8ff0
EOF
EXPECT=<<EOF
- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0x00008ff0  ffff ffff ffff ffff ffff ffff ffff ffff  ................
0x00009000  0000 0000 0000 0000 0000 0000 0000 0000  ................
EOF
RUN

NAME=omfg all rwx
FILE=-
CMDS=<<EOF
e scr.null=true
o malloc://32 0x400
e scr.null=false
omfg-rwx
om~rwx
omfg
om~rwx~?
EOF
EXPECT=<<EOF
2
EOF
RUN

NAME=Opening a new map doesnt set io.a to false
FILE=-
CMDS=<<EOF
e io.va
e scr.null=true
o malloc://32 0x400
e scr.null=false
e io.va
EOF
EXPECT=<<EOF
true
true
EOF
RUN

NAME=omf one mapping
FILE=-
CMDS=<<EOF
omf 1 rwx
om~rwx~?
omf 1 r-x
om~r-x~?
omf 1 --x
om~--x~?
omf 1 -w-
om~-w-~?
EOF
EXPECT=<<EOF
1
1
1
1
EOF
RUN

NAME=io.unalloc off-by-one fix
FILE=bins/elf/analysis/tiny1
CMDS=<<EOF
e asm.bytes=true
e asm.comments=false
e io.unalloc=true
e io.unalloc.ch=
pd 6
?e
px 16
EOF
EXPECT=<<EOF
            ;-- entry0:
            0x08048054      b32a           mov   bl, 0x2a
            0x08048056      31c0           xor   eax, eax
            0x08048058      40             inc   eax
            0x08048059      cd80           int   0x80
  0x0804805b   unmapped
  0x0804805c   unmapped

- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0x08048054  b32a 31c0 40cd 80                        .*1.@..         
EOF
RUN

NAME=om* order
FILE=bins/elf/before-after-main
CMDS=<<EOF
om
om* > $initial_map
om-*
?e ----
om
?e ----
$initial_map |.
om               # Output must be the same as initial om
EOF
EXPECT=<<EOF
 3 fd: 3 +0x00000000 0x08048000 - 0x08048a67 r-x fmap.LOAD0
 2 fd: 3 +0x00000ed4 0x08049ed4 - 0x0804a01f r-- fmap.LOAD1
 1 fd: 4 +0x00000000 0x0804a020 - 0x0804a023 rw- mmap.LOAD1
----
----
 3 fd: 3 +0x00000000 0x08048000 - 0x08048a67 r-x fmap.LOAD0
 2 fd: 3 +0x00000ed4 0x08049ed4 - 0x0804a01f r-- fmap.LOAD1
 1 fd: 4 +0x00000000 0x0804a020 - 0x0804a023 rw- mmap.LOAD1
EOF
RUN
