Add test for file holes, allow comments in logs.

This commit is contained in:
Ivan Baravy 2019-10-28 06:10:38 +03:00
parent e65cfc02d8
commit d946de1c81
15 changed files with 395 additions and 18 deletions

View File

@ -137,19 +137,15 @@ s512_xfs_v4_files.img:
$(MKFILEPATTERN) $(TEMP_DIR)/no_hole 65536
#
$(MKFILEPATTERN) $(TEMP_DIR)/hole_begin 65536
fallocate -p -o 0 -l 16384 $(TEMP_DIR)/hole_begin
fallocate -p -o 0 -l 16KiB $(TEMP_DIR)/hole_begin
#
$(MKFILEPATTERN) $(TEMP_DIR)/hole_middle 65536
fallocate -p -o 32768 -l 16384 $(TEMP_DIR)/hole_middle
fallocate -p -o 32KiB -l 16KiB $(TEMP_DIR)/hole_middle
#
$(MKFILEPATTERN) $(TEMP_DIR)/hole_end 65536
fallocate -p -o 49152 -l 16384 $(TEMP_DIR)/hole_end
fallocate -p -o 48KiB -l 16KiB $(TEMP_DIR)/hole_end
#
# fallocate -l 120GiB $(TEMP_DIR)/btree_l1_no_hole
fallocate -l 4KiB $(TEMP_DIR)/btree_l1_no_hole
# $(MKFILEPATTERN) $(TEMP_DIR)/btree_l1_no_hole 2097152
# fallocate -c -l 64KiB -o $$((64*$$n))KiB $(TEMP_DIR)/btree_l1_no_hole ; \
# dd if=/dev/zero of=$(TEMP_DIR)/btree_l1_no_hole bs=1M count=128
for n in $$(seq 1 2000); do \
fallocate -i -l 4KiB -o 0KiB $(TEMP_DIR)/btree_l1_no_hole ; \
fallocate -z -l 4KiB -o 0KiB $(TEMP_DIR)/btree_l1_no_hole ; \
@ -171,13 +167,13 @@ s512_xfs_v4_files_b4k_n2b.img:
$(MKFILEPATTERN) $(TEMP_DIR)/no_hole 65536
#
$(MKFILEPATTERN) $(TEMP_DIR)/hole_begin 65536
fallocate -p -o 0 -l 16384 $(TEMP_DIR)/hole_begin
fallocate -p -o 0 -l 16KiB $(TEMP_DIR)/hole_begin
#
$(MKFILEPATTERN) $(TEMP_DIR)/hole_middle 65536
fallocate -p -o 32768 -l 16384 $(TEMP_DIR)/hole_middle
fallocate -p -o 32KiB -l 16KiB $(TEMP_DIR)/hole_middle
#
$(MKFILEPATTERN) $(TEMP_DIR)/hole_end 65536
fallocate -p -o 49152 -l 16384 $(TEMP_DIR)/hole_end
fallocate -p -o 48KiB -l 16KiB $(TEMP_DIR)/hole_end
#
# fallocate -l 120GiB $(TEMP_DIR)/btree_l1_no_hole
fallocate -l 4KiB $(TEMP_DIR)/btree_l1_no_hole

5
kofu.c
View File

