mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 18:06:50 +00:00
Limit max string length in log session for okl4
This commit also adds a test to test-log.
This commit is contained in:
parent
487162a53d
commit
0da420c104
@ -44,7 +44,7 @@ struct Genode::Log_session : Session
|
||||
virtual ~Log_session() { }
|
||||
|
||||
/* the lowest platform-specific maximum IPC payload size (OKL4) */
|
||||
enum { MAX_STRING_LEN = 236};
|
||||
enum { MAX_STRING_LEN = 232 };
|
||||
|
||||
typedef Rpc_in_buffer<MAX_STRING_LEN> String;
|
||||
|
||||
|
@ -27,7 +27,7 @@ append xen_args { sdl="0" }
|
||||
|
||||
run_genode_until "Test done.*\n" 20
|
||||
|
||||
grep_output {\[init -\> test-log\]}
|
||||
grep_output {\[init -\> test-log}
|
||||
|
||||
compare_output_to {
|
||||
[init -> test-log] hex range: [0e00,1680)
|
||||
@ -38,5 +38,10 @@ compare_output_to {
|
||||
[init -> test-log] positive hex char: 0x02
|
||||
[init -> test-log] multiarg string: "parent -> child.7"
|
||||
[init -> test-log] String(Hex(3)): 0x3
|
||||
[init -> test-log] Very long messages:
|
||||
[init -> test-log -> log] 1.....................................................................................................................................................................................................................................2
|
||||
[init -> test-log] 3.....................................................................................................................................................................................................................................4
|
||||
[init -> test-log] 5.....................................................................................................................................................................................................................................6
|
||||
[init -> test-log]
|
||||
[init -> test-log] Test done.
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* \brief Testing 'log()' with negative integer
|
||||
* \brief Testing 'Genode::log()' and LOG session
|
||||
* \author Christian Prochaska
|
||||
* \date 2012-04-20
|
||||
*
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <log_session/connection.h>
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
@ -33,5 +34,26 @@ void Component::construct(Genode::Env &env)
|
||||
String<32> hex(Hex(3));
|
||||
log("String(Hex(3)): ", hex);
|
||||
|
||||
log("Very long messages:");
|
||||
|
||||
static char buf[2*Log_session::MAX_STRING_LEN];
|
||||
|
||||
/* test writing of message with length = MAX_STRING_LEN with LOG connection */
|
||||
for (char &c : buf) c = '.';
|
||||
buf[0] = '1'; /* begin of line */
|
||||
buf[Log_session::MAX_STRING_LEN - 2] = '2'; /* last visible */
|
||||
buf[Log_session::MAX_STRING_LEN - 1] = '\0'; /* end of line */
|
||||
Log_connection log_connection { env, "log" };
|
||||
log_connection.write(buf);
|
||||
|
||||
/* test splitting of message with length > MAX_STRING_LEN with 'Genode::log()' */
|
||||
for (char &c : buf) c = '.';
|
||||
buf[0] = '3'; /* begin of first line */
|
||||
buf[Log_session::MAX_STRING_LEN - 2] = '4'; /* last visible before flushed */
|
||||
buf[Log_session::MAX_STRING_LEN - 1] = '5'; /* first after flush */
|
||||
buf[2*Log_session::MAX_STRING_LEN - 3] = '6'; /* last visible before flushed */
|
||||
buf[2*Log_session::MAX_STRING_LEN - 2] = '\0'; /* end of second line */
|
||||
log(Cstring(buf));
|
||||
|
||||
log("Test done.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user