Disable disk cache in tests.

It is useless since host OS cache is used anyway. It also slows down
coverage collection because of many taken branches.

Specialized tests should be written to test disk cache specifically.
This commit is contained in:
Ivan Baravy 2020-03-08 01:09:36 +03:00
parent 349800ca54
commit 5822be9942
38 changed files with 84 additions and 52 deletions

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0
/> disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0 -c 0
/hd0/1: xfs
/> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0
disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0 -c 0
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
ls70 /hd0/1/block

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k.img hd0
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k.img hd0 -c 0
/hd0/1: xfs
/> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k.img hd0
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k.img hd0 -c 0
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
ls70 /hd0/1/block

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
# zero length
/> read70 /hd0/1/no_hole 0 0 -b

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
# zero length
read70 /hd0/1/no_hole 0 0 -b
read70 /hd0/1/no_hole 1 0 -b

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
/> stat70 /hd0/1/
status = 0 success

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
stat70 /hd0/1/
stat70 /hd0/1/hole_begin
disk_del hd0

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
/> pwd
/

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
pwd
cd /hd0
pwd

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
# hole begin
# zero length

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.img hd0 -c 0
# hole begin
# zero length
read70 /hd0/1/hole_begin 0 0 -b

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0
/> disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0 -c 0
/hd0/1: xfs
/> stat70 /hd0/1/sf_empty
status = 0 success

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0
disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.img hd0 -c 0
stat70 /hd0/1/sf_empty
stat70 /hd0/1/sf_empty/.
stat70 /hd0/1/sf_empty/..

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_ftype0_s4k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v4_ftype0_s4k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
/> ls70 /hd0/1/sf
status = 6 end_of_file, count = 5

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_ftype0_s4k_b4k_n8k.img hd0
disk_add ../img/xfs_v4_ftype0_s4k_b4k_n8k.img hd0 -c 0
ls70 /hd0/1/sf
ls70 /hd0/1/block
ls70 /hd0/1/leaf

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0 -c 0
/hd0/1: xfs
/> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0 -c 0
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
ls70 /hd0/1/block

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0 -c 0
/hd0/1: xfs
/> stat70 /hd0/1/sf_empty
status = 0 success

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.img hd0 -c 0
stat70 /hd0/1/sf_empty
stat70 /hd0/1/sf_empty/.
stat70 /hd0/1/sf_empty/..

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v4_unicode.img hd0
/> disk_add ../img/xfs_v4_unicode.img hd0 -c 0
/hd0/1: xfs
/> stat80 /hd0/1/dir0

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v4_unicode.img hd0
disk_add ../img/xfs_v4_unicode.img hd0 -c 0
stat80 /hd0/1/dir0
stat80 /hd0/1/dir0/

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0
/> disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0 -c 0
/hd0/1: xfs
/> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0
disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0 -c 0
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
ls70 /hd0/1/block

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0
/> disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0 -c 0
/hd0/1: xfs
/> stat70 /hd0/1/sf_empty
status = 0 success

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0
disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.img hd0 -c 0
stat70 /hd0/1/sf_empty
stat70 /hd0/1/sf_empty/.
stat70 /hd0/1/sf_empty/..

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
# hole begin
# zero length

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0
disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0 -c 0
# hole begin
# zero length
read70 /hd0/1/hole_begin 0 0 -b

View File

@ -1,4 +1,4 @@
/> disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0
/> disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0 -c 0
/hd0/1: xfs
# zero length
/> read70 /hd0/1/no_hole 0 0 -b

View File

@ -1,4 +1,4 @@
disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0
disk_add ../img/xfs_v5_files_s05k_b4k_n8k.img hd0 -c 0
# zero length
read70 /hd0/1/no_hole 0 0 -b
read70 /hd0/1/no_hole 1 0 -b

View File

@ -1,4 +1,4 @@
/> disk_add ../img/kolibri.img rd
/> disk_add ../img/kolibri.img rd -c 0
/rd/1: fat
/> set_skin /sys/DEFAULT.SKN
status: 0

View File

@ -1,4 +1,4 @@
disk_add ../img/kolibri.img rd
disk_add ../img/kolibri.img rd -c 0
set_skin /sys/DEFAULT.SKN
window_redraw 1
draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello

View File

@ -35,8 +35,8 @@ draw: $(draw_tests)
%.out.log: %.ref.log %.t
$(UMKA_SHELL) < $*.t > $@
@ cmp $@ $<
@ if [ -f "$*.ref.png" ]; then cmp $*.out.png $*.ref.png; fi
@ cmp $*.{out,ref}.log
@ if [ -f "$*.ref.png" ]; then cmp $*.{out,ref}.png; fi
coverage:
../covpreproc ../umka.lst 0x34 coverage.* > ../umka.cov

View File

@ -389,6 +389,9 @@ uglobal
context_counter dd ?
LAPIC_BASE dd ?
irq_mode dd ?
ioapic_cnt dd ?
ioapic_gsi_base dd ?
MAX_IOAPICS = 2
cache_ide0 IDE_CACHE
cache_ide1 IDE_CACHE
DiskNumber db ?

View File

