/* * resourced * * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include "lowmem-limit-env.hpp" #include "lowmem-mock.hpp" #define WRAP_LIMIT(rettype, name, def_args, call_args) \ WRAP(global_test_lowmem_limit_env, rettype, name, def_args, call_args) WRAP_LIMIT(int, kill, (pid_t pid, int sig), (pid, sig)) WRAP_LIMIT(ssize_t, read, (int fd, void *buf, size_t count), (fd, buf, count)) WRAP_LIMIT(int, access, (const char *pathname, int mode), (pathname, mode)) #define MOCK_LIMIT(rettype, name, def_args, call_args) \ MOCK(global_test_lowmem_limit_env, rettype, name, def_args, call_args) /* mocking other module dependencies for lowmem-limit.c */ MOCK_LIMIT(int, proc_get_mem_usage, (pid_t pid, unsigned int *usage), (pid, usage)) MOCK_LIMIT(int, proc_get_cmdline, (pid_t pid, char *cmdline, size_t maxcmdline), (pid, cmdline, maxcmdline)) MOCK_LIMIT(proc_app_info *, find_app_info, (const pid_t pid), (pid)) MOCK_LIMIT(int, exec_cmd, (int argc, const char *argv[]), (argc, argv)) MOCK_LIMIT(void, make_memps_log, (enum mem_log path, pid_t pid, char *victim_name), (path, pid, victim_name)) MOCK_LIMIT(resourced_ret_c, cgroup_write_pid_fullpath, (const char *cgroup_full_path, const int pid), (cgroup_full_path, pid)) MOCK_LIMIT(int, cgroup_get_pids, (const char *name, GArray **pids), (name, pids)) MOCK_LIMIT(int, cgroup_write_node_uint32, (const char *cgroup_name, const char *file_name, uint32_t value), (cgroup_name, file_name, value)) MOCK_LIMIT(int, cgroup_read_node_uint32, (const char *cgroup_name, const char *file_name, uint32_t *value), (cgroup_name, file_name, value)) MOCK_LIMIT(int, cgroup_get_memory_stat, (const char *name, struct cgroup_memory_stat **mem_stat), (name, mem_stat)) MOCK_LIMIT(int, cgroup_make_subdir, (const char* parentdir, const char* cgroup_name, bool *already), (parentdir, cgroup_name, already)) MOCK_LIMIT(int, d_bus_broadcast_signal_gvariant, (const char *path, const char *interface, const char *name, GVariant *gv), (path, interface, name, gv)) MOCK_LIMIT(int, request_helper_worker, (enum helper_worker_operation op, void *data, int (*function) (void *data), void *callback), (op, data, function, reinterpret_cast(callback))) MOCK_LIMIT(int, memcg_set_eventfd, (const char *memcg, const char *event, char *value), (memcg, event, value)) MOCK_LIMIT(int, add_fd_read_handler, (int fd, fd_changed_cb callback, void *data, release_cb free_func, fd_handler_h *handler), (fd, callback, data, free_func, handler)) MOCK_LIMIT(unsigned long, lowmem_get_ktotalram, (void), ()) MOCK_LIMIT(int, config_parse, (const char *file_name, int cb(struct parse_result *result, void *user_data), void *user_data), (file_name, cb, user_data))