2 * Copyright (c) 2018-2020, Samsung Electronics Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <loglimiter.h>
27 #include <loglimiter-internal.h>
29 static size_t get_rulecount()
32 struct rule *r = NULL;
35 assert(!__log_limiter_dump_rule(&r, buf, sizeof buf));
41 static int fail_snprintf;
42 int __wrap_snprintf(char *str, size_t size, const char *format, ...)
44 if (fail_snprintf && !--fail_snprintf)
49 const int ret = vsnprintf(str, size, format, va);
54 static int fail_malloc;
55 void *__real_malloc(size_t size);
56 void *__wrap_malloc(size_t size)
58 return (fail_malloc == 1 && size == sizeof(struct rule))
59 || (fail_malloc == 2 && size != sizeof(struct rule))
65 static bool fail_time;
66 static bool future_time;
67 time_t __real_time(time_t *t);
68 time_t __wrap_time(time_t *t)
73 return __real_time(t) + (future_time ? 40000 : 0);