blob: 49403e1c7ee619ed338ee85672ad6bf60897bb49 [file] [log] [blame]
Andrew Walbranf3ac84d2019-07-26 16:10:02 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "hf/dlog.h"
18
19#include "hftest.h"
20
21/**
22 * Test that logs are written to the buffer, and the rest is empty.
23 */
24TEST(dlog, log_buffer)
25{
26 const char test_string[] = "Test string\n";
27
28 dlog(test_string);
29 ASSERT_EQ(strcmp(test_string, dlog_buffer), 0);
30 /* The \0 at the end shouldn't be counted. */
31 ASSERT_EQ(dlog_buffer_offset, sizeof(test_string) - 1);
32 for (int i = sizeof(test_string) - 1; i < DLOG_BUFFER_SIZE; ++i) {
33 EXPECT_EQ(dlog_buffer[i], '\0');
34 }
35}