mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
libc counter test
This commit is contained in:
parent
f8349b5bc7
commit
ba1bd071df
84
repos/libports/run/libc_counter.run
Normal file
84
repos/libports/run/libc_counter.run
Normal file
@ -0,0 +1,84 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core init drivers/timer server/terminal_crosslink test/libc_counter
|
||||
}
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
<start name="terminal_crosslink">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Terminal"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="test-libc_counter-source">
|
||||
<resource name="RAM" quantum="8M"/>
|
||||
<config ld_verbose="yes">
|
||||
<vfs>
|
||||
<dir name="dev"> <terminal/> <log/> </dir>
|
||||
</vfs>
|
||||
<libc stdin="/dev/terminal" stdout="/dev/terminal" stderr="/dev/log"/>
|
||||
</config>
|
||||
</start>
|
||||
<start name="test-libc_counter-sink">
|
||||
<resource name="RAM" quantum="8M"/>
|
||||
<config ld_verbose="yes">
|
||||
<vfs>
|
||||
<dir name="dev"> <terminal/> <log/> <null/> </dir>
|
||||
</vfs>
|
||||
<libc stdin="/dev/terminal" stdout="/dev/terminal" stderr="/dev/log"/>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
|
||||
set boot_modules {
|
||||
core init timer terminal_crosslink
|
||||
test-libc_counter-source test-libc_counter-sink
|
||||
ld.lib.so libc.lib.so libm.lib.so
|
||||
}
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args "-nographic -m 64"
|
||||
|
||||
#
|
||||
# Execute test case
|
||||
#
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
# vi: set ft=tcl :
|
44
repos/libports/src/test/libc_counter/sink/main.cc
Normal file
44
repos/libports/src/test/libc_counter/sink/main.cc
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* \brief LibC counter test - sink
|
||||
* \author Christian Helmuth
|
||||
* \date 2017-01-31
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* libc includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
enum { MAX_COUNT = 10 };
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stderr, "--- counter sink started ---\n");
|
||||
|
||||
static char buf[32];
|
||||
|
||||
/* stdin/stdout are connected to the source */
|
||||
for (unsigned i = 0; i < MAX_COUNT; ++i) {
|
||||
int nbytes = 0;
|
||||
|
||||
/* XXX busy loop - read does not block */
|
||||
unsigned retry = 0;
|
||||
while (0 == (nbytes = read(0, buf, sizeof(buf)))) ++retry;
|
||||
fprintf(stderr, "nbytes=%d retry=%u\n", nbytes, retry);
|
||||
buf[31] = 0;
|
||||
fprintf(stderr, "buf=\"%s\"\n", buf);
|
||||
}
|
||||
|
||||
fprintf(stderr, "--- counter sink terminates ---\n");
|
||||
}
|
3
repos/libports/src/test/libc_counter/sink/target.mk
Normal file
3
repos/libports/src/test/libc_counter/sink/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-libc_counter-sink
|
||||
SRC_CC = main.cc
|
||||
LIBS = posix
|
38
repos/libports/src/test/libc_counter/source/main.cc
Normal file
38
repos/libports/src/test/libc_counter/source/main.cc
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* \brief LibC counter test - source
|
||||
* \author Christian Helmuth
|
||||
* \date 2017-01-31
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* libc includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
enum { MAX_COUNT = 10 };
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stderr, "--- counter source started ---\n");
|
||||
|
||||
static char buf[32];
|
||||
|
||||
/* stdin/stdout are connected to the source */
|
||||
for (unsigned i = 0; i < MAX_COUNT; ++i) {
|
||||
int nbytes = snprintf(buf, sizeof(buf), "%u.", i);
|
||||
nbytes = write(1, buf, nbytes);
|
||||
fprintf(stderr, "nbytes=%d\n", nbytes);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "--- counter source terminates ---\n");
|
||||
}
|
3
repos/libports/src/test/libc_counter/source/target.mk
Normal file
3
repos/libports/src/test/libc_counter/source/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-libc_counter-source
|
||||
SRC_CC = main.cc
|
||||
LIBS = posix
|
Loading…
Reference in New Issue
Block a user