rizin/test/db/io/cache
Riccardo Schirone 144ba639dc
Convert s commands to newshell (#375)
* Rename `sj`/`s*` and move them under `sH`. Remove `s=`
* Rename `s-*` to `sH-`
* Use `sd` for "seek delta", which moves relative to the current offset
* Enforce <cmd> <arg> syntax. So no more `s+16` but `s +16`. Command
  `sHr` is for redo history, `sHu` for undo history. If one wants to move
  relative to the current address, they need to do `sd +10`/`sd -10`.
* Remove `ss` commands in favour of `cmd.seek.silent`. This was anyway
  used mainly for scripts, so no need to replicate all `s` commands
  under `ss`.

Change a bit rz_core_seek API to avoid dupped entries in seek history.
2021-01-20 10:30:20 +08:00

168 lines
2.8 KiB
Text

NAME=io.cache: minimal usage
FILE=malloc://1024
CMDS=<<EOF
e io.cache=true
wx 010203
p8 3
wcr
# Test write works after disabling the cache.
e io.cache=false
wx 040506
p8 3
EOF
EXPECT=<<EOF
010203
040506
EOF
RUN
NAME=io.cache: Writing after end of file
FILE=bins/other/0x3
CMDS=<<EOF
e io.cache=true
w hello
x 5
EOF
EXPECT=<<EOF
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000000 6865 6c6c 6f hello
EOF
RUN
NAME=io.cache: Writing after end of file
FILE=malloc://1024
CMDS=<<EOF
?e
b 0xf
p8
w no-cache
p8
e io.cache=true
w cache-mode
p8
# Reseting cache restores original data.
wcr
p8
w overwrite
p8
wci
# Commit cache overwrites original data.
p8
# Reset cache with no pending cache entries.
wcr
wci
p8
EOF
EXPECT=<<EOF
000000000000000000000000000000
6e6f2d636163686500000000000000
63616368652d6d6f64650000000000
6e6f2d636163686500000000000000
6f7665727772697465000000000000
6f7665727772697465000000000000
6f7665727772697465000000000000
EOF
RUN
NAME=io.cache: empty file
FILE=.empty.tmp
BROKEN=1
CMDS=<<EOF
?e
b 15
p8
w no-cache
p8
e io.cache=true
w cache-mode
p8
# Reseting cache restores original data.
wcr
p8
w overwrite
p8
wci
# Commit cache overwrites original data.
p8
# Reset cache with no pending cache entries.
wcr
wci
p8
# File was correctly writen.
cat .empty.tmp
?e
EOF
EXPECT=<<EOF
ffffffffffffffffffffffffffffff
6e6f2d6361636865ffffffffffffff
63616368652d6d6f6465ffffffffff
6e6f2d6361636865ffffffffffffff
6f7665727772697465ffffffffffff
6f7665727772697465ffffffffffff
6f7665727772697465ffffffffffff
overwrite
EOF
RUN
NAME=io.cache: Reading behind cache written area
FILE=malloc://32
CMDS=<<EOF
e io.cache=true
px 32
sd +1
px 31
sd -1
wx 90
px 32
sd +1
px 31
EOF
EXPECT=<<EOF
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000000 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000010 0000 0000 0000 0000 0000 0000 0000 0000 ................
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000001 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000011 0000 0000 0000 0000 0000 0000 0000 00 ...............
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000000 9000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000010 0000 0000 0000 0000 0000 0000 0000 0000 ................
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000001 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000011 0000 0000 0000 0000 0000 0000 0000 00 ...............
EOF
RUN
NAME=io.cache: cache write, cache undo
FILE=malloc://1024
CMDS=<<EOF
e io.cache=true
w a
w b @ 1
p8 2
wc- 0 2
p8 2
EOF
EXPECT=<<EOF
6162
0000
EOF
RUN
NAME=io.cache: cache reset
FILE=malloc://32
CMDS=<<EOF
e io.cache=true
wx 90
wcr
wx 90
EOF
EXPECT_ERR=<<EOF
EOF
RUN