Skip to content

Commit e35663d

Browse files
committed
test: add syslog_facility unit test cases
1 parent 2844d70 commit e35663d

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ set(TEST_SOURCES
8787
${TEST}/util/unit/ringbuffer.cpp
8888
${TEST}/util/unit/statman.cpp
8989
${TEST}/util/unit/syslogd_test.cpp
90+
${TEST}/util/unit/syslog_facility_test.cpp
9091
${TEST}/util/unit/tar_test.cpp
9192
${TEST}/util/unit/uri_test.cpp
9293
)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// This file is a part of the IncludeOS unikernel - www.includeos.org
2+
//
3+
// Copyright 2015-2017 Oslo and Akershus University College of Applied Sciences
4+
// and Alfred Bratterud
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
#include <common.cxx>
19+
#include <util/syslog_facility.hpp>
20+
21+
CASE("facility-related functions get/set facility, facility_name() returns facility name as string")
22+
{
23+
Syslog_facility sf;
24+
// default created with LOG_USER
25+
EXPECT(sf.facility_name() == "USER");
26+
sf.set_facility(LOG_MAIL);
27+
EXPECT(sf.facility_name() == "MAIL");
28+
EXPECT(sf.facility() == LOG_MAIL);
29+
}
30+
31+
CASE("ident-related functions get/set ident, returns whether ident is set")
32+
{
33+
Syslog_facility sf;
34+
EXPECT(sf.ident_is_set() == false);
35+
sf.set_ident("foo");
36+
EXPECT(sf.ident_is_set() == true);
37+
EXPECT(sf.ident() == "foo");
38+
}
39+
40+
CASE("priority-related functions get/set priority")
41+
{
42+
Syslog_facility sf;
43+
sf.set_priority(LOG_CRIT);
44+
EXPECT_NOT(sf.priority() == LOG_INFO);
45+
EXPECT(sf.priority() == LOG_CRIT);
46+
EXPECT(sf.priority_name() == "CRIT");
47+
}
48+
49+
CASE("logopt-related functions get/set logopt")
50+
{
51+
Syslog_facility sf("bar", LOG_INTERNAL);
52+
sf.set_logopt(LOG_NOWAIT);
53+
EXPECT_NOT(sf.logopt() == LOG_USER);
54+
EXPECT(sf.logopt() == (LOG_NOWAIT));
55+
}

0 commit comments

Comments
 (0)