[systemd-commits] 2 commits - .gitignore Makefile.am man/systemd-analyze.xml man/systemd.unit.xml src/test

Dave Reisner dreisner at kemper.freedesktop.org
Thu Jan 8 12:58:18 PST 2015


 .gitignore              |    1 
 Makefile.am             |    9 ++++-
 man/systemd-analyze.xml |    4 +-
 man/systemd.unit.xml    |    2 -
 src/test/test-verbs.c   |   78 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 90 insertions(+), 4 deletions(-)

New commits:
commit d2f0e78f2b72620ecf088ea756f9958e947f1182
Author: Dave Reisner <dreisner at archlinux.org>
Date:   Fri Dec 19 22:59:51 2014 -0500

    test-verbs: add unit tests for verbs minilib

diff --git a/.gitignore b/.gitignore
index 70ee4f6..2e14b26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -253,6 +253,7 @@
 /test-unit-name
 /test-utf8
 /test-util
+/test-verbs
 /test-watchdog
 /test-xml
 /timedatectl
diff --git a/Makefile.am b/Makefile.am
index 21097bf..483feb3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1389,7 +1389,8 @@ tests += \
 	test-execute \
 	test-copy \
 	test-cap-list \
-	test-sigbus
+	test-sigbus \
+	test-verbs
 
 EXTRA_DIST += \
 	test/a.service \
@@ -1662,6 +1663,12 @@ test_tmpfiles_LDADD = \
 test_namespace_SOURCES = \
 	src/test/test-namespace.c
 
+test_verbs_SOURCES = \
+	src/test/test-verbs.c
+
+test_verbs_LDADD = \
+	libsystemd-shared.la
+
 test_namespace_LDADD = \
 	libsystemd-core.la
 
diff --git a/src/test/test-verbs.c b/src/test/test-verbs.c
new file mode 100644
index 0000000..0fcdd9e
--- /dev/null
+++ b/src/test/test-verbs.c
@@ -0,0 +1,78 @@
+/***
+  This file is part of systemd.
+
+  Copyright 2014 systemd developers
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "macro.h"
+#include "strv.h"
+#include "verbs.h"
+
+static int noop_dispatcher(int argc, char *argv[], void *userdata) {
+        return 0;
+}
+
+#define test_dispatch_one(argv, verbs, expected) \
+        optind = 0; \
+        assert_se(dispatch_verb(strv_length(argv), argv, verbs, NULL) == expected);
+
+static void test_verbs(void) {
+        static const Verb verbs[] = {
+                { "help",        VERB_ANY, VERB_ANY, 0,            noop_dispatcher },
+                { "list-images", VERB_ANY, 1,        0,            noop_dispatcher },
+                { "list",        VERB_ANY, 2,        VERB_DEFAULT, noop_dispatcher },
+                { "status",      2,        VERB_ANY, 0,            noop_dispatcher },
+                { "show",        VERB_ANY, VERB_ANY, 0,            noop_dispatcher },
+                { "terminate",   2,        VERB_ANY, 0,            noop_dispatcher },
+                { "login",       2,        2,        0,            noop_dispatcher },
+                { "copy-to",     3,        4,        0,            noop_dispatcher },
+                {}
+        };
+
+        /* not found */
+        test_dispatch_one(STRV_MAKE("command-not-found"), verbs, -EINVAL);
+
+        /* found */
+        test_dispatch_one(STRV_MAKE("show"), verbs, 0);
+
+        /* found, too few args */
+        test_dispatch_one(STRV_MAKE("copy-to", "foo"), verbs, -EINVAL);
+
+        /* found, meets min args */
+        test_dispatch_one(STRV_MAKE("status", "foo", "bar"), verbs, 0);
+
+        /* found, too many args */
+        test_dispatch_one(STRV_MAKE("copy-to", "foo", "bar", "baz", "quux", "qaax"), verbs, -EINVAL);
+
+        /* no verb, but a default is set */
+        test_dispatch_one(STRV_MAKE_EMPTY, verbs, 0);
+}
+
+static void test_verbs_no_default(void) {
+        static const Verb verbs[] = {
+                { "help", VERB_ANY, VERB_ANY, 0, noop_dispatcher },
+                {},
+        };
+
+        test_dispatch_one(STRV_MAKE(NULL), verbs, -EINVAL);
+}
+
+int main(int argc, char *argv[]) {
+        test_verbs();
+        test_verbs_no_default();
+
+        return 0;
+}

commit ee9c4ff4c89584ecf4e64f330fba627df099f4ad
Author: Dave Reisner <dreisner at archlinux.org>
Date:   Wed Jan 7 21:54:45 2015 -0500

    doc: fix stale references to systemd-verify
    
    This was subsumed into systemd-analyze back in 142c4ecaa98.

diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index 073e807..ecfc7af 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -352,7 +352,7 @@ Requires=different.service
 [Service]
 Desription=x
 
-$ systemd-verify ./user.slice
+$ systemd-analyze verify ./user.slice
 [./user.slice:9] Unknown lvalue 'WhatIsThis' in section 'Unit'
 [./user.slice:13] Unknown section 'Service'. Ignoring.
 Error: org.freedesktop.systemd1.LoadFailed:
@@ -376,7 +376,7 @@ ListenStream=100
 ListenStream=100
 Accept=yes
 
-$ systemd-verify ./a.socket ./b.socket
+$ systemd-analyze verify ./a.socket ./b.socket
 Service a.service not loaded, a.socket cannot be started.
 Service b at 0.service not loaded, b.socket cannot be started.
                         </programlisting>
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index ae243d6..bf0deb1 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -1592,7 +1592,7 @@
                         <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
-                        <citerefentry><refentrytitle>systemd-verify</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+                        <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
                         <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry>



More information about the systemd-commits mailing list