1
/* Copyright 2013-2014 IBM Corp.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
25
#define _printf printf
27
static inline unsigned long mftb(void)
32
int _printf(const char* fmt, ...);
34
#include "../console-log.c"
36
struct debug_descriptor debug_descriptor;
38
bool flushed_to_drivers;
39
char console_buffer[4096];
41
ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
43
flushed_to_drivers = flush_to_drivers;
44
memcpy(console_buffer, buf, count);
50
debug_descriptor.console_log_levels = 0x75;
52
prlog(PR_EMERG, "Hello World");
53
assert(memcmp(console_buffer, "[42,0] Hello World", strlen("[42,0] Hello World")) == 0);
54
assert(flushed_to_drivers==true);
56
memset(console_buffer, 0, sizeof(console_buffer));
59
prlog(PR_TRACE, "Hello World");
60
assert(console_buffer[0] == 0);
62
// Should not be flushed to console
63
prlog(PR_DEBUG, "Hello World");
64
assert(memcmp(console_buffer, "[42,7] Hello World", strlen("[42,7] Hello World")) == 0);
65
assert(flushed_to_drivers==false);
67
printf("Hello World");
68
assert(memcmp(console_buffer, "[42,5] Hello World", strlen("[42,5] Hello World")) == 0);
69
assert(flushed_to_drivers==true);