@ -350,7 +350,10 @@ int main(int argc, char **argv) {
//msg_file_not_found db 'file not found: '
const char **cargv = (const char**)malloc(sizeof(const char*) * (MAX_COMMAND_ARGS + 1));
while(next_line()) {
if (cmd_buf[0] == '#' || cmd_buf[0] == '\n') continue;
if (cmd_buf[0] == '#' || cmd_buf[0] == '\n') {
printf("%s", cmd_buf);
continue;
}
if (cmd_buf[0] == 'X') break;
if (!is_tty) {
prompt();

View File

@ -1,5 +1,6 @@
/> disk_add ../img/s512_xfs_v4_files_b4k_n2b.img hd0
/hd0/1: xfs
# zero length
/> read /hd0/1/no_hole 0 0 -b
status = 0 success, count = 0
@ -72,6 +73,7 @@ status = 0 success, count = 0
/> read /hd0/1/no_hole 0xffffffffffffffff 0 -b
status = 0 success, count = 0
# one-byte length
/> read /hd0/1/no_hole 0 1 -b
status = 0 success, count = 1
00
@ -144,6 +146,7 @@ status = 6 end_of_file, count = 0
/> read /hd0/1/no_hole 0xffffffffffffffff 1 -b
status = 6 end_of_file, count = 0
# fixed-size block, different begin/end positions
/> read /hd0/1/no_hole 0 11 -b
status = 0 success, count = 11
000102030405060708090a

View File

@ -0,0 +1,274 @@
/> disk_add ../img/s512_xfs_v4_files_b4k_n2b.img hd0
/hd0/1: xfs
# hole begin
# zero length
/> read /hd0/1/hole_begin 0 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_begin 1 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_begin 0x3ffe 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_begin 0x3fff 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_begin 0x4000 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_begin 0x4001 0 -b
status = 0 success, count = 0
# one-byte length
/> read /hd0/1/hole_begin 0 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_begin 1 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_begin 0x3ffe 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_begin 0x3fff 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_begin 0x4000 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_begin 0x4001 1 -b
status = 0 success, count = 1
40
# fixed-size block, different begin/end positions
/> read /hd0/1/hole_begin 0 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_begin 1 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_begin 0x3ff4 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_begin 0x3ff5 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_begin 0x3ff6 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_begin 0x3ff7 11 -b
status = 0 success, count = 11
0000000000000000000040
/> read /hd0/1/hole_begin 0x3ffe 11 -b
status = 0 success, count = 11
0000004002400440064008
/> read /hd0/1/hole_begin 0x3fff 11 -b
status = 0 success, count = 11
0000400240044006400840
/> read /hd0/1/hole_begin 0x4000 11 -b
status = 0 success, count = 11
004002400440064008400a
/> read /hd0/1/hole_begin 0x4001 11 -b
status = 0 success, count = 11
4002400440064008400a40
# hole middle
# zero length
/> read /hd0/1/hole_middle 0x7ffe 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0x7fff 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0x8000 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0x8001 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0xbffe 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0xbfff 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0xc000 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_middle 0xc001 0 -b
status = 0 success, count = 0
# one-byte length
/> read /hd0/1/hole_middle 0x7ffe 1 -b
status = 0 success, count = 1
fe
/> read /hd0/1/hole_middle 0x7fff 1 -b
status = 0 success, count = 1
7f
/> read /hd0/1/hole_middle 0x8000 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_middle 0x8001 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_middle 0xbffe 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_middle 0xbfff 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_middle 0xc000 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_middle 0xc001 1 -b
status = 0 success, count = 1
c0
# fixed-size block, different begin/end positions
/> read /hd0/1/hole_middle 0x7ff4 11 -b
status = 0 success, count = 11
f47ff67ff87ffa7ffc7ffe
/> read /hd0/1/hole_middle 0x7ff5 11 -b
status = 0 success, count = 11
7ff67ff87ffa7ffc7ffe7f
/> read /hd0/1/hole_middle 0x7ff6 11 -b
status = 0 success, count = 11
f67ff87ffa7ffc7ffe7f00
/> read /hd0/1/hole_middle 0x7ff7 11 -b
status = 0 success, count = 11
7ff87ffa7ffc7ffe7f0000
/> read /hd0/1/hole_middle 0x7ffe 11 -b
status = 0 success, count = 11
fe7f000000000000000000
/> read /hd0/1/hole_middle 0x7fff 11 -b
status = 0 success, count = 11
7f00000000000000000000
/> read /hd0/1/hole_middle 0x8000 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_middle 0x8001 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_middle 0xbff4 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_middle 0xbff5 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_middle 0xbff6 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_middle 0xbff7 11 -b
status = 0 success, count = 11
00000000000000000000c0
/> read /hd0/1/hole_middle 0xbffe 11 -b
status = 0 success, count = 11
000000c002c004c006c008
/> read /hd0/1/hole_middle 0xbfff 11 -b
status = 0 success, count = 11
0000c002c004c006c008c0
/> read /hd0/1/hole_middle 0xc000 11 -b
status = 0 success, count = 11
00c002c004c006c008c00a
/> read /hd0/1/hole_middle 0xc001 11 -b
status = 0 success, count = 11
c002c004c006c008c00ac0
# hole end
# zero length
/> read /hd0/1/hole_end 0xbffe 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0xbfff 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0xc000 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0xc001 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0xfffe 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0xffff 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0x10000 0 -b
status = 0 success, count = 0
/> read /hd0/1/hole_end 0x10001 0 -b
status = 0 success, count = 0
# one-byte length
/> read /hd0/1/hole_end 0xbffe 1 -b
status = 0 success, count = 1
fe
/> read /hd0/1/hole_end 0xbfff 1 -b
status = 0 success, count = 1
bf
/> read /hd0/1/hole_end 0xc000 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_end 0xc001 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_end 0xfffe 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_end 0xffff 1 -b
status = 0 success, count = 1
00
/> read /hd0/1/hole_end 0x10000 1 -b
status = 6 end_of_file, count = 0
/> read /hd0/1/hole_end 0x10001 1 -b
status = 6 end_of_file, count = 0
# fixed-size block, different begin/end positions
/> read /hd0/1/hole_end 0xbff4 11 -b
status = 0 success, count = 11
f4bff6bff8bffabffcbffe
/> read /hd0/1/hole_end 0xbff5 11 -b
status = 0 success, count = 11
bff6bff8bffabffcbffebf
/> read /hd0/1/hole_end 0xbff6 11 -b
status = 0 success, count = 11
f6bff8bffabffcbffebf00
/> read /hd0/1/hole_end 0xbff7 11 -b
status = 0 success, count = 11
bff8bffabffcbffebf0000
/> read /hd0/1/hole_end 0xbffe 11 -b
status = 0 success, count = 11
febf000000000000000000
/> read /hd0/1/hole_end 0xbfff 11 -b
status = 0 success, count = 11
bf00000000000000000000
/> read /hd0/1/hole_end 0xc000 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_end 0xc001 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_end 0xfff4 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_end 0xfff5 11 -b
status = 0 success, count = 11
0000000000000000000000
/> read /hd0/1/hole_end 0xfff6 11 -b
status = 6 end_of_file, count = 10
00000000000000000000
/> read /hd0/1/hole_end 0xfff7 11 -b
status = 6 end_of_file, count = 9
000000000000000000
/> read /hd0/1/hole_end 0xfffe 11 -b
status = 6 end_of_file, count = 2
0000
/> read /hd0/1/hole_end 0xffff 11 -b
status = 6 end_of_file, count = 1
00
/> read /hd0/1/hole_end 0x10000 11 -b
status = 6 end_of_file, count = 0
/> read /hd0/1/hole_end 0x10001 11 -b
status = 6 end_of_file, count = 0

View File

@ -0,0 +1,101 @@
disk_add ../img/s512_xfs_v4_files_b4k_n2b.img hd0
# hole begin
# zero length
read /hd0/1/hole_begin 0 0 -b
read /hd0/1/hole_begin 1 0 -b
read /hd0/1/hole_begin 0x3ffe 0 -b
read /hd0/1/hole_begin 0x3fff 0 -b
read /hd0/1/hole_begin 0x4000 0 -b
read /hd0/1/hole_begin 0x4001 0 -b
# one-byte length
read /hd0/1/hole_begin 0 1 -b
read /hd0/1/hole_begin 1 1 -b
read /hd0/1/hole_begin 0x3ffe 1 -b
read /hd0/1/hole_begin 0x3fff 1 -b
read /hd0/1/hole_begin 0x4000 1 -b
read /hd0/1/hole_begin 0x4001 1 -b
# fixed-size block, different begin/end positions
read /hd0/1/hole_begin 0 11 -b
read /hd0/1/hole_begin 1 11 -b
read /hd0/1/hole_begin 0x3ff4 11 -b
read /hd0/1/hole_begin 0x3ff5 11 -b
read /hd0/1/hole_begin 0x3ff6 11 -b
read /hd0/1/hole_begin 0x3ff7 11 -b
read /hd0/1/hole_begin 0x3ffe 11 -b
read /hd0/1/hole_begin 0x3fff 11 -b
read /hd0/1/hole_begin 0x4000 11 -b
read /hd0/1/hole_begin 0x4001 11 -b
# hole middle
# zero length
read /hd0/1/hole_middle 0x7ffe 0 -b
read /hd0/1/hole_middle 0x7fff 0 -b
read /hd0/1/hole_middle 0x8000 0 -b
read /hd0/1/hole_middle 0x8001 0 -b
read /hd0/1/hole_middle 0xbffe 0 -b
read /hd0/1/hole_middle 0xbfff 0 -b
read /hd0/1/hole_middle 0xc000 0 -b
read /hd0/1/hole_middle 0xc001 0 -b
# one-byte length
read /hd0/1/hole_middle 0x7ffe 1 -b
read /hd0/1/hole_middle 0x7fff 1 -b
read /hd0/1/hole_middle 0x8000 1 -b
read /hd0/1/hole_middle 0x8001 1 -b
read /hd0/1/hole_middle 0xbffe 1 -b
read /hd0/1/hole_middle 0xbfff 1 -b
read /hd0/1/hole_middle 0xc000 1 -b
read /hd0/1/hole_middle 0xc001 1 -b
# fixed-size block, different begin/end positions
read /hd0/1/hole_middle 0x7ff4 11 -b
read /hd0/1/hole_middle 0x7ff5 11 -b
read /hd0/1/hole_middle 0x7ff6 11 -b
read /hd0/1/hole_middle 0x7ff7 11 -b
read /hd0/1/hole_middle 0x7ffe 11 -b
read /hd0/1/hole_middle 0x7fff 11 -b
read /hd0/1/hole_middle 0x8000 11 -b
read /hd0/1/hole_middle 0x8001 11 -b
read /hd0/1/hole_middle 0xbff4 11 -b
read /hd0/1/hole_middle 0xbff5 11 -b
read /hd0/1/hole_middle 0xbff6 11 -b
read /hd0/1/hole_middle 0xbff7 11 -b
read /hd0/1/hole_middle 0xbffe 11 -b
read /hd0/1/hole_middle 0xbfff 11 -b
read /hd0/1/hole_middle 0xc000 11 -b
read /hd0/1/hole_middle 0xc001 11 -b
# hole end
# zero length
read /hd0/1/hole_end 0xbffe 0 -b
read /hd0/1/hole_end 0xbfff 0 -b
read /hd0/1/hole_end 0xc000 0 -b
read /hd0/1/hole_end 0xc001 0 -b
read /hd0/1/hole_end 0xfffe 0 -b
read /hd0/1/hole_end 0xffff 0 -b
read /hd0/1/hole_end 0x10000 0 -b
read /hd0/1/hole_end 0x10001 0 -b
# one-byte length
read /hd0/1/hole_end 0xbffe 1 -b
read /hd0/1/hole_end 0xbfff 1 -b
read /hd0/1/hole_end 0xc000 1 -b
read /hd0/1/hole_end 0xc001 1 -b
read /hd0/1/hole_end 0xfffe 1 -b
read /hd0/1/hole_end 0xffff 1 -b
read /hd0/1/hole_end 0x10000 1 -b
read /hd0/1/hole_end 0x10001 1 -b
# fixed-size block, different begin/end positions
read /hd0/1/hole_end 0xbff4 11 -b
read /hd0/1/hole_end 0xbff5 11 -b
read /hd0/1/hole_end 0xbff6 11 -b
read /hd0/1/hole_end 0xbff7 11 -b
read /hd0/1/hole_end 0xbffe 11 -b
read /hd0/1/hole_end 0xbfff 11 -b
read /hd0/1/hole_end 0xc000 11 -b
read /hd0/1/hole_end 0xc001 11 -b
read /hd0/1/hole_end 0xfff4 11 -b
read /hd0/1/hole_end 0xfff5 11 -b
read /hd0/1/hole_end 0xfff6 11 -b
read /hd0/1/hole_end 0xfff7 11 -b
read /hd0/1/hole_end 0xfffe 11 -b
read /hd0/1/hole_end 0xffff 11 -b
read /hd0/1/hole_end 0x10000 11 -b
read /hd0/1/hole_end 0x10001 11 -b

View File

@ -2,19 +2,19 @@ KOFU=../kofu
f30_tests := $(addsuffix .out, $(basename $(wildcard ???_f30_*.t)))
sf700_tests := $(addsuffix .out, $(basename $(wildcard ???_sf700_*.t)))
sf701_tests := $(addsuffix .out, $(basename $(wildcard ???_sf701_*.t)))
sf705_tests := $(addsuffix .out, $(basename $(wildcard ???_sf705_*.t)))
f70s0_tests := $(addsuffix .out, $(basename $(wildcard ???_f70s0_*.t)))
f70s1_tests := $(addsuffix .out, $(basename $(wildcard ???_f70s1_*.t)))
f70s5_tests := $(addsuffix .out, $(basename $(wildcard ???_f70s5_*.t)))
all: f30 f70
@echo all tests passed
f30: $(f30_tests)
f70: sf700 sf701 sf705
sf700: $(sf700_tests)
sf701: $(sf701_tests)
sf705: $(sf705_tests)
f70: f70s0 f70s1 f70s5
f70s0: $(f70s0_tests)
f70s1: $(f70s1_tests)
f70s5: $(f70s5_tests)
%.out: %.ref %.t
$(KOFU) < $(word 2, $^) > $@