backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / virsystemdtest.c
blob2dafce2764d0d5a93dab1e630718fc6c76a9b9cc
1 /*
2 * Copyright (C) 2013, 2014 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <http://www.gnu.org/licenses/>.
19 #include <config.h>
21 #include "testutils.h"
23 #if defined(WITH_DBUS) && defined(__linux__)
25 # include <dbus/dbus.h>
26 # include <fcntl.h>
28 # define LIBVIRT_VIRSYSTEMDPRIV_H_ALLOW
29 # include "virsystemdpriv.h"
31 # include "virsystemd.h"
32 # include "virdbus.h"
33 # include "virlog.h"
34 # include "virmock.h"
35 # include "rpc/virnetsocket.h"
36 # include "intprops.h"
37 # define VIR_FROM_THIS VIR_FROM_NONE
39 VIR_LOG_INIT("tests.systemdtest");
41 VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block,
42 DBusMessage *,
43 DBusConnection *, connection,
44 DBusMessage *, message,
45 int, timeout_milliseconds,
46 DBusError *, error)
48 DBusMessage *reply = NULL;
49 const char *service = dbus_message_get_destination(message);
50 const char *member = dbus_message_get_member(message);
52 VIR_MOCK_REAL_INIT(dbus_connection_send_with_reply_and_block);
54 if (STREQ(service, "org.freedesktop.machine1")) {
55 if (getenv("FAIL_BAD_SERVICE")) {
56 dbus_set_error_const(error,
57 "org.freedesktop.systemd.badthing",
58 "Something went wrong creating the machine");
59 } else {
60 reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
62 if (STREQ(member, "GetMachineByPID")) {
63 const char *object_path = "/org/freedesktop/machine1/machine/qemu_2ddemo";
64 DBusMessageIter iter;
66 dbus_message_iter_init_append(reply, &iter);
67 if (!dbus_message_iter_append_basic(&iter,
68 DBUS_TYPE_OBJECT_PATH,
69 &object_path))
70 goto error;
71 } else if (STREQ(member, "Get")) {
72 const char *name = "qemu-demo";
73 DBusMessageIter iter;
74 DBusMessageIter sub;
76 dbus_message_iter_init_append(reply, &iter);
77 dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
78 "s", &sub);
80 if (!dbus_message_iter_append_basic(&sub,
81 DBUS_TYPE_STRING,
82 &name))
83 goto error;
84 dbus_message_iter_close_container(&iter, &sub);
87 } else if (STREQ(service, "org.freedesktop.login1")) {
88 char *supported = getenv("RESULT_SUPPORT");
89 DBusMessageIter iter;
90 reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
91 dbus_message_iter_init_append(reply, &iter);
93 if (!dbus_message_iter_append_basic(&iter,
94 DBUS_TYPE_STRING,
95 &supported))
96 goto error;
97 } else if (STREQ(service, "org.freedesktop.DBus") &&
98 STREQ(member, "ListActivatableNames")) {
99 const char *svc1 = "org.foo.bar.wizz";
100 const char *svc2 = "org.freedesktop.machine1";
101 const char *svc3 = "org.freedesktop.login1";
102 DBusMessageIter iter;
103 DBusMessageIter sub;
104 reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
105 dbus_message_iter_init_append(reply, &iter);
106 dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
107 "s", &sub);
109 if (!dbus_message_iter_append_basic(&sub,
110 DBUS_TYPE_STRING,
111 &svc1))
112 goto error;
113 if (!getenv("FAIL_NO_SERVICE") &&
114 !dbus_message_iter_append_basic(&sub,
115 DBUS_TYPE_STRING,
116 &svc2))
117 goto error;
118 if (!getenv("FAIL_NO_SERVICE") &&
119 !dbus_message_iter_append_basic(&sub,
120 DBUS_TYPE_STRING,
121 &svc3))
122 goto error;
123 dbus_message_iter_close_container(&iter, &sub);
124 } else if (STREQ(service, "org.freedesktop.DBus") &&
125 STREQ(member, "ListNames")) {
126 const char *svc1 = "org.foo.bar.wizz";
127 const char *svc2 = "org.freedesktop.systemd1";
128 const char *svc3 = "org.freedesktop.login1";
129 DBusMessageIter iter;
130 DBusMessageIter sub;
131 reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
132 dbus_message_iter_init_append(reply, &iter);
133 dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
134 "s", &sub);
136 if (!dbus_message_iter_append_basic(&sub,
137 DBUS_TYPE_STRING,
138 &svc1))
139 goto error;
140 if ((!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) &&
141 !dbus_message_iter_append_basic(&sub,
142 DBUS_TYPE_STRING,
143 &svc2))
144 goto error;
145 if ((!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) &&
146 !dbus_message_iter_append_basic(&sub,
147 DBUS_TYPE_STRING,
148 &svc3))
149 goto error;
150 dbus_message_iter_close_container(&iter, &sub);
151 } else {
152 reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
155 return reply;
157 error:
158 virDBusMessageUnref(reply);
159 return NULL;
163 static int testCreateContainer(const void *opaque ATTRIBUTE_UNUSED)
165 unsigned char uuid[VIR_UUID_BUFLEN] = {
166 1, 1, 1, 1,
167 2, 2, 2, 2,
168 3, 3, 3, 3,
169 4, 4, 4, 4
171 if (virSystemdCreateMachine("demo",
172 "lxc",
173 uuid,
174 "/proc/123/root",
175 123,
176 true,
177 0, NULL,
178 "highpriority.slice", 0) < 0) {
179 fprintf(stderr, "%s", "Failed to create LXC machine\n");
180 return -1;
183 return 0;
186 static int testTerminateContainer(const void *opaque ATTRIBUTE_UNUSED)
188 if (virSystemdTerminateMachine("lxc-demo") < 0) {
189 fprintf(stderr, "%s", "Failed to terminate LXC machine\n");
190 return -1;
193 return 0;
196 static int testCreateMachine(const void *opaque ATTRIBUTE_UNUSED)
198 unsigned char uuid[VIR_UUID_BUFLEN] = {
199 1, 1, 1, 1,
200 2, 2, 2, 2,
201 3, 3, 3, 3,
202 4, 4, 4, 4
204 if (virSystemdCreateMachine("demo",
205 "qemu",
206 uuid,
207 NULL,
208 123,
209 false,
210 0, NULL,
211 NULL, 0) < 0) {
212 fprintf(stderr, "%s", "Failed to create KVM machine\n");
213 return -1;
216 return 0;
219 static int testTerminateMachine(const void *opaque ATTRIBUTE_UNUSED)
221 if (virSystemdTerminateMachine("test-qemu-demo") < 0) {
222 fprintf(stderr, "%s", "Failed to terminate KVM machine\n");
223 return -1;
226 return 0;
229 static int testCreateNoSystemd(const void *opaque ATTRIBUTE_UNUSED)
231 unsigned char uuid[VIR_UUID_BUFLEN] = {
232 1, 1, 1, 1,
233 2, 2, 2, 2,
234 3, 3, 3, 3,
235 4, 4, 4, 4
237 int rv;
239 setenv("FAIL_NO_SERVICE", "1", 1);
241 if ((rv = virSystemdCreateMachine("demo",
242 "qemu",
243 uuid,
244 NULL,
245 123,
246 false,
247 0, NULL,
248 NULL, 0)) == 0) {
249 unsetenv("FAIL_NO_SERVICE");
250 fprintf(stderr, "%s", "Unexpected create machine success\n");
251 return -1;
253 unsetenv("FAIL_NO_SERVICE");
255 if (rv != -2) {
256 fprintf(stderr, "%s", "Unexpected create machine error\n");
257 return -1;
260 return 0;
263 static int testCreateSystemdNotRunning(const void *opaque ATTRIBUTE_UNUSED)
265 unsigned char uuid[VIR_UUID_BUFLEN] = {
266 1, 1, 1, 1,
267 2, 2, 2, 2,
268 3, 3, 3, 3,
269 4, 4, 4, 4
271 int rv;
273 setenv("FAIL_NOT_REGISTERED", "1", 1);
275 if ((rv = virSystemdCreateMachine("demo",
276 "qemu",
277 uuid,
278 NULL,
279 123,
280 false,
281 0, NULL,
282 NULL, 0)) == 0) {
283 unsetenv("FAIL_NOT_REGISTERED");
284 fprintf(stderr, "%s", "Unexpected create machine success\n");
285 return -1;
287 unsetenv("FAIL_NOT_REGISTERED");
289 if (rv != -2) {
290 fprintf(stderr, "%s", "Unexpected create machine error\n");
291 return -1;
294 return 0;
297 static int testCreateBadSystemd(const void *opaque ATTRIBUTE_UNUSED)
299 unsigned char uuid[VIR_UUID_BUFLEN] = {
300 1, 1, 1, 1,
301 2, 2, 2, 2,
302 3, 3, 3, 3,
303 4, 4, 4, 4
305 int rv;
307 setenv("FAIL_BAD_SERVICE", "1", 1);
309 if ((rv = virSystemdCreateMachine("demo",
310 "qemu",
311 uuid,
312 NULL,
313 123,
314 false,
315 0, NULL,
316 NULL, 0)) == 0) {
317 unsetenv("FAIL_BAD_SERVICE");
318 fprintf(stderr, "%s", "Unexpected create machine success\n");
319 return -1;
321 unsetenv("FAIL_BAD_SERVICE");
323 if (rv != -1) {
324 fprintf(stderr, "%s", "Unexpected create machine error\n");
325 return -1;
328 return 0;
332 static int testCreateNetwork(const void *opaque ATTRIBUTE_UNUSED)
334 unsigned char uuid[VIR_UUID_BUFLEN] = {
335 1, 1, 1, 1,
336 2, 2, 2, 2,
337 3, 3, 3, 3,
338 4, 4, 4, 4
340 int nicindexes[] = {
341 2, 1729, 87539319,
343 size_t nnicindexes = ARRAY_CARDINALITY(nicindexes);
344 if (virSystemdCreateMachine("demo",
345 "lxc",
346 uuid,
347 "/proc/123/root",
348 123,
349 true,
350 nnicindexes, nicindexes,
351 "highpriority.slice", 0) < 0) {
352 fprintf(stderr, "%s", "Failed to create LXC machine\n");
353 return -1;
356 return 0;
360 static int
361 testGetMachineName(const void *opaque ATTRIBUTE_UNUSED)
363 char *tmp = virSystemdGetMachineNameByPID(1234);
364 int ret = -1;
366 if (!tmp) {
367 fprintf(stderr, "%s", "Failed to create LXC machine\n");
368 return ret;
371 if (STREQ(tmp, "qemu-demo"))
372 ret = 0;
374 VIR_FREE(tmp);
375 return ret;
379 struct testNameData {
380 const char *name;
381 const char *expected;
382 int id;
383 bool legacy;
386 static int
387 testScopeName(const void *opaque)
389 const struct testNameData *data = opaque;
390 int ret = -1;
391 char *actual = NULL;
393 if (!(actual = virSystemdMakeScopeName(data->name, "lxc", data->legacy)))
394 goto cleanup;
396 if (STRNEQ(actual, data->expected)) {
397 fprintf(stderr, "Expected '%s' but got '%s'\n",
398 data->expected, actual);
399 goto cleanup;
402 ret = 0;
404 cleanup:
405 VIR_FREE(actual);
406 return ret;
409 static int
410 testMachineName(const void *opaque)
412 const struct testNameData *data = opaque;
413 int ret = -1;
414 char *actual = NULL;
416 if (!(actual = virDomainGenerateMachineName("qemu", data->id,
417 data->name, true)))
418 goto cleanup;
420 if (STRNEQ(actual, data->expected)) {
421 fprintf(stderr, "Expected '%s' but got '%s'\n",
422 data->expected, actual);
423 goto cleanup;
426 ret = 0;
428 cleanup:
429 VIR_FREE(actual);
430 return ret;
433 typedef int (*virSystemdCanHelper)(bool * result);
434 struct testPMSupportData {
435 virSystemdCanHelper tested;
438 static int testPMSupportHelper(const void *opaque)
440 int rv;
441 bool result;
442 size_t i;
443 const char *results[4] = {"yes", "no", "na", "challenge"};
444 int expected[4] = {1, 0, 0, 1};
445 const struct testPMSupportData *data = opaque;
447 for (i = 0; i < 4; i++) {
448 setenv("RESULT_SUPPORT", results[i], 1);
449 if ((rv = data->tested(&result)) < 0) {
450 fprintf(stderr, "%s", "Unexpected canSuspend error\n");
451 return -1;
454 if (result != expected[i]) {
455 fprintf(stderr, "Unexpected result for answer '%s'\n", results[i]);
456 goto error;
458 unsetenv("RESULT_SUPPORT");
461 return 0;
462 error:
463 unsetenv("RESULT_SUPPORT");
464 return -1;
467 static int testPMSupportHelperNoSystemd(const void *opaque)
469 int rv;
470 bool result;
471 const struct testPMSupportData *data = opaque;
473 setenv("FAIL_NO_SERVICE", "1", 1);
475 if ((rv = data->tested(&result)) == 0) {
476 unsetenv("FAIL_NO_SERVICE");
477 fprintf(stderr, "%s", "Unexpected canSuspend success\n");
478 return -1;
480 unsetenv("FAIL_NO_SERVICE");
482 if (rv != -2) {
483 fprintf(stderr, "%s", "Unexpected canSuspend error\n");
484 return -1;
487 return 0;
490 static int testPMSupportSystemdNotRunning(const void *opaque)
492 int rv;
493 bool result;
494 const struct testPMSupportData *data = opaque;
496 setenv("FAIL_NOT_REGISTERED", "1", 1);
498 if ((rv = data->tested(&result)) == 0) {
499 unsetenv("FAIL_NOT_REGISTERED");
500 fprintf(stderr, "%s", "Unexpected canSuspend success\n");
501 return -1;
503 unsetenv("FAIL_NOT_REGISTERED");
505 if (rv != -2) {
506 fprintf(stderr, "%s", "Unexpected canSuspend error\n");
507 return -1;
510 return 0;
514 static int
515 testActivationCreateFDs(virNetSocketPtr *sockUNIX,
516 virNetSocketPtr **sockIP,
517 size_t *nsockIP)
519 *sockUNIX = NULL;
520 *sockIP = NULL;
521 *nsockIP = 0;
523 if (virNetSocketNewListenUNIX("virsystemdtest.sock",
524 0777,
527 sockUNIX) < 0)
528 return -1;
530 if (virNetSocketNewListenTCP("localhost",
531 NULL,
532 AF_UNSPEC,
533 sockIP,
534 nsockIP) < 0) {
535 virObjectUnref(*sockUNIX);
536 return -1;
539 return 0;
543 static int
544 testActivation(bool useNames)
546 virNetSocketPtr sockUNIX;
547 virNetSocketPtr *sockIP;
548 size_t nsockIP;
549 int ret = -1;
550 size_t i;
551 char nfdstr[INT_BUFSIZE_BOUND(size_t)];
552 char pidstr[INT_BUFSIZE_BOUND(pid_t)];
553 virSystemdActivationMap map[2];
554 int *fds = NULL;
555 size_t nfds = 0;
556 VIR_AUTOPTR(virSystemdActivation) act = NULL;
557 VIR_AUTOCLEAN(virBuffer) names = VIR_BUFFER_INITIALIZER;
559 virBufferAddLit(&names, "demo-unix.socket");
561 if (testActivationCreateFDs(&sockUNIX, &sockIP, &nsockIP) < 0)
562 return -1;
564 for (i = 0; i < nsockIP; i++)
565 virBufferAddLit(&names, ":demo-ip.socket");
567 snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
568 snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
570 setenv("LISTEN_FDS", nfdstr, 1);
571 setenv("LISTEN_PID", pidstr, 1);
573 if (virBufferError(&names))
574 goto cleanup;
576 if (useNames)
577 setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
578 else
579 unsetenv("LISTEN_FDNAMES");
581 map[0].name = "demo-unix.socket";
582 map[0].family = AF_UNIX;
583 map[0].path = virNetSocketGetPath(sockUNIX);
585 map[1].name = "demo-ip.socket";
586 map[1].family = AF_INET;
587 map[1].port = virNetSocketGetPort(sockIP[0]);
589 if (virSystemdGetActivation(map, ARRAY_CARDINALITY(map), &act) < 0)
590 goto cleanup;
592 if (act == NULL) {
593 fprintf(stderr, "Activation object was not created: %s", virGetLastErrorMessage());
594 goto cleanup;
597 if (virSystemdActivationComplete(act) == 0) {
598 fprintf(stderr, "Activation did not report unclaimed FDs");
599 goto cleanup;
602 virSystemdActivationClaimFDs(act, "demo-unix.socket", &fds, &nfds);
604 if (nfds != 1) {
605 fprintf(stderr, "Expected 1 UNIX fd, but got %zu\n", nfds);
606 goto cleanup;
608 VIR_FREE(fds);
610 virSystemdActivationClaimFDs(act, "demo-ip.socket", &fds, &nfds);
612 if (nfds != nsockIP) {
613 fprintf(stderr, "Expected %zu IP fd, but got %zu\n", nsockIP, nfds);
614 goto cleanup;
616 VIR_FREE(fds);
618 virSystemdActivationClaimFDs(act, "demo-ip-alt.socket", &fds, &nfds);
620 if (nfds != 0) {
621 fprintf(stderr, "Expected 0 IP fd, but got %zu\n", nfds);
622 goto cleanup;
625 if (virSystemdActivationComplete(act) < 0) {
626 fprintf(stderr, "Action was not complete: %s\n", virGetLastErrorMessage());
627 goto cleanup;
630 ret = 0;
631 cleanup:
632 virObjectUnref(sockUNIX);
633 for (i = 0; i < nsockIP; i++)
634 virObjectUnref(sockIP[i]);
635 VIR_FREE(sockIP);
636 VIR_FREE(fds);
637 return ret;
641 static int
642 testActivationEmpty(const void *opaque ATTRIBUTE_UNUSED)
644 virSystemdActivationPtr act;
646 unsetenv("LISTEN_FDS");
648 if (virSystemdGetActivation(NULL, 0, &act) < 0)
649 return -1;
651 if (act != NULL) {
652 fprintf(stderr, "Unexpectedly got activation object");
653 virSystemdActivationFree(&act);
654 return -1;
657 return 0;
661 static int
662 testActivationFDNames(const void *opaque ATTRIBUTE_UNUSED)
664 return testActivation(true);
668 static int
669 testActivationFDAddrs(const void *opaque ATTRIBUTE_UNUSED)
671 return testActivation(false);
675 static int
676 mymain(void)
678 int ret = 0;
680 unsigned char uuid[VIR_UUID_BUFLEN];
682 /* The one we use in tests quite often */
683 if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", uuid) < 0)
684 return EXIT_FAILURE;
686 # define DO_TEST(_name, func) \
687 do { \
688 if (virTestRun(_name, func, NULL) < 0) \
689 ret = -1; \
690 if (virTestRun(_name "again ", func, NULL) < 0) \
691 ret = -1; \
692 virSystemdHasMachinedResetCachedValue(); \
693 } while (0)
695 DO_TEST("Test create container ", testCreateContainer);
696 DO_TEST("Test terminate container ", testTerminateContainer);
697 DO_TEST("Test create machine ", testCreateMachine);
698 DO_TEST("Test terminate machine ", testTerminateMachine);
699 DO_TEST("Test create no systemd ", testCreateNoSystemd);
700 DO_TEST("Test create systemd not running ", testCreateSystemdNotRunning);
701 DO_TEST("Test create bad systemd ", testCreateBadSystemd);
702 DO_TEST("Test create with network ", testCreateNetwork);
703 DO_TEST("Test getting machine name ", testGetMachineName);
705 # define TEST_SCOPE(_name, unitname, _legacy) \
706 do { \
707 struct testNameData data = { \
708 .name = _name, .expected = unitname, .legacy = _legacy, \
709 }; \
710 if (virTestRun("Test scopename", testScopeName, &data) < 0) \
711 ret = -1; \
712 } while (0)
714 # define TEST_SCOPE_OLD(name, unitname) \
715 TEST_SCOPE(name, unitname, true)
716 # define TEST_SCOPE_NEW(name, unitname) \
717 TEST_SCOPE(name, unitname, false)
719 TEST_SCOPE_OLD("demo", "machine-lxc\\x2ddemo.scope");
720 TEST_SCOPE_OLD("demo-name", "machine-lxc\\x2ddemo\\x2dname.scope");
721 TEST_SCOPE_OLD("demo!name", "machine-lxc\\x2ddemo\\x21name.scope");
722 TEST_SCOPE_OLD(".demo", "machine-lxc\\x2d\\x2edemo.scope");
723 TEST_SCOPE_OLD("bull💩", "machine-lxc\\x2dbull\\xf0\\x9f\\x92\\xa9.scope");
725 TEST_SCOPE_NEW("qemu-3-demo", "machine-qemu\\x2d3\\x2ddemo.scope");
727 # define TEST_MACHINE(_name, _id, machinename) \
728 do { \
729 struct testNameData data = { \
730 .name = _name, .expected = machinename, .id = _id, \
731 }; \
732 if (virTestRun("Test scopename", testMachineName, &data) < 0) \
733 ret = -1; \
734 } while (0)
736 TEST_MACHINE("demo", 1, "qemu-1-demo");
737 TEST_MACHINE("demo-name", 2, "qemu-2-demo-name");
738 TEST_MACHINE("demo!name", 3, "qemu-3-demoname");
739 TEST_MACHINE(".demo", 4, "qemu-4-.demo");
740 TEST_MACHINE("bull\U0001f4a9", 5, "qemu-5-bull");
741 TEST_MACHINE("demo..name", 6, "qemu-6-demo.name");
742 TEST_MACHINE("12345678901234567890123456789012345678901234567890123456789", 7,
743 "qemu-7-123456789012345678901234567890123456789012345678901234567");
744 TEST_MACHINE("123456789012345678901234567890123456789012345678901234567890", 8,
745 "qemu-8-123456789012345678901234567890123456789012345678901234567");
747 # define TESTS_PM_SUPPORT_HELPER(name, function) \
748 do { \
749 struct testPMSupportData data = { \
750 function \
751 }; \
752 if (virTestRun("Test " name " ", testPMSupportHelper, &data) < 0) \
753 ret = -1; \
754 virSystemdHasLogindResetCachedValue(); \
755 if (virTestRun("Test " name " no systemd ", \
756 testPMSupportHelperNoSystemd, &data) < 0) \
757 ret = -1; \
758 virSystemdHasLogindResetCachedValue(); \
759 if (virTestRun("Test systemd " name " not running ", \
760 testPMSupportSystemdNotRunning, &data) < 0) \
761 ret = -1; \
762 virSystemdHasLogindResetCachedValue(); \
763 } while (0)
765 TESTS_PM_SUPPORT_HELPER("canSuspend", &virSystemdCanSuspend);
766 TESTS_PM_SUPPORT_HELPER("canHibernate", &virSystemdCanHibernate);
767 TESTS_PM_SUPPORT_HELPER("canHybridSleep", &virSystemdCanHybridSleep);
769 if (virTestRun("Test activation empty", testActivationEmpty, NULL) < 0)
770 ret = -1;
772 if (fcntl(STDERR_FILENO + 1, F_GETFL) == -1 && errno == EBADF &&
773 fcntl(STDERR_FILENO + 2, F_GETFL) == -1 && errno == EBADF &&
774 fcntl(STDERR_FILENO + 3, F_GETFL) == -1 && errno == EBADF) {
775 if (virTestRun("Test activation names", testActivationFDNames, NULL) < 0)
776 ret = -1;
777 if (virTestRun("Test activation addrs", testActivationFDAddrs, NULL) < 0)
778 ret = -1;
779 } else {
780 VIR_INFO("Skipping activation tests as FD 3/4/5 is open");
783 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
786 VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virdbusmock.so")
788 #else /* ! (WITH_DBUS && __linux__) */
790 main(void)
792 return EXIT_AM_SKIP;
794 #endif /* ! WITH_DBUS */