Some rounds of write/read in libc fs test

The test performs several rounds of write-read cycles with the following
configuration attributes in a <write-read> config node

  rounds       determines the number of rounds (default is 4)
  size         determines the number of bytes written/read in one round
               (default is 4 MiB)
  buffer_size  determines the size of the write-read buffer
               (default is 32 KiB)

In one round the test writes and reads "size/buffer_size" times
from/into a buffer_size'd buffer.
This commit is contained in:
Christian Helmuth 2015-11-12 11:54:12 +01:00
parent a0d92fcdb8
commit db3a5a3b02
5 changed files with 80 additions and 7 deletions

View File

@ -80,7 +80,10 @@ append config "
append config {
<resource name="RAM" quantum="8M"/>
<config>
<iterations value="1"/>
<iterations value="1"/>}
append_if [have_include "power_on/qemu"] config {
<write-read size="1M" buffer_size="8K"/>}
append config {
<libc stdout="/dev/log" stderr="/dev/log">
<vfs>
<dir name="dev">}

View File

@ -19,7 +19,7 @@ create_boot_directory
# Generate config
#
install_config {
set config {
<config>
<parent-provides>
<service name="ROM"/>
@ -29,6 +29,7 @@ install_config {
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
<service name="SIGNAL"/>
</parent-provides>
<start name="test-libc_vfs">
<resource name="RAM" quantum="2M"/>
@ -36,7 +37,10 @@ install_config {
<any-service> <parent/> </any-service>
</route>
<config>
<iterations value="1"/>
<iterations value="1"/>}
append_if [have_include "power_on/qemu"] config {
<write-read size="1M" buffer_size="8K"/>}
append config {
<libc stdout="/dev/log" cwd="/tmp" >
<vfs>
<dir name="tmp" >
@ -50,6 +54,8 @@ install_config {
</config>
}
install_config $config
#
# Boot modules
#

View File

@ -16,7 +16,7 @@ create_boot_directory
# Generate config
#
install_config {
set config {
<config>
<parent-provides>
<service name="ROM"/>
@ -39,7 +39,10 @@ install_config {
<start name="test-libc_vfs">
<resource name="RAM" quantum="2M"/>
<config>
<iterations value="1"/>
<iterations value="1"/>}
append_if [have_include "power_on/qemu"] config {
<write-read size="1M" buffer_size="8K"/>}
append config {
<libc stdout="/dev/log" cwd="/tmp" >
<vfs>
<dir name="tmp" >
@ -53,6 +56,8 @@ install_config {
</config>
}
install_config $config
#
# Boot modules
#

View File

@ -16,7 +16,7 @@ create_boot_directory
# Generate config
#
install_config {
set config {
<config>
<parent-provides>
<service name="ROM"/>
@ -42,7 +42,10 @@ install_config {
<start name="test-libc_vfs">
<resource name="RAM" quantum="2M"/>
<config>
<iterations value="1"/>
<iterations value="1"/>}
append_if [have_include "power_on/qemu"] config {
<write-read size="1M" buffer_size="8K"/>}
append config {
<libc stdout="/dev/log" cwd="/tmp" >
<vfs>
<dir name="tmp" >
@ -56,6 +59,8 @@ install_config {
</config>
}
install_config $config
#
# Boot modules
#

View File

@ -19,6 +19,7 @@
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <unistd.h>
@ -26,6 +27,57 @@
#include <errno.h>
static void test_write_read()
{
size_t rounds = 4;
size_t size = 4*1024*1024;
size_t buffer_size = 32*1024;
try {
Genode::Xml_node config = Genode::config()->xml_node().sub_node("write-read");
try { config.attribute("rounds").value(&rounds); } catch (...) { }
Genode::Number_of_bytes n;
try {
config.attribute("size").value(&n);
size = n;
} catch (...) { }
try {
config.attribute("buffer_size").value(&n);
buffer_size = n;
} catch (...) { }
} catch (...) { }
void *buf = malloc(buffer_size);
char const *file_name = "write_read.tst";
printf("write-read test: %zu rounds of %zu MiB (buffer size %zu)\n",
rounds, size/(1024*1024), buffer_size);
for (unsigned round = 0; buf && round < rounds; ++round) {
printf("starting round %u\n", round);
unlink(file_name);
int fd = open(file_name, O_CREAT | O_RDWR);
memset(buf, round, buffer_size);
/* write-read i_max times the buffer */
unsigned const i_max = size/buffer_size;
for (unsigned i = 0; i < i_max; ++i) write(fd, buf, buffer_size);
lseek(fd, SEEK_SET, 0);
for (unsigned i = 0; i < i_max; ++i) read(fd, buf, buffer_size);
close(fd);
printf("finished round %u\n", round);
}
free(buf);
}
#define CALL_AND_CHECK(ret, operation, condition, info_string, ...) \
printf("calling " #operation " " info_string "\n", ##__VA_ARGS__); \
ret = operation; \
@ -234,6 +286,8 @@ int main(int argc, char *argv[])
sleep(2);
}
test_write_read();
printf("test finished\n");
return 0;