🧑💻 Check for Xephyr availability before running tests
This commit is contained in:
parent
599610fd6f
commit
b47ccfd93a
3 changed files with 24 additions and 4 deletions
|
@ -10,7 +10,8 @@ clock_t USER_DELAY = 1 * CLOCKS_PER_SEC;
|
||||||
|
|
||||||
void run_aswm(void) {
|
void run_aswm(void) {
|
||||||
int stat_loc;
|
int stat_loc;
|
||||||
// Ensures aswm is running
|
// A return value of 0 indicates that the status of aswm_pid is not yet
|
||||||
|
// available, i.e. aswm is running
|
||||||
TEST_ASSERT_EQUAL_INT(0, waitpid(aswm_pid, &stat_loc, WNOHANG));
|
TEST_ASSERT_EQUAL_INT(0, waitpid(aswm_pid, &stat_loc, WNOHANG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,9 +140,11 @@ void create_multiple_resizeable_top_level_window(void) {
|
||||||
int main(void) {
|
int main(void) {
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
set_up_test_logger();
|
set_up_test_logger();
|
||||||
|
if(check_xephyr_available()) {
|
||||||
RUN_TEST(run_aswm);
|
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);
|
RUN_TEST(create_multiple_resizeable_top_level_window);
|
||||||
|
}
|
||||||
tear_down_test_logger();
|
tear_down_test_logger();
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,23 @@ void tear_down_test_logger(void) {
|
||||||
zlog_fini();
|
zlog_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_xephyr_available() {
|
||||||
|
xephyr_pid = fork();
|
||||||
|
if(xephyr_pid == 0) {
|
||||||
|
char* args[] = {"which", "Xephyr", NULL};
|
||||||
|
execvp(args[0], args);
|
||||||
|
}
|
||||||
|
int stat_loc;
|
||||||
|
waitpid(xephyr_pid, &stat_loc, 0);
|
||||||
|
if(stat_loc != 0) {
|
||||||
|
zlog_error(test_log, "Xephyr executable not found. Make sure it is installed and available in your PATH.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void setUp(void) {
|
void setUp(void) {
|
||||||
|
|
||||||
tmpnam(display_fd); // Creates a temporary file name
|
tmpnam(display_fd); // Creates a temporary file name
|
||||||
sprintf(display_name, ":%u", display_count); // Loads initial display count
|
sprintf(display_name, ":%u", display_count); // Loads initial display count
|
||||||
// in display name
|
// in display name
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern Display* test_display;
|
||||||
extern Window test_root;
|
extern Window test_root;
|
||||||
extern zlog_category_t *test_log;
|
extern zlog_category_t *test_log;
|
||||||
|
|
||||||
|
bool check_xephyr_available();
|
||||||
void set_up_test_logger();
|
void set_up_test_logger();
|
||||||
void tear_down_test_logger();
|
void tear_down_test_logger();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue