🔊 zlog set up
This commit is contained in:
parent
0e7a1f5623
commit
fc736642b2
21 changed files with 302 additions and 157 deletions
|
|
@ -138,8 +138,10 @@ void create_multiple_resizeable_top_level_window(void) {
|
|||
// not needed when using generate_test_runner.rb
|
||||
int main(void) {
|
||||
UNITY_BEGIN();
|
||||
set_up_test_logger();
|
||||
RUN_TEST(run_aswm);
|
||||
RUN_TEST(create_single_resizeable_top_level_window);
|
||||
RUN_TEST(create_single_resizeable_top_level_window);
|
||||
RUN_TEST(create_multiple_resizeable_top_level_window);
|
||||
tear_down_test_logger();
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
7
test/aswm_log.conf
Normal file
7
test/aswm_log.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[formats]
|
||||
|
||||
simple = "[%c %p] %d(%m-%d %T) %-5V %-8f:%-3L %m%n"
|
||||
|
||||
[rules]
|
||||
|
||||
aswm.NOTICE >stdout; simple
|
||||
8
test/log.conf
Normal file
8
test/log.conf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[formats]
|
||||
|
||||
simple = "[%c %p] %d(%m-%d %T) %-5V %f:%L %m%n"
|
||||
|
||||
[rules]
|
||||
|
||||
aswm.INFO >stdout; simple
|
||||
test.DEBUG >stdout; simple
|
||||
|
|
@ -9,6 +9,7 @@ char display_name[5];
|
|||
int aswm_pid;
|
||||
Display* test_display;
|
||||
Window test_root;
|
||||
zlog_category_t *test_log;
|
||||
|
||||
// Local variables
|
||||
unsigned int display_count = 100;
|
||||
|
|
@ -25,6 +26,24 @@ void run_xephyr() {
|
|||
execvp(args[0], args);
|
||||
}
|
||||
|
||||
void set_up_test_logger(void) {
|
||||
int rc;
|
||||
|
||||
rc = zlog_init(ASWM_TEST_DIR "/log.conf");
|
||||
if (rc) {
|
||||
printf("Init test zlog failed\n");
|
||||
}
|
||||
|
||||
test_log = zlog_get_category("test_log");
|
||||
if (!test_log) {
|
||||
printf("Get zlog test_log category failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void tear_down_test_logger(void) {
|
||||
zlog_fini();
|
||||
}
|
||||
|
||||
void setUp(void) {
|
||||
tmpnam(display_fd); // Creates a temporary file name
|
||||
sprintf(display_name, ":%u", display_count); // Loads initial display count
|
||||
|
|
@ -34,7 +53,7 @@ void setUp(void) {
|
|||
if(xephyr_pid == 0) {
|
||||
run_xephyr();
|
||||
} else {
|
||||
printf("Trying to run Xephyr instance on :%u...\n", display_count);
|
||||
zlog_info(test_log, "Trying to run Xephyr instance on :%u...", display_count);
|
||||
}
|
||||
|
||||
// The following loop waits for one of those two things:
|
||||
|
|
@ -60,7 +79,7 @@ void setUp(void) {
|
|||
if(xephyr_pid == 0) {
|
||||
run_xephyr();
|
||||
} else {
|
||||
printf("Trying to run Xephyr instance on :%u...\n", display_count);
|
||||
zlog_info(test_log, "Trying to run Xephyr instance on :%u...", display_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,8 +87,8 @@ void setUp(void) {
|
|||
|
||||
aswm_pid = fork();
|
||||
if(aswm_pid == 0) {
|
||||
printf("Running aswm instance on %s...\n", display_name);
|
||||
char* args[] = {"./aswm", NULL};
|
||||
zlog_info(test_log, "Running aswm instance on %s...", display_name);
|
||||
char* args[] = {"./aswm", "--log", ASWM_TEST_DIR "/aswm_log.conf", NULL};
|
||||
char display_env[256];
|
||||
sprintf(display_env, "DISPLAY=%s", display_name);
|
||||
char* envp[] = {display_env, NULL};
|
||||
|
|
|
|||
|
|
@ -2,13 +2,22 @@
|
|||
#define ASWM_TEST_SET_UP
|
||||
|
||||
#include "unity.h"
|
||||
#include "zlog.h"
|
||||
#include "X11/Xlib.h"
|
||||
|
||||
#ifndef ASWM_TEST_DIR
|
||||
#define ASWM_TEST_DIR "."
|
||||
#endif
|
||||
|
||||
// Extern variables accessible from any test.
|
||||
// Defined in test_set_up.c
|
||||
extern char display_name[5];
|
||||
extern int aswm_pid;
|
||||
extern Display* test_display;
|
||||
extern Window test_root;
|
||||
extern zlog_category_t *test_log;
|
||||
|
||||
void set_up_test_logger();
|
||||
void tear_down_test_logger();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue