summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy White <jwhite@codeweavers.com>2020-04-20 14:29:42 -0500
committerFrediano Ziglio <freddy77@gmail.com>2020-04-21 15:57:26 +0100
commit54e08ccc090d7628007ea35feae1b953c3d29679 (patch)
tree905f5ba50e1d0357abfc904628935d453bbe379d
parent6a70ca62daec97774ad2428036818429f10998ed (diff)
Have tests code follow style guide.
Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--src/tests/tests.c27
-rw-r--r--src/tests/tests.h3
-rw-r--r--src/tests/util.c5
-rw-r--r--src/tests/x11spice_test.c19
-rw-r--r--src/tests/xcbtest.c3
-rw-r--r--src/tests/xdummy.c12
6 files changed, 30 insertions, 39 deletions
diff --git a/src/tests/tests.c b/src/tests/tests.c
index cf12d18..fdb2e9c 100644
--- a/src/tests/tests.c
+++ b/src/tests/tests.c
@@ -30,7 +30,7 @@
#include "xcbtest.h"
#include "x11spice_test.h"
-static int test_common_start(test_t * test, x11spice_server_t * server,
+static int test_common_start(test_t *test, x11spice_server_t *server,
xdummy_t *xserver, gconstpointer user_data)
{
int rc;
@@ -61,7 +61,7 @@ static int test_common_start(test_t * test, x11spice_server_t * server,
return 0;
}
-static void test_common_stop(test_t * test G_GNUC_UNUSED, x11spice_server_t * server)
+static void test_common_stop(test_t *test G_GNUC_UNUSED, x11spice_server_t *server)
{
x11spice_stop(server);
}
@@ -145,8 +145,7 @@ void test_basic(xdummy_t *xdummy, gconstpointer user_data)
if (xcbtest_draw_grid(buf)) {
g_warning("Could not draw the grid");
g_test_fail();
- }
- else {
+ } else {
snprintf(buf, sizeof(buf), "%s/expected.grid.1024x768.ppm", PATH_TO_TEST_SRC);
check_screenshot(&test, &server, xdummy, buf);
}
@@ -170,7 +169,7 @@ void test_resize(xdummy_t *xdummy, gconstpointer user_data)
if (rc)
return;
- for (i = 0; i < sizeof(modes) / sizeof(modes[0]) && ! g_test_failed(); i++) {
+ for (i = 0; i < sizeof(modes) / sizeof(modes[0]) && !g_test_failed(); i++) {
snprintf(buf, sizeof(buf), "xrandr --display :%s -s %s", xdummy->display, modes[i]);
system(buf);
@@ -179,8 +178,7 @@ void test_resize(xdummy_t *xdummy, gconstpointer user_data)
g_warning("Could not draw the grid");
g_test_fail();
break;
- }
- else {
+ } else {
snprintf(buf, sizeof(buf), "%s/expected.grid.%s.ppm", PATH_TO_TEST_SRC, modes[i]);
check_screenshot(&test, &server, xdummy, buf);
}
@@ -212,8 +210,7 @@ void test_tallscreen(xdummy_t *xdummy, gconstpointer user_data)
if (xcbtest_draw_grid(buf)) {
g_warning("Could not draw the grid");
g_test_fail();
- }
- else {
+ } else {
snprintf(buf, sizeof(buf), "%s/expected.grid.3840x2160.ppm", PATH_TO_TEST_SRC);
check_screenshot(&test, &server, xdummy, buf);
}
@@ -223,8 +220,7 @@ void test_tallscreen(xdummy_t *xdummy, gconstpointer user_data)
if (xcbtest_draw_at_bottom(buf)) {
g_warning("Could not draw at the bottom");
g_test_fail();
- }
- else {
+ } else {
snprintf(buf, sizeof(buf), "%s/expected.grid.bottom.3840x2160.ppm", PATH_TO_TEST_SRC);
check_screenshot(&test, &server, xdummy, buf);
}
@@ -266,7 +262,7 @@ void test_script(xdummy_t *xdummy, gconstpointer user_data)
snprintf(buf, sizeof(buf), "client_%s", (char *) user_data);
start_server(&client_server, buf);
- if (! client_server.running) {
+ if (!client_server.running) {
g_warning("Could not start client X server");
g_test_skip("Could not start client X server");
}
@@ -277,8 +273,8 @@ void test_script(xdummy_t *xdummy, gconstpointer user_data)
script_out = g_test_build_filename(G_TEST_BUILT, "run", user_data, "script.out", NULL);
script_dir = strdup(script_out);
snprintf(buf, sizeof(buf), "%s/%s :%s :%s %s%s %s", PATH_TO_TEST_SRC, (char *) user_data,
- xdummy->display, client_server.display, needs_prefix ? "spice://" : "",
- server.uri, dirname(script_dir));
+ xdummy->display, client_server.display, needs_prefix ? "spice://" : "",
+ server.uri, dirname(script_dir));
free(script_dir);
g_message("Launching script %s; this could take some time.", (char *) user_data);
@@ -292,8 +288,7 @@ void test_script(xdummy_t *xdummy, gconstpointer user_data)
if (WEXITSTATUS(rc) == 77) {
g_warning("Skipped script test [%s]", buf);
g_test_skip(buf);
- }
- else {
+ } else {
g_warning("Error running script [%s]; status %d", buf, rc);
g_test_fail();
}
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 2d497c3..d093684 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -29,8 +29,7 @@
/*----------------------------------------------------------------------------
** Structure definitions
**--------------------------------------------------------------------------*/
-typedef struct
-{
+typedef struct {
xdummy_t *xserver;
const gchar *logfile;
const gchar *name;
diff --git a/src/tests/util.c b/src/tests/util.c
index b115041..74c5fe8 100644
--- a/src/tests/util.c
+++ b/src/tests/util.c
@@ -56,11 +56,8 @@ int spawn_command(char *cmd, char *output_file, int *pid)
return -1;
execl("/bin/sh", "sh", "-c", cmd, NULL);
- g_error("exec of [%s] failed",cmd);
+ g_error("exec of [%s] failed", cmd);
}
return 0;
}
-
-
-
diff --git a/src/tests/x11spice_test.c b/src/tests/x11spice_test.c
index 63163ee..6c980f0 100644
--- a/src/tests/x11spice_test.c
+++ b/src/tests/x11spice_test.c
@@ -42,11 +42,13 @@ static int exec_x11spice(x11spice_server_t *server, gchar *display)
dup2(server->pipe, fileno(stderr));
if (valgrind)
- snprintf(buf, sizeof(buf), "%s ../x11spice --display :%s localhost:5900-5999 --hide --config %s",
- valgrind, display, server->conffile);
- else
- snprintf(buf, sizeof(buf), "../x11spice --display :%s localhost:5900-5999 --hide --config %s",
+ snprintf(buf, sizeof(buf),
+ "%s ../x11spice --display :%s localhost:5900-5999 --hide --config %s", valgrind,
display, server->conffile);
+ else
+ snprintf(buf, sizeof(buf),
+ "../x11spice --display :%s localhost:5900-5999 --hide --config %s", display,
+ server->conffile);
return execl("/bin/sh", "sh", "-c", buf, NULL);
@@ -105,7 +107,8 @@ int x11spice_start(x11spice_server_t *server, test_t *test)
server->running = FALSE;
- server->conffile = g_test_build_filename(G_TEST_BUILT, "run", test->name, "x11spice.conf", NULL);
+ server->conffile =
+ g_test_build_filename(G_TEST_BUILT, "run", test->name, "x11spice.conf", NULL);
if (!server->conffile) {
g_warning("Failed to create conffile");
g_test_fail();
@@ -114,8 +117,7 @@ int x11spice_start(x11spice_server_t *server, test_t *test)
fp = fopen(server->conffile, "w");
if (fp) {
- char *config_data = "[spice]\n"
- "disable-ticketing=true\n";
+ char *config_data = "[spice]\ndisable-ticketing=true\n";
fwrite(config_data, 1, strlen(config_data), fp);
if (test->never_trust_damage)
fprintf(fp, "trust-damage=never\n");
@@ -132,8 +134,7 @@ int x11spice_start(x11spice_server_t *server, test_t *test)
exec_x11spice(server, test->xserver->display);
g_warning("x11spice server exec failed.");
return -1;
- }
- else {
+ } else {
server->pipe = fd[0];
close(fd[1]);
diff --git a/src/tests/xcbtest.c b/src/tests/xcbtest.c
index 6398ae1..6f301cf 100644
--- a/src/tests/xcbtest.c
+++ b/src/tests/xcbtest.c
@@ -64,8 +64,7 @@ static void create_rectangles(xcb_rectangle_t * red, xcb_rectangle_t * green, in
red[r].x = x * (w / 8);
red[r].y = y * (h / 8);
r++;
- }
- else {
+ } else {
green[g].x = x * (w / 8);
green[g].y = y * (h / 8);
g++;
diff --git a/src/tests/xdummy.c b/src/tests/xdummy.c
index 9b7b079..95d60df 100644
--- a/src/tests/xdummy.c
+++ b/src/tests/xdummy.c
@@ -39,6 +39,7 @@
static void write_xorg_conf(FILE * fp, xdummy_t *server)
{
+ /* *INDENT-OFF* - Prevent indent from changing style here */
fprintf(fp,
"# This xorg configuration file is meant to be used by x11spice\n"
"# to start a dummy X11 server.\n"
@@ -102,6 +103,7 @@ static void write_xorg_conf(FILE * fp, xdummy_t *server)
" InputDevice \"dummy_mouse\"\n"
" InputDevice \"dummy_keyboard\"\n"
"EndSection\n", server->desired_vram, server->modes, server->vmode);
+ /* *INDENT-ON* */
}
static int generate_paths(xdummy_t *server, gconstpointer user_data)
@@ -168,8 +170,7 @@ static void get_module_paths(const char *xorg_binary, char *module_paths, int si
close(pipes[1]);
execlp(xorg_binary, xorg_binary, "-showDefaultModulePath", NULL);
exit(0);
- }
- else {
+ } else {
waitpid(pid, NULL, 0);
rc = read(pipes[0], module_paths, size - 2);
if (rc > 0) {
@@ -226,11 +227,11 @@ static int exec_xorg(xdummy_t *server, gconstpointer user_data G_GNUC_UNUSED)
static void configure_xorg_parameters(xdummy_t *server, gconstpointer user_data)
{
- server->desired_vram = ((1024 * 768 * 4) + 1023)/ 1024;
+ server->desired_vram = ((1024 * 768 * 4) + 1023) / 1024;
server->modes = "\"1024x768\"";
server->vmode = "1024 768";
- if (strcmp(user_data , "resize") == 0) {
+ if (strcmp(user_data, "resize") == 0) {
server->desired_vram = ((1920 * 1080 * 4) + 1023) / 1024;
server->modes = "\"1920x1080\"";
server->vmode = "1920 1080";
@@ -274,8 +275,7 @@ void start_server(xdummy_t *server, gconstpointer user_data)
exec_xorg(server, user_data);
g_warning("server exec failed.");
exit(-1);
- }
- else {
+ } else {
server->pipe = fd[0];
close(fd[1]);