From cea8e32e3fc57569094e2ddf4167f2a9864fc3a4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 20 Jan 2010 04:02:39 +0100 Subject: [PATCH] extend test a little --- main.c | 20 ++++++++++++++++++-- manager.c | 8 ++++---- manager.h | 4 ++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index de7572ef..fde11c09 100644 --- a/main.c +++ b/main.c @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) { Manager *m = NULL; - Name *milestone = NULL; + Name *milestone = NULL, *syslog = NULL; Job *job = NULL; int r, retval = 1; @@ -23,13 +23,29 @@ int main(int argc, char *argv[]) { goto finish; } + if ((r = manager_load_name(m, "syslog.socket", &syslog) < 0)) { + fprintf(stderr, "Failed to load syslog socket: %s\n", strerror(-r)); + goto finish; + } if ((r = manager_add_job(m, JOB_START, milestone, JOB_REPLACE, false, &job)) < 0) { fprintf(stderr, "Failed to start default milestone: %s\n", strerror(-r)); goto finish; } - manager_dump_names(m, stdout); + printf("- By names:\n"); + manager_dump_names(m, stdout, "\t"); + + printf("- By jobs:\n"); + manager_dump_jobs(m, stdout, "\t"); + + if ((r = manager_add_job(m, JOB_STOP, syslog, JOB_REPLACE, false, &job)) < 0) { + fprintf(stderr, "Failed to start default milestone: %s\n", strerror(-r)); + goto finish; + } + + printf("- By jobs:\n"); + manager_dump_jobs(m, stdout, "\t"); retval = 0; diff --git a/manager.c b/manager.c index 6470e1c1..170ea843 100644 --- a/manager.c +++ b/manager.c @@ -778,7 +778,7 @@ finish: return 0; } -void manager_dump_jobs(Manager *s, FILE *f) { +void manager_dump_jobs(Manager *s, FILE *f, const char *prefix) { void *state; Job *j; @@ -786,10 +786,10 @@ void manager_dump_jobs(Manager *s, FILE *f) { assert(f); HASHMAP_FOREACH(j, s->jobs, state) - job_dump(j, f, NULL); + job_dump(j, f, prefix); } -void manager_dump_names(Manager *s, FILE *f) { +void manager_dump_names(Manager *s, FILE *f, const char *prefix) { void *state; Name *n; const char *t; @@ -799,5 +799,5 @@ void manager_dump_names(Manager *s, FILE *f) { HASHMAP_FOREACH_KEY(n, t, s->names, state) if (name_id(n) == t) - name_dump(n, f, NULL); + name_dump(n, f, prefix); } diff --git a/manager.h b/manager.h index ad62b74a..e68b087f 100644 --- a/manager.h +++ b/manager.h @@ -45,8 +45,8 @@ Name *manager_get_name(Manager *m, const char *name); int manager_load_name(Manager *m, const char *name, Name **_ret); int manager_add_job(Manager *m, JobType type, Name *name, JobMode mode, bool force, Job **_ret); -void manager_dump_names(Manager *s, FILE *f); -void manager_dump_jobs(Manager *s, FILE *f); +void manager_dump_names(Manager *s, FILE *f, const char *prefix); +void manager_dump_jobs(Manager *s, FILE *f, const char *prefix); void manager_transaction_delete_job(Manager *m, Job *j); -- 2.39.5