@ -140,7 +140,7 @@ int main(int argc, char *argv[]) {
exit(1);
}
kos_init();
void *userdata = vdisk_init(argv[2]);
void *userdata = vdisk_init(argv[2], 0u);
void *vdisk = disk_add(&vdisk_functions, "hd0", userdata, 0);
disk_media_changed(vdisk, 1);
return fuse_main(argc-1, argv, &umka_oper, NULL);

View File

@ -62,7 +62,7 @@ diskfunc_t vdisk_functions = {
.read = vdisk_read,
.write = vdisk_write,
.flush = NULL,
.adjust_cache_size = vdisk_adjust_cache_size,
.adjust_cache_size = NULL,
};
char cur_dir[PATH_MAX] = "/";
const char *last_dir = cur_dir;
@ -224,11 +224,33 @@ void umka_disk_list_partitions(disk_t *d) {
}
void umka_disk_add(int argc, char **argv) {
(void)argc;
const char *file_name = argv[1];
const char *disk_name = argv[2];
const char *usage = \
"usage: disk_add <file> <name> [option]...\n"
" <file> absolute or relative path\n"
" <name> disk name, e.g. hd0 or rd\n"
" -c cache size size of disk cache in bytes";
if (argc < 3) {
puts(usage);
return;
}
unsigned cache_size = 0u;
int opt;
optind = 1;
const char *file_name = argv[optind++];
const char *disk_name = argv[optind++];
while ((opt = getopt(argc, argv, "c:")) != -1) {
switch (opt) {
case 'c':
cache_size = strtoul(optarg, NULL, 0);
vdisk_functions.adjust_cache_size = vdisk_adjust_cache_size;
break;
default:
puts(usage);
return;
}
}
void *userdata = vdisk_init(file_name);
void *userdata = vdisk_init(file_name, cache_size);
if (userdata) {
void *vdisk = disk_add(&vdisk_functions, disk_name, userdata, 0);
if (vdisk) {

21
vdisk.c
View File

@ -7,11 +7,12 @@
typedef struct {
FILE *file;
uint64_t sect_cnt;
uint32_t sect_size;
uint64_t sect_cnt;
unsigned cache_size;
} vdisk_t;
void *vdisk_init(const char *fname) {
void *vdisk_init(const char *fname, unsigned cache_size) {
FILE *f = fopen(fname, "r+");
if (!f) {
printf("vdisk: can't open file '%s': %s\n", fname, strerror(errno));
@ -25,7 +26,10 @@ void *vdisk_init(const char *fname) {
sect_size = 4096;
}
vdisk_t *vdisk = (vdisk_t*)malloc(sizeof(vdisk_t));
*vdisk = (vdisk_t){f, (uint64_t)fsize / sect_size, sect_size};
*vdisk = (vdisk_t){.file = f,
.sect_size = sect_size,
.sect_cnt = (uint64_t)fsize / sect_size,
.cache_size = cache_size};
return vdisk;
}
@ -37,7 +41,8 @@ void vdisk_close(void *userdata) {
}
__attribute__((__stdcall__))
int vdisk_read(void *userdata, void *buffer, off_t startsector, size_t *numsectors) {
int vdisk_read(void *userdata, void *buffer, off_t startsector,
size_t *numsectors) {
vdisk_t *vdisk = userdata;
fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET);
fread(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file);
@ -45,7 +50,8 @@ int vdisk_read(void *userdata, void *buffer, off_t startsector, size_t *numsecto
}
__attribute__((__stdcall__))
int vdisk_write(void *userdata, void *buffer, off_t startsector, size_t *numsectors) {
int vdisk_write(void *userdata, void *buffer, off_t startsector,
size_t *numsectors) {
vdisk_t *vdisk = userdata;
fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET);
fwrite(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file);
@ -62,8 +68,7 @@ int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo) {
}
__attribute__((__stdcall__))
unsigned int vdisk_adjust_cache_size(void *userdata, unsigned int suggested_size) {
(void)userdata;
unsigned vdisk_adjust_cache_size(vdisk_t *vdisk, unsigned suggested_size) {
(void)suggested_size;
return 64*1024;
return vdisk->cache_size;
}

10
vdisk.h
View File

@ -5,21 +5,23 @@
#include <inttypes.h>
#include "kolibri.h"
void *vdisk_init(const char *fname);
void *vdisk_init(const char *fname, unsigned cache_size);
__attribute__((__stdcall__))
void vdisk_close(void *userdata);
__attribute__((__stdcall__))
int vdisk_read(void *userdata, void *buffer, off_t startsector, size_t *numsectors);
int vdisk_read(void *userdata, void *buffer, off_t startsector,
size_t *numsectors);
__attribute__((__stdcall__))
int vdisk_write(void *userdata, void *buffer, off_t startsector, size_t *numsectors);
int vdisk_write(void *userdata, void *buffer, off_t startsector,
size_t *numsectors);
__attribute__((__stdcall__))
int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo);
__attribute__((__stdcall__))
unsigned int vdisk_adjust_cache_size(void *userdata, unsigned int suggested_size);
unsigned int vdisk_adjust_cache_size(void *userdata, unsigned suggested_size);
#endif // VDISK_H_INCLUDED