Use macros for testing virSystemd APIs

This hides the unused third parameter from every line
and prepares for resetting the environment after each test
case in the future.
This commit is contained in:
Ján Tomko 2017-02-23 12:25:33 +01:00
parent 18c145a0d3
commit 27cdbcb9c2

View File

@ -518,25 +518,21 @@ mymain(void)
if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", uuid) < 0) if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", uuid) < 0)
return EXIT_FAILURE; return EXIT_FAILURE;
if (virTestRun("Test create container ", testCreateContainer, NULL) < 0) # define DO_TEST(_name, func) \
ret = -1; do { \
if (virTestRun("Test terminate container ", testTerminateContainer, NULL) < 0) if (virTestRun(_name, func, NULL) < 0) \
ret = -1; ret = -1; \
if (virTestRun("Test create machine ", testCreateMachine, NULL) < 0) } while (0)
ret = -1;
if (virTestRun("Test terminate machine ", testTerminateMachine, NULL) < 0) DO_TEST("Test create container ", testCreateContainer);
ret = -1; DO_TEST("Test terminate container ", testTerminateContainer);
if (virTestRun("Test create no systemd ", testCreateNoSystemd, NULL) < 0) DO_TEST("Test create machine ", testCreateMachine);
ret = -1; DO_TEST("Test terminate machine ", testTerminateMachine);
if (virTestRun("Test create systemd not running ", DO_TEST("Test create no systemd ", testCreateNoSystemd);
testCreateSystemdNotRunning, NULL) < 0) DO_TEST("Test create systemd not running ", testCreateSystemdNotRunning);
ret = -1; DO_TEST("Test create bad systemd ", testCreateBadSystemd);
if (virTestRun("Test create bad systemd ", testCreateBadSystemd, NULL) < 0) DO_TEST("Test create with network ", testCreateNetwork);
ret = -1; DO_TEST("Test getting machine name ", testGetMachineName);
if (virTestRun("Test create with network ", testCreateNetwork, NULL) < 0)
ret = -1;
if (virTestRun("Test getting machine name ", testGetMachineName, NULL) < 0)
ret = -1;
# define TEST_SCOPE(_name, unitname, _legacy) \ # define TEST_SCOPE(_name, unitname, _legacy) \
do { \ do { \