mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
test/libc_many_writes for examining write batching
This test reveals the patters of the batching of consecutive write operations on a file-system session. It issues 100 writes of one byte each, which should ideally result in large batches of operations submitted to the file-system session at once. The run script performs the write operations through a chain of two VFS servers, thereby exercising the write batching of both the libc and the intermediate VFS server. Issue #4697
This commit is contained in:
parent
6edede0db9
commit
9421a449ab
86
repos/libports/run/libc_many_writes.run
Normal file
86
repos/libports/run/libc_many_writes.run
Normal file
@ -0,0 +1,86 @@
|
||||
build {
|
||||
core lib/ld init timer
|
||||
lib/vfs lib/vfs_audit server/vfs
|
||||
lib/libc lib/posix test/libc_many_writes
|
||||
}
|
||||
|
||||
create_boot_directory
|
||||
|
||||
install_config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="CPU"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="LOG"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="ROM"/>
|
||||
</parent-provides>
|
||||
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
|
||||
<default caps="128"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="ramfs">
|
||||
<binary name="vfs"/>
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="File_system"/> </provides>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="ram"> <ram/> </dir>
|
||||
<dir name="audit"> <audit path="ram"/> </dir>
|
||||
</vfs>
|
||||
<default-policy root="/audit" writeable="yes"/>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="fs">
|
||||
<binary name="vfs"/>
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="File_system"/> </provides>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="fs"> <fs/> </dir>
|
||||
<dir name="audit"> <audit path="fs"/> </dir>
|
||||
</vfs>
|
||||
<default-policy root="/audit" writeable="yes"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="File_system"> <child name="ramfs"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="test-libc_many_writes" caps="1000">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="rw"> <fs/> </dir>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log"/>
|
||||
<arg value="test"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="File_system"> <child name="fs"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image [build_artifacts]
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until "child .* exited with exit value 0.*\n" 20
|
||||
|
59
repos/libports/src/test/libc_many_writes/main.c
Normal file
59
repos/libports/src/test/libc_many_writes/main.c
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* \brief Libc test stressing the batching of write operations
|
||||
* \author Norman Feske
|
||||
* \date 2022-12-01
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
static void print_time(char const *msg)
|
||||
{
|
||||
struct timespec tp;
|
||||
bzero(&tp, sizeof(tp));
|
||||
|
||||
int res = clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
if (res != 0) {
|
||||
printf("error: clock_gettime failed (%d)\n", res);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("%s: %ld s %ld ms\n", msg, tp.tv_sec, tp.tv_nsec/1000000);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char const * const path = "/rw/data";
|
||||
|
||||
int const fd = open(path, O_CREAT | O_RDWR);
|
||||
if (fd < 0)
|
||||
printf("error: creation of file '%s' failed (%d)\n", path, fd);
|
||||
|
||||
print_time("start");
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
printf("write\n");
|
||||
unsigned char c = i & 0xffu;
|
||||
write(fd, &c, 1);
|
||||
}
|
||||
|
||||
print_time("end");
|
||||
|
||||
close(fd);
|
||||
|
||||
printf("exiting\n");
|
||||
return 0;
|
||||
}
|
3
repos/libports/src/test/libc_many_writes/target.mk
Normal file
3
repos/libports/src/test/libc_many_writes/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-libc_many_writes
|
||||
SRC_C = main.c
|
||||
LIBS = posix
|
Loading…
x
Reference in New Issue
Block a user