Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
x11spice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spice
x11spice
Commits
45481c52
Commit
45481c52
authored
Jul 30, 2019
by
Jeremy White
Committed by
Frediano Ziglio
Mar 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the Spice video dummy driver for our tests if enabled.
Acked-by:
Frediano Ziglio
<
fziglio@redhat.com
>
parent
83180d7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
1 deletion
+69
-1
src/tests/Makefile.am
src/tests/Makefile.am
+5
-0
src/tests/xdummy.c
src/tests/xdummy.c
+63
-1
src/tests/xdummy.h
src/tests/xdummy.h
+1
-0
No files found.
src/tests/Makefile.am
View file @
45481c52
...
...
@@ -18,6 +18,11 @@ x11spice_test_SOURCES = \
x11spice_test_CPPFLAGS
=
-DPATH_TO_TEST_SRC
=
\"
$(abs_srcdir)
\"
# Instruct the xdummy utility where to find the spice-video-driver library
if
DUMMY
x11spice_test_CPPFLAGS
+=
-DSPICEDUMMY
=
\"
$(abs_top_builddir)
/spice-video-dummy/src/.libs
\"
endif
TESTS
+=
options_test
options_test_CPPFLAGS
=
-I
$(top_srcdir)
/src
options_test_LDADD
=
$(GLIB2_LIBS)
...
...
src/tests/xdummy.c
View file @
45481c52
...
...
@@ -30,6 +30,7 @@
#include <sys/wait.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include "xdummy.h"
...
...
@@ -76,7 +77,11 @@ static void write_xorg_conf(FILE * fp, xdummy_t *server)
"EndSection
\n
"
"Section
\"
Device
\"\n
"
" Identifier
\"
dummy_videocard
\"\n
"
#if defined(SPICEDUMMY)
" Driver
\"
spicedummy
\"\n
"
#else
" Driver
\"
dummy
\"\n
"
#endif
" VideoRam %ld
\n
"
"EndSection
\n
"
"
\n
"
...
...
@@ -87,6 +92,7 @@ static void write_xorg_conf(FILE * fp, xdummy_t *server)
" DefaultDepth 24
\n
"
"SubSection
\"
Display
\"\n
"
" Modes %s
\n
"
" Virtual %s
\n
"
"EndSubSection
\n
"
"EndSection
\n
"
"
\n
"
...
...
@@ -95,7 +101,7 @@ static void write_xorg_conf(FILE * fp, xdummy_t *server)
" Screen
\"
dummy_screen
\"\n
"
" InputDevice
\"
dummy_mouse
\"\n
"
" InputDevice
\"
dummy_keyboard
\"\n
"
"EndSection
\n
"
,
server
->
desired_vram
,
server
->
modes
);
"EndSection
\n
"
,
server
->
desired_vram
,
server
->
modes
,
server
->
vmode
);
}
static
int
generate_paths
(
xdummy_t
*
server
,
gconstpointer
user_data
)
...
...
@@ -136,11 +142,61 @@ static int generate_paths(xdummy_t *server, gconstpointer user_data)
return
0
;
}
static
void
get_module_paths
(
const
char
*
xorg_binary
,
char
*
module_paths
,
int
size
)
{
int
pipes
[
2
];
int
rc
;
int
pid
;
char
*
p
;
memset
(
module_paths
,
0
,
size
);
#if defined(SPICEDUMMY)
strncpy
(
module_paths
,
SPICEDUMMY
,
size
-
1
);
module_paths
+=
strlen
(
module_paths
);
size
-=
strlen
(
module_paths
);
#endif
/* We invoke Xorg -showDefaultModulePath, which frustratingly
writes the path we crave to stderr. Because of the stderr
requirement, we need to manage file handles manually instead
of using popen() */
if
(
pipe
(
pipes
)
==
0
)
{
pid
=
fork
();
if
(
pid
==
0
)
{
close
(
pipes
[
0
]);
dup2
(
pipes
[
1
],
STDERR_FILENO
);
close
(
pipes
[
1
]);
execlp
(
xorg_binary
,
xorg_binary
,
"-showDefaultModulePath"
,
NULL
);
exit
(
0
);
}
else
{
waitpid
(
pid
,
NULL
,
0
);
rc
=
read
(
pipes
[
0
],
module_paths
,
size
-
2
);
if
(
rc
>
0
)
{
for
(
p
=
module_paths
+
rc
-
1
;
p
>=
module_paths
&&
isspace
(
*
p
);
p
--
)
*
p
=
'\0'
;
/* Don't use bogus paths or errors masquerading as paths */
if
(
access
(
module_paths
,
X_OK
)
!=
0
)
*
module_paths
=
0
;
#if defined(SPICEDUMMY)
/* Comma separate multiple directories */
memmove
(
module_paths
+
1
,
module_paths
,
rc
);
*
module_paths
=
','
;
#endif
}
close
(
pipes
[
0
]);
close
(
pipes
[
1
]);
}
}
}
static
int
exec_xorg
(
xdummy_t
*
server
,
gconstpointer
user_data
G_GNUC_UNUSED
)
{
FILE
*
fp
;
char
fdbuf
[
100
];
char
xorg_binary
[
100
];
char
module_paths
[
4096
];
fp
=
fopen
(
server
->
xorg_fname
,
"w"
);
if
(
!
fp
)
...
...
@@ -160,8 +216,11 @@ static int exec_xorg(xdummy_t *server, gconstpointer user_data G_GNUC_UNUSED)
else
if
(
access
(
"/usr/lib/xorg/Xorg"
,
X_OK
)
==
0
)
strcpy
(
xorg_binary
,
"/usr/lib/xorg/Xorg"
);
get_module_paths
(
xorg_binary
,
module_paths
,
sizeof
(
module_paths
));
return
execlp
(
xorg_binary
,
xorg_binary
,
"-ac"
,
"-config"
,
server
->
xorg_fname
,
"-modulepath"
,
module_paths
,
"-logfile"
,
server
->
logfile
,
"-displayfd"
,
fdbuf
,
NULL
);
}
...
...
@@ -169,15 +228,18 @@ static void configure_xorg_parameters(xdummy_t *server, gconstpointer user_data)
{
server
->
desired_vram
=
((
1024
*
768
*
4
)
+
1023
)
/
1024
;
server
->
modes
=
"
\"
1024x768
\"
"
;
server
->
vmode
=
"1024 768"
;
if
(
strcmp
(
user_data
,
"resize"
)
==
0
)
{
server
->
desired_vram
=
((
1920
*
1080
*
4
)
+
1023
)
/
1024
;
server
->
modes
=
"
\"
1920x1080
\"
"
;
server
->
vmode
=
"1920 1080"
;
}
if
(
strlen
(
user_data
)
>
7
&&
memcmp
(
user_data
,
"client_"
,
7
)
==
0
)
{
server
->
desired_vram
=
((
1280
*
1024
*
4
)
+
1023
)
/
1024
;
server
->
modes
=
"
\"
1280x1024
\"
"
;
server
->
vmode
=
"1280 1024"
;
}
}
...
...
src/tests/xdummy.h
View file @
45481c52
...
...
@@ -31,6 +31,7 @@ typedef struct {
int
pipe
;
long
desired_vram
;
gchar
*
modes
;
gchar
*
vmode
;
gboolean
running
;
gchar
*
xorg_fname
;
gchar
*
logfile
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment