support unit test cases of worker related
This commit is contained in:
parent
de090dce35
commit
cf425dfa56
11 changed files with 87 additions and 6084 deletions
|
|
@ -25,8 +25,8 @@ controller_src = [
|
|||
incdir = include_directories('.', '../include', '../lib',
|
||||
'include')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
math_dep = cc.find_library('m', required : false)
|
||||
# cc = meson.get_compiler('c')
|
||||
# math_dep = cc.find_library('m', required : false)
|
||||
|
||||
controller_deps = [libxce_dep, math_dep]
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ endif
|
|||
|
||||
include_dir = include_directories('include', 'include/xce')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
math_dep = cc.find_library('m', required: false)
|
||||
rt_dep = cc.find_library('rt', required: false)
|
||||
|
||||
libcjson_dep = dependency('libcjson')
|
||||
libcyaml_dep = dependency('libcyaml')
|
||||
libyaml_dep = dependency('yaml-0.1')
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ stdenv.mkDerivation {
|
|||
unity_test_with_color
|
||||
libcyaml
|
||||
libyaml
|
||||
libcgroup
|
||||
];
|
||||
|
||||
build-system = [ pkgs.meson ];
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ incdir = include_directories('.', 'include', '../include', '../lib')
|
|||
libuv_dep = dependency('libuv')
|
||||
elogind_dep = dependency('libelogind')
|
||||
sqlite3_dep = dependency('sqlite3')
|
||||
|
||||
libcgroup_dep = dependency('libcgroup')
|
||||
|
||||
xcecd_worker_deps = [
|
||||
libxce_dep,
|
||||
libcgroup_dep,
|
||||
libuv_dep,
|
||||
elogind_dep,
|
||||
sqlite3_dep,
|
||||
|
|
@ -53,7 +54,7 @@ xcecd_srcs = [
|
|||
'src/xcecd_exdata.c',
|
||||
'src/xcecd_cgroups.c',
|
||||
'src/xcecd_dbus_manager.c',
|
||||
'src/main.c',
|
||||
# 'src/main.c',
|
||||
'src/xcecd.c',
|
||||
'src/thread_pool.c',
|
||||
'src/system_monitor.c',
|
||||
|
|
@ -72,15 +73,59 @@ hwloc_dep = dependency('hwloc')
|
|||
|
||||
xcecd_deps = [xcecd_worker_deps,hwloc_dep]
|
||||
xcecd = executable('xcecd',
|
||||
xcecd_srcs,
|
||||
[xcecd_srcs,'src/main.c'],
|
||||
c_args: ['-DDBUS_MANAGER'],
|
||||
include_directories: [incdir],
|
||||
dependencies: [xcecd_deps],
|
||||
install: true)
|
||||
|
||||
xcecd_virtual = executable('xcecd_virtual',
|
||||
xcecd_srcs,
|
||||
[xcecd_srcs,'src/main.c'],
|
||||
c_args: ['-DVIRTUAL_CLUSTER', '-DDBUS_MANAGER'],
|
||||
include_directories: [incdir],
|
||||
dependencies:[xcecd_deps],
|
||||
install:true)
|
||||
|
||||
include_dir_test = include_directories('test')
|
||||
|
||||
xce_test_deps = xcecd_deps
|
||||
xce_sched_test = executable('xce_sched_test',
|
||||
[xcecd_srcs, 'test/xce_sched_test.c'],
|
||||
include_directories: [incdir,include_dir_test],
|
||||
dependencies: [xce_test_deps],
|
||||
install: true)
|
||||
|
||||
unity_deps = dependency('unity')
|
||||
xcecd_daemon_test = executable('xcecd_daemon_test',
|
||||
[xcecd_srcs, 'test/xcecd_daemon_test.c'],
|
||||
include_directories: [incdir, include_dir_test],
|
||||
dependencies: [xce_test_deps, unity_deps],
|
||||
install: true)
|
||||
|
||||
xcecd_worker_test = executable('xcecd_worker_test',
|
||||
[xcecd_srcs, 'test/xcecd_worker_test.c'],
|
||||
include_directories: [incdir, include_dir_test],
|
||||
dependencies: [xce_test_deps, unity_deps],
|
||||
install: true)
|
||||
|
||||
# cgroup_srcs = [
|
||||
# 'src/xcecd_cgroups.c',
|
||||
# 'test/cgroup_test.c'
|
||||
# ]
|
||||
|
||||
# cgroup_test = executable('cgroup_test',
|
||||
# cgroup_srcs,
|
||||
# include_directories: [incdir, include_dir_test],
|
||||
# dependencies: [xce_test_deps, unity_deps],
|
||||
# install: true)
|
||||
|
||||
limit_test_srcs = [
|
||||
'test/limit_test.c'
|
||||
]
|
||||
|
||||
|
||||
limit_test = executable('limit_test',
|
||||
limit_test_srcs,
|
||||
include_directories: [incdir, include_dir_test],
|
||||
dependencies: [xce_test_deps, unity_deps, math_dep],
|
||||
install: true)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined(DBUS_MANAGER)
|
||||
#include "process_worker_manager.h"
|
||||
#endif
|
||||
|
||||
/* TEMP SOLUTION: use config later */
|
||||
#define LOG_SIZE (1024 * 1024 * 100) // 100 MB
|
||||
#define LOG_LEVEL 2 // DEBUG level
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "process_worker_manager.h"
|
||||
|
||||
xcecd_context_t xcecd_ctx = { 0 };
|
||||
hostattrs_t host_attrs = { 0 };
|
||||
|
||||
|
|
@ -68,7 +70,7 @@ void xcecd_process_command(void* arg)
|
|||
}
|
||||
|
||||
/* adding worker to worker list,and update worker pid */
|
||||
int pid = get_current_process_pid(ctx->manager);
|
||||
pid = get_current_process_pid(ctx->manager);
|
||||
if (pid != -1) {
|
||||
|
||||
add_worker(&xcecd_ctx.worker_list, pid, WORKER_RUNNING, ctx->xce_jobid,
|
||||
|
|
@ -726,4 +728,4 @@ bool xcecd_check_restart_type(void)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3,10 +3,10 @@
|
|||
#include "../include/system_monitor.h"
|
||||
#include "../include/thread_pool.h"
|
||||
#include "../include/xcecd.h"
|
||||
#include "unity.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unity.h>
|
||||
|
||||
// Mock function declarations
|
||||
static int mock_network_start_called = 0;
|
||||
|
|
@ -29,9 +29,9 @@ void test_xcecd_init_success(void)
|
|||
.resource_update_interval = 5,
|
||||
.job_status_update_interval = 1,
|
||||
.port = 8080,
|
||||
.acct_file_path = "/tmp/xcecd.acct",
|
||||
.log_file_path = "/tmp/xcecd.log",
|
||||
.domain_sock_path = "/tmp/xcecd.sock",
|
||||
.acct_file = "/tmp/xcecd.acct",
|
||||
.log_file = "/tmp/xcecd.log",
|
||||
.domain_sock_file = "/tmp/xcecd.sock",
|
||||
.remote_host = "localhost",
|
||||
.remote_port = 6789,
|
||||
.update_interval = 2 };
|
||||
|
|
@ -53,9 +53,9 @@ void test_xcecd_init_invalid_params(void)
|
|||
.resource_update_interval = 0,
|
||||
.job_status_update_interval = 0,
|
||||
.port = 0,
|
||||
.acct_file_path = NULL,
|
||||
.log_file_path = NULL,
|
||||
.domain_sock_path = NULL,
|
||||
.acct_file = NULL,
|
||||
.log_file = NULL,
|
||||
.domain_sock_file = NULL,
|
||||
.remote_host = NULL,
|
||||
.remote_port = 0,
|
||||
.update_interval = 0 };
|
||||
|
|
@ -77,9 +77,9 @@ void test_xcecd_stop(void)
|
|||
.resource_update_interval = 5,
|
||||
.job_status_update_interval = 1,
|
||||
.port = 8080,
|
||||
.acct_file_path = "/tmp/xcecd.acct",
|
||||
.log_file_path = "/tmp/xcecd.log",
|
||||
.domain_sock_path = "/tmp/xcecd.sock",
|
||||
.acct_file = "/tmp/xcecd.acct",
|
||||
.log_file = "/tmp/xcecd.log",
|
||||
.domain_sock_file = "/tmp/xcecd.sock",
|
||||
.remote_host = "localhost",
|
||||
.remote_port = 6789,
|
||||
.update_interval = 2 };
|
||||
|
|
@ -97,9 +97,9 @@ void test_xcecd_cleanup(void)
|
|||
.resource_update_interval = 5,
|
||||
.job_status_update_interval = 1,
|
||||
.port = 8080,
|
||||
.acct_file_path = "/tmp/xcecd.acct",
|
||||
.log_file_path = "/tmp/xcecd.log",
|
||||
.domain_sock_path = "/tmp/xcecd.sock",
|
||||
.acct_file = "/tmp/xcecd.acct",
|
||||
.log_file = "/tmp/xcecd.log",
|
||||
.domain_sock_file = "/tmp/xcecd.sock",
|
||||
.remote_host = "localhost",
|
||||
.remote_port = 6789,
|
||||
.update_interval = 2 };
|
||||
|
|
@ -117,9 +117,9 @@ void test_xcecd_multiple_init_cleanup(void)
|
|||
.resource_update_interval = 5,
|
||||
.job_status_update_interval = 1,
|
||||
.port = 8080,
|
||||
.acct_file_path = "/tmp/xcecd.acct",
|
||||
.log_file_path = "/tmp/xcecd.log",
|
||||
.domain_sock_path = "/tmp/xcecd.sock",
|
||||
.acct_file = "/tmp/xcecd.acct",
|
||||
.log_file = "/tmp/xcecd.log",
|
||||
.domain_sock_file = "/tmp/xcecd.sock",
|
||||
.remote_host = "localhost",
|
||||
.remote_port = 6789,
|
||||
.update_interval = 2 };
|
||||
|
|
@ -138,9 +138,9 @@ void test_xcecd_init_minimum_values(void)
|
|||
.resource_update_interval = 1,
|
||||
.job_status_update_interval = 1,
|
||||
.port = 1024,
|
||||
.acct_file_path = "/tmp/xcecd.acct",
|
||||
.log_file_path = "/tmp/xcecd.log",
|
||||
.domain_sock_path = "/tmp/xcecd.sock",
|
||||
.acct_file = "/tmp/xcecd.acct",
|
||||
.log_file = "/tmp/xcecd.log",
|
||||
.domain_sock_file = "/tmp/xcecd.sock",
|
||||
.remote_host = "localhost",
|
||||
.remote_port = 6789,
|
||||
.update_interval = 1 };
|
||||
|
|
@ -162,4 +162,4 @@ int main(void)
|
|||
RUN_TEST(test_xcecd_init_minimum_values);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "../include/process_manager.h"
|
||||
#include "../include/xcecd.h"
|
||||
#include "../include/xcecd_utils.h"
|
||||
#include "../include/xcecd_worker.h"
|
||||
#include "unity.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
|
@ -35,6 +34,8 @@ static int mock_select_return = 0;
|
|||
static int mock_waitpid_return = 0;
|
||||
static int mock_process_manager_start_process_return = 0;
|
||||
|
||||
extern int main(void);
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
mock_socket_fd = -1;
|
||||
|
|
@ -318,4 +319,4 @@ int main(void)
|
|||
RUN_TEST(test_xcecd_worker_main);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue