summaryrefslogtreecommitdiffstats
path: root/src/tests/test-unit
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test-unit')
-rw-r--r--src/tests/test-unit/test-unit.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tests/test-unit/test-unit.c b/src/tests/test-unit/test-unit.c
index 09b7c86..5912dbc 100644
--- a/src/tests/test-unit/test-unit.c
+++ b/src/tests/test-unit/test-unit.c
@@ -36,7 +36,7 @@
-static int process1(const struct unitdesc *desc)
+static int processunit(const struct unitdesc *desc)
{
int isuser = desc->scope == unitscope_user;
int issystem = desc->scope == unitscope_system;
@@ -52,18 +52,23 @@ printf("\n%s\n\n",content);
return 0;
}
-static int process(void *closure, const struct unitdesc descs[], unsigned count)
+static int process(void *closure, const struct generatedesc *desc)
{
- while (count--)
- process1(descs++);
+ int i;
+ for (i = 0 ; i < desc->nunits ; i++)
+ processunit(&desc->units[i]);
return 0;
}
int main(int ac, char **av)
{
+ struct unitconf conf;
struct json_object *obj;
int rc;
+ conf.installdir = "INSTALL-DIR";
+ conf.icondir = "ICONS-DIR";
+ conf.port = 666;
rc = unit_generator_on(*++av);
if (rc < 0)
error("can't read template %s: %m",*av);
@@ -72,13 +77,8 @@ int main(int ac, char **av)
if (!obj)
error("can't read widget config at %s: %m",*av);
- j_add_string_m(obj, "#metadata.install-dir", "INSTALL-DIR");
- j_add_string_m(obj, "#metadata.app-data-dir", "%h/app-data");
- j_add_string_m(obj, "#metadata.icons-dir", "ICONS-DIR");
- j_add_string_m(obj, "#metadata.http-port", "HTTP-PORT");
-
puts(json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY));
- rc = unit_generator_process(obj, process, NULL);
+ rc = unit_generator_process(obj, &conf, process, NULL);
if (rc)
error("can't apply generate units, error %d",rc);
json_object_put(obj);