PolicyKit: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 21 15:03:28 UTC 2020


 .gitlab-ci.yml                                             |   44 ++++++++
 src/polkitbackend/polkitbackendjsauthority.cpp             |    5 -
 test/polkitbackend/Makefile.am                             |    6 -
 test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py |   65 +++++++++++++
 test/polkitbackend/test-polkitbackendjsauthority.c         |    2 
 5 files changed, 116 insertions(+), 6 deletions(-)

New commits:
commit 3eadcff2b186547a3303f4904a49e165cefb5623
Merge: 721e0a5 cd1dc64
Author: Jan Rybar <jrybar at redhat.com>
Date:   Fri Feb 21 15:03:26 2020 +0000

    Merge branch 'wip/hadess/add-ci' into 'master'
    
    ci: Add a CI and run tests
    
    See merge request polkit/polkit!46

commit cd1dc6450373704a1c9839ff6ad0a0336d27b858
Author: Bastien Nocera <hadess at hadess.net>
Date:   Fri Feb 21 15:03:25 2020 +0000

    ci: Add a CI
    
    Just compiles and installs polkit

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..6689607
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,44 @@
+image: fedora:rawhide
+
+variables:
+  DEPENDENCIES: gcc
+                gcc-c++
+                libtool
+                autoconf
+                automake
+                gtk-doc
+                intltool
+                gobject-introspection-devel
+                make
+                libxslt
+                pkgconfig(gio-2.0)
+                pkgconfig(mozjs-60)
+                expat-devel
+                pkgconfig(libsystemd)
+                pkgconfig(systemd)
+                pam-devel
+                python3-dbusmock
+
+build_stable:
+  before_script:
+    - dnf upgrade -y --nogpgcheck fedora-release fedora-repos*
+    - dnf update -y && dnf install -y $DEPENDENCIES
+  script:
+    - mkdir _build
+    - cd _build
+    - CPPFLAGS='-D_FORTIFY_SOURCE=2' ../autogen.sh
+      --disable-dependency-tracking
+      --enable-ansi
+      --enable-man-pages
+      --enable-test
+      --enable-libsystemd-login=yes
+      --enable-libelogind=no
+    - make
+    - make check
+    - make install
+  artifacts:
+    name: 'test logs'
+    when: 'always'
+    paths:
+      - '_build/test/*/*.log'
+
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index e97b8aa..0f18085 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1153,8 +1153,9 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
       if (identity == NULL)
         {
           polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
-                                        "Identity `%s' is not valid, ignoring",
-                                        identity_str);
+                                        "Identity `%s' is not valid, ignoring (%s)",
+                                        identity_str, error->message);
+          g_clear_error (&error);
         }
       else
         {
diff --git a/test/polkitbackend/Makefile.am b/test/polkitbackend/Makefile.am
index 53bfb2a..4b13256 100644
--- a/test/polkitbackend/Makefile.am
+++ b/test/polkitbackend/Makefile.am
@@ -33,16 +33,16 @@ TEST_PROGS =
 
 # ----------------------------------------------------------------------------------------------------
 
-TEST_PROGS += polkitbackendjsauthoritytest
 polkitbackendjsauthoritytest_SOURCES = test-polkitbackendjsauthority.c
 # force C++ link via dummy C++ file, (see GNU automake manual section 8.3.5)
 nodist_EXTRA_polkitbackendjsauthoritytest_SOURCES = dummy-force-cpp-link.cxx
 
+TESTS_ENVIRONMENT = TOP_BUILD_DIR="$(top_builddir)"
+TEST_PROGS += polkitbackendjsauthoritytest-wrapper.py
 
 # ----------------------------------------------------------------------------------------------------
 
-noinst_PROGRAMS = $(TEST_PROGS)
-check_PROGRAMS = $(TEST_PROGS)
+noinst_PROGRAMS = polkitbackendjsauthoritytest
 TESTS = $(TEST_PROGS)
 
 clean-local :
diff --git a/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py b/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py
new file mode 100755
index 0000000..2a4e160
--- /dev/null
+++ b/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python3
+
+# This program 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 3 of the License, or (at your option) any
+# later version.  See http://www.gnu.org/copyleft/lgpl.html for the full text
+# of the license.
+
+__author__ = 'Bastien Nocera'
+__email__ = 'hadess at hadess.net'
+__copyright__ = '(c) 2020 Red Hat Inc.'
+__license__ = 'LGPL 3+'
+
+import unittest
+import sys
+import subprocess
+import dbus
+import dbus.mainloop.glib
+import dbusmock
+import os
+import time
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+class TestPolkitBackendJsAuthority(dbusmock.DBusTestCase):
+    '''Test polkitbackendjsauthoritytest'''
+
+    @classmethod
+    def setUpClass(klass):
+        klass.start_system_bus()
+
+        klass.top_build_dir = '../../'
+        if 'TOP_BUILD_DIR' in os.environ:
+            klass.top_build_dir = os.environ['TOP_BUILD_DIR']
+        klass.mocklibc_path = klass.top_build_dir + '/test/mocklibc/bin/mocklibc'
+        assert(os.path.exists(klass.mocklibc_path))
+        print ('Top build dir: %s' % klass.top_build_dir)
+
+        klass.top_src_dir = os.path.dirname(os.path.realpath(__file__)) + '/../../'
+        if 'TOP_SRC_DIR' in os.environ:
+            klass.top_src_dir = os.environ['TOP_SRC_DIR']
+        print ('Top source dir: %s' % klass.top_src_dir)
+
+        os.environ['POLKIT_TEST_DATA'] = klass.top_src_dir + '/test/data'
+        print ('Polkit test data dir: %s' % os.environ['POLKIT_TEST_DATA'])
+
+        os.environ['MOCK_PASSWD'] = klass.top_src_dir + '/test/data/etc/passwd'
+        print ('Mock password file: %s' % os.environ['MOCK_PASSWD'])
+        os.environ['MOCK_GROUP'] = klass.top_src_dir + '/test/data/etc/group'
+        print ('Mock group file: %s' % os.environ['MOCK_GROUP'])
+        os.environ['MOCK_NETGROUP'] = klass.top_src_dir + '/test/data/etc/netgroup'
+        print ('Mock netgroup file: %s' % os.environ['MOCK_NETGROUP'])
+
+    def test_polkitbackendjsauthoritytest(self):
+        # Add '; exit 0' at the end of the cmd line if launching fails and you
+        # want to capture the error output
+        out = subprocess.check_output(self.mocklibc_path + ' ' + self.top_build_dir + '/test/polkitbackend/polkitbackendjsauthoritytest',
+                                      stderr=subprocess.STDOUT,
+                                      shell=True,
+                                      universal_newlines=True)
+        print(out)
+
+if __name__ == '__main__':
+    # avoid writing to stderr
+    unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
diff --git a/test/polkitbackend/test-polkitbackendjsauthority.c b/test/polkitbackend/test-polkitbackendjsauthority.c
index 71aad23..f97e0e0 100644
--- a/test/polkitbackend/test-polkitbackendjsauthority.c
+++ b/test/polkitbackend/test-polkitbackendjsauthority.c
@@ -101,7 +101,7 @@ test_get_admin_identities_for_action_id (const gchar         *action_id,
       g_assert_cmpstr (expected_admins[n], ==, s);
       g_free (s);
     }
-  g_assert (expected_admins[n] == NULL);
+  g_assert_cmpstr (expected_admins[n], ==, NULL);
 
   g_list_free_full (admin_identities, g_object_unref);
   g_clear_object (&details);


More information about the hal-commit mailing list