]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Enable test-ipcrm, test-hostname in unsafe tests
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Feb 2016 23:39:20 +0000 (18:39 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 5 Mar 2016 02:45:45 +0000 (21:45 -0500)
Makefile.am
configure.ac
src/test/test-ipcrm.c

index c6f6bc5d376dfe5867da9cc39db1374e764acaf4..e2d5328c1b1133e568e6649e0ec373ed59fc923e 100644 (file)
@@ -131,8 +131,12 @@ TEST_EXTENSIONS = .py
 PY_LOG_COMPILER = $(PYTHON)
 DISABLE_HARD_ERRORS = yes
 if ENABLE_TESTS
-noinst_PROGRAMS = $(manual_tests) $(tests)
+noinst_PROGRAMS = $(manual_tests) $(tests) $(unsafe_tests)
 TESTS = $(tests)
+if ENABLE_UNSAFE_TESTS
+TESTS += \
+       $(unsafe_tests)
+endif
 else
 noinst_PROGRAMS =
 TESTS =
@@ -1387,15 +1391,17 @@ EXTRA_DIST += \
 
 manual_tests += \
        test-ns \
-       test-hostname \
        test-cgroup \
        test-install \
-       test-ipcrm \
        test-btrfs \
        test-acd \
        test-ipv4ll-manual \
        test-ask-password-api
 
+unsafe_tests = \
+       test-hostname \
+       test-ipcrm
+
 if HAVE_LIBIPTC
 manual_tests += \
        test-firewall-util
index e55d1a02a62403857f628f29336b9b81a46ff92c..79340bcca956df1001220758e42d6a7befd9277e 100644 (file)
@@ -1487,9 +1487,10 @@ AS_IF([test x"$cross_compiling" = "xyes"], [], [
 ])
 
 AC_ARG_ENABLE(tests,
-        [AC_HELP_STRING([--disable-tests], [disable tests])],
+        [AC_HELP_STRING([--disable-tests], [disable tests, or enable extra tests with =unsafe])],
         enable_tests=$enableval, enable_tests=yes)
-AM_CONDITIONAL(ENABLE_TESTS, [test x$enable_tests = xyes])
+AM_CONDITIONAL(ENABLE_TESTS, [test x$enable_tests = xyes -o x$enable_tests = xunsafe])
+AM_CONDITIONAL(ENABLE_UNSAFE_TESTS, [test x$enable_tests = xunsafe])
 
 AC_ARG_ENABLE(debug,
         [AC_HELP_STRING([--enable-debug@<:@=LIST@:>@], [enable extra debugging (hashmap,mmap-cache)])],
@@ -1611,6 +1612,7 @@ AC_MSG_RESULT([
         ldconfig support:        ${enable_ldconfig}
         hibernate support:       ${enable_hibernate}
         extra debugging:         ${enable_debug}
+        tests:                   ${enable_tests}
 
         prefix:                  ${prefix}
         rootprefix:              ${with_rootprefix}
index 2464d32458c15634665dd4246fb1c54ef9d32f09..47b1c4443db4bd502a23dbd75563544b8b21db5d 100644 (file)
 
 int main(int argc, char *argv[]) {
         uid_t uid;
-
-        assert_se(argc == 2);
-        assert_se(parse_uid(argv[1], &uid) >= 0);
+        int r;
+        const char* name = argv[1] ?: "nfsnobody";
+
+        r = get_user_creds(&name, &uid, NULL, NULL, NULL);
+        if (r < 0) {
+                log_error("Failed to resolve \"nobody\": %m");
+                return EXIT_FAILURE;
+        }
 
         return clean_ipc(uid) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }