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 /hd0/1: xfs
/> ls70 /hd0/1/sf_empty /> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2 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_empty
ls70 /hd0/1/sf ls70 /hd0/1/sf
ls70 /hd0/1/block 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 /hd0/1: xfs
/> ls70 /hd0/1/sf_empty /> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2 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_empty
ls70 /hd0/1/sf ls70 /hd0/1/sf
ls70 /hd0/1/block 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 /hd0/1: xfs
# zero length # zero length
/> read70 /hd0/1/no_hole 0 0 -b /> 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 # zero length
read70 /hd0/1/no_hole 0 0 -b read70 /hd0/1/no_hole 0 0 -b
read70 /hd0/1/no_hole 1 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 /hd0/1: xfs
/> stat70 /hd0/1/ /> stat70 /hd0/1/
status = 0 success 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/
stat70 /hd0/1/hole_begin stat70 /hd0/1/hole_begin
disk_del hd0 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 /hd0/1: xfs
/> pwd /> 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 pwd
cd /hd0 cd /hd0
pwd 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 /hd0/1: xfs
# hole begin # hole begin
# zero length # 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 # hole begin
# zero length # zero length
read70 /hd0/1/hole_begin 0 0 -b 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 /hd0/1: xfs
/> stat70 /hd0/1/sf_empty /> stat70 /hd0/1/sf_empty
status = 0 success 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/. 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 /hd0/1: xfs
/> ls70 /hd0/1/sf /> ls70 /hd0/1/sf
status = 6 end_of_file, count = 5 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/sf
ls70 /hd0/1/block ls70 /hd0/1/block
ls70 /hd0/1/leaf 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 /hd0/1: xfs
/> ls70 /hd0/1/sf_empty /> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2 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_empty
ls70 /hd0/1/sf ls70 /hd0/1/sf
ls70 /hd0/1/block 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 /hd0/1: xfs
/> stat70 /hd0/1/sf_empty /> stat70 /hd0/1/sf_empty
status = 0 success 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/. 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 /hd0/1: xfs
/> stat80 /hd0/1/dir0 /> 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
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 /hd0/1: xfs
/> ls70 /hd0/1/sf_empty /> ls70 /hd0/1/sf_empty
status = 6 end_of_file, count = 2 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_empty
ls70 /hd0/1/sf ls70 /hd0/1/sf
ls70 /hd0/1/block 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 /hd0/1: xfs
/> stat70 /hd0/1/sf_empty /> stat70 /hd0/1/sf_empty
status = 0 success 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/. 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 /hd0/1: xfs
# hole begin # hole begin
# zero length # 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 # hole begin
# zero length # zero length
read70 /hd0/1/hole_begin 0 0 -b 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 /hd0/1: xfs
# zero length # zero length
/> read70 /hd0/1/no_hole 0 0 -b /> 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 # zero length
read70 /hd0/1/no_hole 0 0 -b read70 /hd0/1/no_hole 0 0 -b
read70 /hd0/1/no_hole 1 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 /rd/1: fat
/> set_skin /sys/DEFAULT.SKN /> set_skin /sys/DEFAULT.SKN
status: 0 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 set_skin /sys/DEFAULT.SKN
window_redraw 1 window_redraw 1
draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello 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 %.out.log: %.ref.log %.t
$(UMKA_SHELL) < $*.t > $@ $(UMKA_SHELL) < $*.t > $@
@ cmp $@ $< @ cmp $*.{out,ref}.log
@ if [ -f "$*.ref.png" ]; then cmp $*.out.png $*.ref.png; fi @ if [ -f "$*.ref.png" ]; then cmp $*.{out,ref}.png; fi
coverage: coverage:
../covpreproc ../umka.lst 0x34 coverage.* > ../umka.cov ../covpreproc ../umka.lst 0x34 coverage.* > ../umka.cov

View File

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

View File

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

View File

@ -62,7 +62,7 @@ diskfunc_t vdisk_functions = {
.read = vdisk_read, .read = vdisk_read,
.write = vdisk_write, .write = vdisk_write,
.flush = NULL, .flush = NULL,
.adjust_cache_size = vdisk_adjust_cache_size, .adjust_cache_size = NULL,
}; };
char cur_dir[PATH_MAX] = "/"; char cur_dir[PATH_MAX] = "/";
const char *last_dir = cur_dir; 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 umka_disk_add(int argc, char **argv) {
(void)argc; const char *usage = \
const char *file_name = argv[1]; "usage: disk_add <file> <name> [option]...\n"
const char *disk_name = argv[2]; " <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) { if (userdata) {
void *vdisk = disk_add(&vdisk_functions, disk_name, userdata, 0); void *vdisk = disk_add(&vdisk_functions, disk_name, userdata, 0);
if (vdisk) { if (vdisk) {

21
vdisk.c
View File

@ -7,11 +7,12 @@
typedef struct { typedef struct {
FILE *file; FILE *file;
uint64_t sect_cnt;
uint32_t sect_size; uint32_t sect_size;
uint64_t sect_cnt;
unsigned cache_size;
} vdisk_t; } vdisk_t;
void *vdisk_init(const char *fname) { void *vdisk_init(const char *fname, unsigned cache_size) {
FILE *f = fopen(fname, "r+"); FILE *f = fopen(fname, "r+");
if (!f) { if (!f) {
printf("vdisk: can't open file '%s': %s\n", fname, strerror(errno)); 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; sect_size = 4096;
} }
vdisk_t *vdisk = (vdisk_t*)malloc(sizeof(vdisk_t)); 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; return vdisk;
} }
@ -37,7 +41,8 @@ void vdisk_close(void *userdata) {
} }
__attribute__((__stdcall__)) __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; vdisk_t *vdisk = userdata;
fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET); fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET);
fread(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file); 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__)) __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; vdisk_t *vdisk = userdata;
fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET); fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET);
fwrite(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file); fwrite(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file);
@ -62,8 +68,7 @@ int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo) {
} }
__attribute__((__stdcall__)) __attribute__((__stdcall__))
unsigned int vdisk_adjust_cache_size(void *userdata, unsigned int suggested_size) { unsigned vdisk_adjust_cache_size(vdisk_t *vdisk, unsigned suggested_size) {
(void)userdata;
(void)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 <inttypes.h>
#include "kolibri.h" #include "kolibri.h"
void *vdisk_init(const char *fname); void *vdisk_init(const char *fname, unsigned cache_size);
__attribute__((__stdcall__)) __attribute__((__stdcall__))
void vdisk_close(void *userdata); void vdisk_close(void *userdata);
__attribute__((__stdcall__)) __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__)) __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__)) __attribute__((__stdcall__))
int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo); int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo);
__attribute__((__stdcall__)) __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 #endif // VDISK_H_INCLUDED