#include "common.h"
#include "systemd_dbus.h"
#include "activationd_acceptance_tests.h"
-#include "activationd_acceptance_tests_dbus.h"
+#include "activationd_acceptance_tests_dbus_signal.h"
+#include "activationd_acceptance_tests_unit_control.h"
#include "activationd_acceptance_tests_vconf.h"
#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
enum {
TEST_TYPE_UNKNOWN,
TEST_TYPE_VCONF,
- TEST_TYPE_DBUS
+ TEST_TYPE_DBUS_SIGNAL,
+ TEST_TYPE_UNIT_CONTROL
};
-static struct test_sequence dbus_acceptance_tests[] = {
+static struct test_sequence unit_control_acceptance_tests[] = {
+ {
+ .desc = "unit control positive test",
+ .actions = {
+ {{
+ {.type = VKC_STRING, .value.s = "Start"}
+ },
+ {ACTIVE, UNKNOWN}, 1, 1, 0},
+ {{
+ {.type = VKC_STRING, .value.s = "Restart"}
+ },
+ {INACTIVE, ACTIVE}, 1, 2, 0},
+ {{
+ {.type = VKC_STRING, .value.s = "Stop"}
+ },
+ {INACTIVE, UNKNOWN}, 1, 1, 0}
+ },
+ .id = "AcceptanceTestSP",
+ .unit = SERVICE_NAME_S_P,
+ .path = NULL,
+ .expected_result = TEST_SUCCESS,
+ .result = TEST_UNKNOWN,
+ .current_action = 0,
+ .step = unit_control_step
+ },
+ {
+ .desc = "unit control negative test",
+ .actions = {
+ {{
+ {.type = VKC_STRING, .value.s = "Start"}
+ },
+ {INACTIVE, UNKNOWN}, 1, 1, 0},
+ {{
+ {.type = VKC_STRING, .value.s = "Restart"}
+ },
+ {INACTIVE, INACTIVE}, 1, 2, 0},
+ {{
+ {.type = VKC_STRING, .value.s = "Stoo"}
+ },
+ {INACTIVE, UNKNOWN}, 1, 1, 0}
+ },
+ .id = "AcceptanceTestIN",
+ .unit = SERVICE_NAME_I_N,
+ .path = NULL,
+ .expected_result = TEST_FAIL,
+ .result = TEST_UNKNOWN,
+ .current_action = 0,
+ .step = unit_control_step
+ },
+ {
+ .desc = "unit control whitelist negative test",
+ .actions = {
+ {{
+ {.type = VKC_STRING, .value.s = "Start"}
+ },
+ {INACTIVE, UNKNOWN}, 1, 1, 0},
+ {{
+ {.type = VKC_STRING, .value.s = "Restart"}
+ },
+ {INACTIVE, INACTIVE}, 1, 2, 0},
+ {{
+ {.type = VKC_STRING, .value.s = "Stop"}
+ },
+ {INACTIVE, UNKNOWN}, 1, 1, 0}
+ },
+ .id = "AcceptanceTestSN",
+ .unit = SERVICE_NAME_S_N,
+ .path = NULL,
+ .expected_result = TEST_FAIL,
+ .result = TEST_UNKNOWN,
+ .current_action = 0,
+ .step = unit_control_step
+ }
+};
+
+static struct test_sequence dbus_signal_acceptance_tests[] = {
{
.desc = "string (positive test)",
.actions = {
{{
- {.type = VKC_STRING, .value.s = "start"}
+ {.type = VKC_STRING, .value.s = "start"}
},
{ACTIVE, UNKNOWN}, 1, 1, 0},
{{
- {.type = VKC_STRING, .value.s = "restart"}
+ {.type = VKC_STRING, .value.s = "restart"}
},
{INACTIVE, ACTIVE}, 1, 2, 0},
{{
- {.type = VKC_STRING, .value.s = "stop"}
+ {.type = VKC_STRING, .value.s = "stop"}
},
{INACTIVE, UNKNOWN}, 1, 1, 0}
},
.expected_result = TEST_SUCCESS,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "string (negative test)",
.actions = {
{{
- {.type = VKC_STRING, .value.s = "start"}
+ {.type = VKC_STRING, .value.s = "start"}
},
{ACTIVE, UNKNOWN}, 1, 1, 0},
{{
- {.type = VKC_STRING, .value.s = "restart"}
+ {.type = VKC_STRING, .value.s = "restart"}
},
{INACTIVE, ACTIVE}, 1, 2, 0},
{{
- {.type = VKC_STRING, .value.s = "stop"}
+ {.type = VKC_STRING, .value.s = "stop"}
},
{INACTIVE, UNKNOWN}, 1, 1, 0}
},
.expected_result = TEST_FAIL,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "int (positive test)",
.actions = {
{{
- {.type = VKC_INT, .value.i = 1}
+ {.type = VKC_INT, .value.i = 1}
},
{ACTIVE, UNKNOWN}, 1, 1, 0},
{{
- {.type = VKC_INT, .value.i = 2}
+ {.type = VKC_INT, .value.i = 2}
},
{INACTIVE, ACTIVE}, 1, 2, 0},
{{
- {.type = VKC_INT, .value.i = 3}
+ {.type = VKC_INT, .value.i = 3}
},
{INACTIVE, UNKNOWN}, 1, 1, 0}
},
.expected_result = TEST_SUCCESS,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "int (negative test)",
.actions = {
{{
- {.type = VKC_INT, .value.i = 1}
+ {.type = VKC_INT, .value.i = 1}
},
{ACTIVE, UNKNOWN}, 1, 1, 0},
{{
- {.type = VKC_INT, .value.i = 2}
+ {.type = VKC_INT, .value.i = 2}
},
{INACTIVE, ACTIVE}, 1, 2, 0},
{{
- {.type = VKC_INT, .value.i = 3}
+ {.type = VKC_INT, .value.i = 3}
},
{INACTIVE, UNKNOWN}, 1, 1, 0}
},
.expected_result = TEST_FAIL,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "double (positive test)",
.actions = {
{{
- {.type = VKC_DOUBLE, .value.d = 1.0}
+ {.type = VKC_DOUBLE, .value.d = 1.0}
},
{ACTIVE, UNKNOWN}, 1, 1, 0},
{{
- {.type = VKC_DOUBLE, .value.d = 2.0}
+ {.type = VKC_DOUBLE, .value.d = 2.0}
},
{INACTIVE, ACTIVE}, 1, 2, 0},
{{
- {.type = VKC_DOUBLE, .value.d = 3.0}
+ {.type = VKC_DOUBLE, .value.d = 3.0}
},
{INACTIVE, UNKNOWN}, 1, 1, 0}
},
.expected_result = TEST_SUCCESS,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "double (negative test)",
.actions = {
{{
- {.type = VKC_DOUBLE, .value.d = 1.0}
+ {.type = VKC_DOUBLE, .value.d = 1.0}
},
{ACTIVE, UNKNOWN}, 1, 1, 0},
{{
- {.type = VKC_DOUBLE, .value.d = 2.0}
+ {.type = VKC_DOUBLE, .value.d = 2.0}
},
{INACTIVE, ACTIVE}, 1, 2, 0},
{{
- {.type = VKC_DOUBLE, .value.d = 3.0}
+ {.type = VKC_DOUBLE, .value.d = 3.0}
},
{INACTIVE, UNKNOWN}, 1, 1, 0}
},
.expected_result = TEST_FAIL,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "bool (positive test)",
.actions = {
{{
- {.type = VKC_BOOL, .value.b = true},
- {.type = VKC_BOOL, .value.b = true}
+ {.type = VKC_BOOL, .value.b = true},
+ {.type = VKC_BOOL, .value.b = true}
},
{ACTIVE, UNKNOWN}, 2, 1, 0},
{{
- {.type = VKC_BOOL, .value.b = true},
- {.type = VKC_BOOL, .value.b = false}
+ {.type = VKC_BOOL, .value.b = true},
+ {.type = VKC_BOOL, .value.b = false}
},
{INACTIVE, ACTIVE}, 2, 2, 0},
{{
- {.type = VKC_BOOL, .value.b = false},
- {.type = VKC_BOOL, .value.b = false}
+ {.type = VKC_BOOL, .value.b = false},
+ {.type = VKC_BOOL, .value.b = false}
},
{INACTIVE, UNKNOWN}, 2, 1, 0}
},
.expected_result = TEST_SUCCESS,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
},
{
.desc = "bool (negative test)",
.actions = {
{{
- {.type = VKC_BOOL, .value.b = true},
- {.type = VKC_BOOL, .value.b = true}
+ {.type = VKC_BOOL, .value.b = true},
+ {.type = VKC_BOOL, .value.b = true}
},
{ACTIVE, UNKNOWN}, 2, 1, 0},
{{
- {.type = VKC_BOOL, .value.b = true},
- {.type = VKC_BOOL, .value.b = false}
+ {.type = VKC_BOOL, .value.b = true},
+ {.type = VKC_BOOL, .value.b = false}
},
{INACTIVE, ACTIVE}, 2, 2, 0},
{{
- {.type = VKC_BOOL, .value.b = false},
- {.type = VKC_BOOL, .value.b = false}
+ {.type = VKC_BOOL, .value.b = false},
+ {.type = VKC_BOOL, .value.b = false}
},
{INACTIVE, UNKNOWN}, 2, 1, 0}
},
.expected_result = TEST_FAIL,
.result = TEST_UNKNOWN,
.current_action = 0,
- .step = dbus_step
+ .step = dbus_signal_step
}
};
{{{.type = VKC_STRING, .value.s = "START"}}, {ACTIVE, UNKNOWN}, 1, 1, 0},
{{{.type = VKC_STRING, .value.s = "RELOAD"}}, {INACTIVE, ACTIVE}, 1, 2, 0},
{{{.type = VKC_STRING, .value.s = "STOP"}}, {INACTIVE, UNKNOWN}, 1, 1, 0}
- //{{{.type = VKC_STRING, .value.s = "START"}}, {ACTIVE, UNKNOWN}, 1, 1, 0},
- //{{{.type = VKC_STRING, .value.s = "RELOAD"}}, {INACTIVE, ACTIVE}, 1, 2, 0},
- //{{{.type = VKC_STRING, .value.s = "STOP"}}, {INACTIVE, UNKNOWN}, 1, 1, 0}
},
.id = VCONF_KEY_S_N,
.unit = SERVICE_NAME_S_N,
static void print_usage(const char *name)
{
- printf("usage: %s -t vconf|dbus\n", name);
+ printf("usage: %s -t vconf|signal|unit_control\n", name);
return;
}
case 't':
if (!strcmp(optarg, "vconf"))
*type = TEST_TYPE_VCONF;
- else if (!strcmp(optarg, "dbus"))
- *type = TEST_TYPE_DBUS;
+ else if (!strcmp(optarg, "signal"))
+ *type = TEST_TYPE_DBUS_SIGNAL;
+ else if (!strcmp(optarg, "unit_control"))
+ *type = TEST_TYPE_UNIT_CONTROL;
break;
default:
return -EINVAL;
if (test_type == TEST_TYPE_VCONF) {
data.tests = vconf_acceptance_tests;
data.tests_count = ARRAY_SIZE(vconf_acceptance_tests);
- } else if (test_type == TEST_TYPE_DBUS) {
- data.tests = dbus_acceptance_tests;
- data.tests_count = ARRAY_SIZE(dbus_acceptance_tests);
+ } else if (test_type == TEST_TYPE_DBUS_SIGNAL) {
+ data.tests = dbus_signal_acceptance_tests;
+ data.tests_count = ARRAY_SIZE(dbus_signal_acceptance_tests);
+ } else if (test_type == TEST_TYPE_UNIT_CONTROL) {
+ data.tests = unit_control_acceptance_tests;
+ data.tests_count = ARRAY_SIZE(unit_control_acceptance_tests);
} else {
fprintf(stderr, "Unknown test type\n");
goto fail;