|
| 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