Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
steam
systemd
Commits
c5e33bf8
Commit
c5e33bf8
authored
Feb 06, 2013
by
Zbigniew Jędrzejewski-Szmek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: skip tests if manager cannot be created
When running without a user session, tests fail.
parent
10ddd913
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
src/test/test-sched-prio.c
src/test/test-sched-prio.c
+8
-2
src/test/test-unit-name.c
src/test/test-unit-name.c
+8
-2
No files found.
src/test/test-sched-prio.c
View file @
c5e33bf8
...
...
@@ -30,10 +30,16 @@ int main(int argc, char *argv[]) {
Service
*
ser
;
FILE
*
serial
=
NULL
;
FDSet
*
fdset
=
NULL
;
int
r
;
/* prepare the test */
assert_se
(
set_unit_path
(
TEST_DIR
)
>=
0
);
assert_se
(
manager_new
(
SYSTEMD_USER
,
&
m
)
>=
0
);
r
=
manager_new
(
SYSTEMD_USER
,
&
m
);
if
(
r
==
-
EPERM
)
{
puts
(
"manager_new: Permission denied. Skipping test."
);
return
EXIT_SUCCESS
;
}
assert
(
r
>=
0
);
assert_se
(
manager_startup
(
m
,
serial
,
fdset
)
>=
0
);
/* load idle ok */
...
...
@@ -82,5 +88,5 @@ int main(int argc, char *argv[]) {
assert_se
(
ser
->
exec_context
.
cpu_sched_policy
==
SCHED_RR
);
assert_se
(
ser
->
exec_context
.
cpu_sched_priority
==
99
);
return
0
;
return
EXIT_SUCCESS
;
}
src/test/test-unit-name.c
View file @
c5e33bf8
...
...
@@ -111,6 +111,7 @@ static void test_replacements(void) {
static
void
test_unit_printf
(
void
)
{
Manager
*
m
;
Unit
*
u
,
*
u2
;
int
r
;
char
_cleanup_free_
*
mid
,
*
bid
,
*
host
,
*
root_uid
;
struct
passwd
*
root
;
...
...
@@ -122,14 +123,19 @@ static void test_unit_printf(void) {
assert_se
((
root
=
getpwnam
(
"root"
)));
assert_se
(
asprintf
(
&
root_uid
,
"%d"
,
(
int
)
root
->
pw_uid
)
>
0
);
assert_se
(
manager_new
(
SYSTEMD_USER
,
&
m
)
==
0
);
r
=
manager_new
(
SYSTEMD_USER
,
&
m
);
if
(
r
==
-
EPERM
)
{
puts
(
"manager_new: Permission denied. Skipping test."
);
return
;
}
assert
(
r
==
0
);
#define expect(unit, pattern, expected) \
{ \
char *e; \
char _cleanup_free_ *t = \
unit_full_printf(unit, pattern); \
printf("result: %s\n
", t);
\
printf("result: %s\n
expect: %s\n", t, expected);
\
if ((e = endswith(expected, "*"))) \
assert(strncmp(t, e, e-expected)); \
else \
...
...
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