}
if (t->flags & TEST_CREATE_CONN) {
+ if (!env->buspath) {
+ char *s = NULL;
+ char *n = NULL;
+ int ret;
+
+ if (!args->busname) {
+ n = unique_name("test-bus");
+ ASSERT_RETURN(n);
+ }
+
+ ret = kdbus_create_bus(-1,
+ args->busname ?: n,
+ 0,
+ 0, &s);
+ free(n);
+ ASSERT_RETURN(ret == 0);
+
+ asprintf(&env->buspath, "%s/%s/bus", args->root, s);
+ free(s);
+ }
+ ASSERT_RETURN(env->buspath);
env->conn = kdbus_hello(env->buspath, 0, NULL, 0);
ASSERT_RETURN(env->conn);
}
char str[64];
} name;
} bus_make;
- int ret;
+ int ret = 0;
memset(&bus_make, 0, sizeof(bus_make));
bus_make.bp.size = sizeof(bus_make.bp);
bus_make.attach[1].size +
bus_make.name.size;
- kdbus_printf("Creating bus with name >%s< on control fd %d ...\n",
- name, control_fd);
+ if (control_fd != -1) {
+ kdbus_printf(
+ "Creating bus with name >%s< on control fd %d ...\n",
+ name, control_fd);
- ret = kdbus_cmd_bus_make(control_fd, &bus_make.cmd);
- if (ret < 0) {
- kdbus_printf("--- error when making bus: %d (%m)\n", ret);
- return ret;
+ ret = kdbus_cmd_bus_make(control_fd, &bus_make.cmd);
+ if (ret < 0) {
+ kdbus_printf("--- error when making bus: %d (%m)\n",
+ ret);
+ return ret;
+ }
}
if (ret == 0 && path)