mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-31 06:31:10 +00:00
Test for combining select with a pipe
The test exercises the VFS's read-ready mechanism when using the vfs_pipe plugin. Issue #4785
This commit is contained in:
parent
2c1b51be65
commit
bd3936c7ed
@ -692,6 +692,7 @@ set default_test_pkgs {
|
|||||||
test-nic_loopback
|
test-nic_loopback
|
||||||
test-part_block_gpt
|
test-part_block_gpt
|
||||||
test-part_block_mbr
|
test-part_block_mbr
|
||||||
|
test-pipe_read_ready
|
||||||
test-pthread
|
test-pthread
|
||||||
test-ram_fs_chunk
|
test-ram_fs_chunk
|
||||||
test-read_only_rom
|
test-read_only_rom
|
||||||
|
1
repos/libports/recipes/pkg/test-pipe_read_ready/README
Normal file
1
repos/libports/recipes/pkg/test-pipe_read_ready/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
Test for using select to wait for a pipe at a VFS server
|
6
repos/libports/recipes/pkg/test-pipe_read_ready/archives
Normal file
6
repos/libports/recipes/pkg/test-pipe_read_ready/archives
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
_/src/init
|
||||||
|
_/src/libc
|
||||||
|
_/src/vfs
|
||||||
|
_/src/vfs_pipe
|
||||||
|
_/src/posix
|
||||||
|
_/src/test-pipe_read_ready
|
1
repos/libports/recipes/pkg/test-pipe_read_ready/hash
Normal file
1
repos/libports/recipes/pkg/test-pipe_read_ready/hash
Normal file
@ -0,0 +1 @@
|
|||||||
|
2023-03-15 2d8860bc863bcb722b03982ec1b68bc21fcf6553
|
73
repos/libports/recipes/pkg/test-pipe_read_ready/runtime
Normal file
73
repos/libports/recipes/pkg/test-pipe_read_ready/runtime
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<runtime ram="32M" caps="1000" binary="init">
|
||||||
|
|
||||||
|
<requires> <timer/> </requires>
|
||||||
|
|
||||||
|
<events>
|
||||||
|
<timeout meaning="failed" sec="30" />
|
||||||
|
<log meaning="succeeded">[init -> select] 3</log>
|
||||||
|
</events>
|
||||||
|
|
||||||
|
<content>
|
||||||
|
<rom label="ld.lib.so"/>
|
||||||
|
<rom label="libc.lib.so"/>
|
||||||
|
<rom label="libm.lib.so"/>
|
||||||
|
<rom label="posix.lib.so"/>
|
||||||
|
<rom label="vfs"/>
|
||||||
|
<rom label="vfs.lib.so"/>
|
||||||
|
<rom label="vfs_pipe.lib.so"/>
|
||||||
|
<rom label="test-pipe_read_ready_counter"/>
|
||||||
|
<rom label="test-pipe_read_ready_select"/>
|
||||||
|
</content>
|
||||||
|
|
||||||
|
<config>
|
||||||
|
<parent-provides>
|
||||||
|
<service name="ROM"/>
|
||||||
|
<service name="PD"/>
|
||||||
|
<service name="RM"/>
|
||||||
|
<service name="CPU"/>
|
||||||
|
<service name="LOG"/>
|
||||||
|
<service name="Timer"/>
|
||||||
|
</parent-provides>
|
||||||
|
|
||||||
|
<default-route>
|
||||||
|
<any-service> <parent/> <any-child/> </any-service>
|
||||||
|
</default-route>
|
||||||
|
|
||||||
|
<default caps="100"/>
|
||||||
|
|
||||||
|
<start name="vfs">
|
||||||
|
<resource name="RAM" quantum="12M"/>
|
||||||
|
<provides> <service name="File_system"/> </provides>
|
||||||
|
<config>
|
||||||
|
<vfs> <pipe> <fifo name="fifo"/> </pipe> </vfs>
|
||||||
|
<default-policy root="/" writeable="yes"/>
|
||||||
|
</config>
|
||||||
|
</start>
|
||||||
|
|
||||||
|
<start name="select">
|
||||||
|
<resource name="RAM" quantum="3M"/>
|
||||||
|
<binary name="test-pipe_read_ready_select"/>
|
||||||
|
<config>
|
||||||
|
<vfs>
|
||||||
|
<dir name="dev"> <log/> </dir>
|
||||||
|
<dir name="rw"> <fs/> </dir>
|
||||||
|
</vfs>
|
||||||
|
<libc stdin="/rw/fifo" stdout="/dev/log" stderr="/dev/log"/>
|
||||||
|
</config>
|
||||||
|
</start>
|
||||||
|
|
||||||
|
<start name="counter" caps="120">
|
||||||
|
<resource name="RAM" quantum="3M"/>
|
||||||
|
<binary name="test-pipe_read_ready_counter"/>
|
||||||
|
<config>
|
||||||
|
<vfs>
|
||||||
|
<dir name="dev"> <null/> <fs/> <log/> </dir>
|
||||||
|
<dir name="rw"> <fs/> </dir>
|
||||||
|
</vfs>
|
||||||
|
<libc stdin="/dev/null" stdout="/rw/fifo" stderr="/dev/log"/>
|
||||||
|
</config>
|
||||||
|
</start>
|
||||||
|
|
||||||
|
</config>
|
||||||
|
|
||||||
|
</runtime>
|
10
repos/libports/recipes/src/test-pipe_read_ready/content.mk
Normal file
10
repos/libports/recipes/src/test-pipe_read_ready/content.mk
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
MIRROR_FROM_REP_DIR := src/test/pipe_read_ready
|
||||||
|
|
||||||
|
content: $(MIRROR_FROM_REP_DIR) LICENSE
|
||||||
|
|
||||||
|
$(MIRROR_FROM_REP_DIR):
|
||||||
|
$(mirror_from_rep_dir)
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
cp $(GENODE_DIR)/LICENSE $@
|
||||||
|
|
1
repos/libports/recipes/src/test-pipe_read_ready/hash
Normal file
1
repos/libports/recipes/src/test-pipe_read_ready/hash
Normal file
@ -0,0 +1 @@
|
|||||||
|
2023-03-15 b7831174a141db784aa219327a3e40ac726e07f1
|
@ -0,0 +1,2 @@
|
|||||||
|
libc
|
||||||
|
posix
|
23
repos/libports/src/test/pipe_read_ready/counter/main.c
Normal file
23
repos/libports/src/test/pipe_read_ready/counter/main.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* \brief Print counter every second
|
||||||
|
* \author Norman Feske
|
||||||
|
* \date 2023-03-14
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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 <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
for (unsigned count = 0; ; count++) {
|
||||||
|
printf("%d\n", count);
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
TARGET := test-pipe_read_ready_counter
|
||||||
|
SRC_C := main.c
|
||||||
|
LIBS += posix
|
38
repos/libports/src/test/pipe_read_ready/select/main.c
Normal file
38
repos/libports/src/test/pipe_read_ready/select/main.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* \brief Watch stdin using select and forward data to stout
|
||||||
|
* \author Norman Feske
|
||||||
|
* \date 2023-03-15
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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 <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
for (;;) {
|
||||||
|
|
||||||
|
/* wait until stdin becomes ready to read */
|
||||||
|
fd_set fds;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(STDIN_FILENO, &fds);
|
||||||
|
select(1, &fds, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
char buffer[4096];
|
||||||
|
ssize_t const bytes = read(STDIN_FILENO, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
if (bytes == -1)
|
||||||
|
fprintf(stderr, "read failed, errno=%d\n", errno);
|
||||||
|
|
||||||
|
if (bytes > 0)
|
||||||
|
write(STDOUT_FILENO, buffer, bytes);
|
||||||
|
}
|
||||||
|
}
|
3
repos/libports/src/test/pipe_read_ready/select/target.mk
Normal file
3
repos/libports/src/test/pipe_read_ready/select/target.mk
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
TARGET := test-pipe_read_ready_select
|
||||||
|
SRC_C := main.c
|
||||||
|
LIBS += posix
|
Loading…
x
Reference in New Issue
Block a user