1.0-3.f2d38ce.git - update for another, current snapshot

...beyond booth-1.0 (commit f2d38ce), including:
  . support for solely manually managed tickets (9a365f9)
  . use asciidoctor instead of asciidoc for generating man pages (65e6a6b)

- switch to using Python 3 for the tests instead of Python 2
  (behind unversioned "python" references; rhbz#1555651)

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
This commit is contained in:
Jan Pokorný 2018-07-13 17:40:51 +02:00
parent e9372d6798
commit 9fb9198f67
No known key found for this signature in database
GPG Key ID: 61BBB23A9E8F8DE2
17 changed files with 1245 additions and 1234 deletions

View File

@ -0,0 +1,158 @@
From 9469ffc2d58a5673fffae8778b9c48f5605dda6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 10 Jul 2018 18:41:18 +0200
Subject: [PATCH] test: remove superfluous shebangs for import-only modules
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Consequently, there's no reason to have the affected files marked as
executable.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
test/arbtests.py | 2 --
test/assertions.py | 2 --
test/boothrunner.py | 2 --
test/boothtestenv.py | 2 --
test/clientenv.py | 2 --
test/clienttests.py | 2 --
test/serverenv.py | 2 --
test/servertests.py | 2 --
test/sitetests.py | 2 --
test/utils.py | 2 --
10 files changed, 20 deletions(-)
mode change 100755 => 100644 test/arbtests.py
mode change 100755 => 100644 test/assertions.py
mode change 100755 => 100644 test/boothrunner.py
mode change 100755 => 100644 test/boothtestenv.py
mode change 100755 => 100644 test/clientenv.py
mode change 100755 => 100644 test/clienttests.py
mode change 100755 => 100644 test/serverenv.py
mode change 100755 => 100644 test/servertests.py
mode change 100755 => 100644 test/sitetests.py
mode change 100755 => 100644 test/utils.py
diff --git a/test/arbtests.py b/test/arbtests.py
old mode 100755
new mode 100644
index caba010..ef7b7f9
--- a/test/arbtests.py
+++ b/test/arbtests.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
from servertests import ServerTests
class ArbitratorConfigTests(ServerTests):
diff --git a/test/assertions.py b/test/assertions.py
old mode 100755
new mode 100644
index 4396ab7..0b7f995
--- a/test/assertions.py
+++ b/test/assertions.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import re
class BoothAssertions:
diff --git a/test/boothrunner.py b/test/boothrunner.py
old mode 100755
new mode 100644
index f9154e7..d981183
--- a/test/boothrunner.py
+++ b/test/boothrunner.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import os
import subprocess
import time
diff --git a/test/boothtestenv.py b/test/boothtestenv.py
old mode 100755
new mode 100644
index 89a484a..fcd0c4d
--- a/test/boothtestenv.py
+++ b/test/boothtestenv.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import os
import subprocess
import time
diff --git a/test/clientenv.py b/test/clientenv.py
old mode 100755
new mode 100644
index fcd40fa..73b2791
--- a/test/clientenv.py
+++ b/test/clientenv.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
from boothtestenv import BoothTestEnvironment
from boothrunner import BoothRunner
diff --git a/test/clienttests.py b/test/clienttests.py
old mode 100755
new mode 100644
index 61b691b..c4b9d8a
--- a/test/clienttests.py
+++ b/test/clienttests.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import string
from clientenv import ClientTestEnvironment
diff --git a/test/serverenv.py b/test/serverenv.py
old mode 100755
new mode 100644
index d0467b9..c6d4e30
--- a/test/serverenv.py
+++ b/test/serverenv.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import os
import re
import time
diff --git a/test/servertests.py b/test/servertests.py
old mode 100755
new mode 100644
index f574f26..39a6ffc
--- a/test/servertests.py
+++ b/test/servertests.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import copy
from pprint import pprint, pformat
import re
diff --git a/test/sitetests.py b/test/sitetests.py
old mode 100755
new mode 100644
index dfdf6b9..6944ffe
--- a/test/sitetests.py
+++ b/test/sitetests.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
from servertests import ServerTests
class SiteConfigTests(ServerTests):
diff --git a/test/utils.py b/test/utils.py
old mode 100755
new mode 100644
index ceeef98..5b70cfc
--- a/test/utils.py
+++ b/test/utils.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
import subprocess
import re
--
2.18.0.rc2

View File

@ -1,112 +0,0 @@
From d44c03a264dc10715c197b1160a7fcdaf7b52a5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 26 Apr 2016 16:43:50 +0200
Subject: [PATCH 1/6] Feature: offer alternatives to libraries from
(cluster-)glue
This revision is a preparation work establishing --without-glue switch
to configure that will eventually allow non-glue alternatives.
The analogous conditional is added to the spec file, based on premise
that cluster-glue will not be re-introduced into Fedora, RHEL, etc.
---
booth.spec | 20 +++++++++++++++++---
configure.ac | 5 +++++
src/Makefile.am | 6 +++---
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/booth.spec b/booth.spec
index cd54ab1..f73d2d8 100644
--- a/booth.spec
+++ b/booth.spec
@@ -1,5 +1,11 @@
%bcond_with html_man
+%if 0%{?fedora} > 18 || 0%{?centos} > 6 || 0%{?rhel} > 6
+%bcond_with glue
+%else
+%bcond_without glue
+%endif
+
%if 0%{?suse_version}
%global booth_docdir %{_defaultdocdir}/%{name}
%else
@@ -50,17 +56,24 @@ BuildRequires: pkgconfig(glib-2.0)
%endif
BuildRequires: libgcrypt-devel
%if 0%{?fedora} || 0%{?centos} || 0%{?rhel}
-BuildRequires: cluster-glue-libs-devel
BuildRequires: pacemaker-libs-devel
%else
-BuildRequires: libglue-devel
BuildRequires: libpacemaker-devel
%endif
+%if 0%{?with_glue}
+%if 0%{?fedora} || 0%{?centos} || 0%{?rhel}
+BuildRequires: cluster-glue-libs-devel
+%else
+BuildRequires: libglue-devel
+%endif
+%endif
BuildRequires: libxml2-devel
BuildRequires: zlib-devel
%if 0%{?fedora} || 0%{?centos} || 0%{?rhel}
Requires: pacemaker >= 1.1.8
+%if 0%{?with_glue}
Requires: cluster-glue-libs >= 1.0.6
+%endif
%else
Requires: pacemaker-ticket-support >= 2.0
%endif
@@ -79,7 +92,8 @@ Pacemaker.
%configure \
--with-initddir=%{_initrddir} \
--docdir=%{booth_docdir} \
- %{!?with_html_man:--without-html_man}
+ %{!?with_html_man:--without-html_man} \
+ %{!?with_glue:--without-glue}
make
diff --git a/configure.ac b/configure.ac
index ab2ad43..1a8ed4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -215,6 +215,11 @@ AC_ARG_WITH([html_man],
[],
[with_html_man=yes])
+AC_ARG_WITH([glue],
+ [ --without-glue : Avoid libraries from (cluster-)glue project.],
+ [],
+ [with_glue=yes])
+
# OS detection
# THIS SECTION MUST DIE!
CP=cp
diff --git a/src/Makefile.am b/src/Makefile.am
index 7d05d76..e7f5aa2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,9 @@ sbin_PROGRAMS = boothd
boothd_SOURCES = config.c main.c raft.c ticket.c transport.c \
pacemaker.c handler.c request.c attr.c
+noinst_HEADERS = booth.h pacemaker.h \
+ config.h log.h raft.h ticket.h transport.h handler.h request.h attr.h
+
if BUILD_TIMER_C
boothd_SOURCES += timer.c
endif
@@ -22,8 +25,5 @@ boothd_LDFLAGS = $(OS_DYFLAGS) -L./
boothd_LDADD = -lplumb -lplumbgpl -lm $(GLIB_LIBS) $(ZLIB_LIBS)
boothd_CFLAGS = $(GLIB_CFLAGS)
-noinst_HEADERS = booth.h pacemaker.h \
- config.h log.h raft.h ticket.h transport.h handler.h request.h attr.h
-
lint:
-splint $(INCLUDES) $(LINT_FLAGS) $(CFLAGS) *.c
--
2.4.11

View File

@ -0,0 +1,60 @@
From a642a833e31a6bd1e71dc2045a16e494775b35e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Thu, 12 Jul 2018 18:58:32 +0200
Subject: [PATCH] test: do not mix tabs with spaces in Python code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Beside being matter of a good style, it's also forbidden inside
a single, non-delimited block in Python 3.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
test/servertests.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/test/servertests.py b/test/servertests.py
index 39a6ffc..71e808e 100644
--- a/test/servertests.py
+++ b/test/servertests.py
@@ -51,8 +51,8 @@ class ServerTests(ServerTestEnvironment):
config_text=self.working_config)
def test_missing_quotes(self):
- # quotes no longer required
- return True
+ # quotes no longer required
+ return True
orig_lines = self.working_config.split("\n")
for i in xrange(len(orig_lines)):
new_lines = copy.copy(orig_lines)
@@ -97,8 +97,8 @@ class ServerTests(ServerTestEnvironment):
expected_exitcode=None, expected_daemon=True)
def test_missing_transport(self):
- # UDP is default -- TODO?
- return True
+ # UDP is default -- TODO?
+ return True
config = re.sub('transport=.+\n', '', self.typical_config)
(pid, ret, stdout, stderr, runner) = \
self.run_booth(config_text=config, expected_exitcode=1, expected_daemon=False)
@@ -141,10 +141,10 @@ class ServerTests(ServerTestEnvironment):
self.assertRegexpMatches(stderr, 'ticket name "' + ticket + '" invalid')
def test_unreachable_peer(self):
- # what should this test do? daemon not expected, but no exitcode either?
- # booth would now just run, and try to reach that peer...
- # TCP reachability is not required during startup anymore.
- return True
+ # what should this test do? daemon not expected, but no exitcode either?
+ # booth would now just run, and try to reach that peer...
+ # TCP reachability is not required during startup anymore.
+ return True
config = re.sub('#(.+147.+)', lambda m: m.group(1), self.working_config)
self.run_booth(config_text=config,
expected_exitcode=None, expected_daemon=False)
--
2.18.0.rc2

View File

@ -1,373 +0,0 @@
From c1211c0d47fb510fbd659d9165dc584a9181ec22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 26 Apr 2016 16:44:48 +0200
Subject: [PATCH 2/6] Feature: alternative logging provider: libqb
---
booth.spec | 3 ++
configure.ac | 28 ++++++++++++++++-
src/Makefile.am | 8 +++++
src/alt/logging_libqb.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++
src/alt/logging_libqb.h | 70 +++++++++++++++++++++++++++++++++++++++++
src/log.h | 22 +++++++++----
src/main.c | 26 ++++++++++++---
7 files changed, 229 insertions(+), 12 deletions(-)
create mode 100644 src/alt/logging_libqb.c
create mode 100644 src/alt/logging_libqb.h
diff --git a/booth.spec b/booth.spec
index f73d2d8..cc73af2 100644
--- a/booth.spec
+++ b/booth.spec
@@ -66,6 +66,9 @@ BuildRequires: cluster-glue-libs-devel
%else
BuildRequires: libglue-devel
%endif
+%else
+# logging provider
+BuildRequires: pkgconfig(libqb)
%endif
BuildRequires: libxml2-devel
BuildRequires: zlib-devel
diff --git a/configure.ac b/configure.ac
index 1a8ed4c..32a7dd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ AC_PREREQ([2.61])
AC_INIT([booth], [1.0], [users@clusterlabs.org])
-AM_INIT_AUTOMAKE([-Wno-portability])
+AM_INIT_AUTOMAKE([-Wno-portability subdir-objects])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADER([src/b_config.h src/booth_config.h])
@@ -220,6 +220,31 @@ AC_ARG_WITH([glue],
[],
[with_glue=yes])
+# figure out logging provider
+logging_provider=""
+if test "x$logging_provider" = "x" && test "x$with_glue" = "xyes"; then
+ AC_CHECK_LIB([plumb], [cl_log], [logging_provider="libplumb"])
+fi
+if test "x$logging_provider" = "x" && test "x$with_glue" = "xno"; then
+ AC_CHECK_LIB([qb], [qb_log_real_], [logging_provider="libqb"])
+fi
+case "$logging_provider" in
+libplumb)
+ ;;
+libqb)
+ PKG_CHECK_MODULES([LIBQB], [libqb])
+ AC_DEFINE([LOGGING_LIBQB], [], [use libqb as a logging provider])
+ PKG_CHECK_MODULES([LIBQB1], [libqb >= 1.0],
+ [AC_DEFINE([LOGGING_LIBQB_MAJOR], [1],
+ [libqb major version lower bound])],
+ [AC_MSG_WARN([[syslog identifier will not get changed]])])
+ ;;
+*)
+ AC_MSG_ERROR([logging provider required (libplumb, or libqb when --without-glue)])
+ ;;
+esac
+AM_CONDITIONAL([LOGGING_LIBQB], [test "x$logging_provider" = "xlibqb"])
+
# OS detection
# THIS SECTION MUST DIE!
CP=cp
@@ -448,6 +473,7 @@ AC_MSG_RESULT([ System init.d directory = ${INITDDIR}])
AC_MSG_RESULT([ booth config dir = ${BOOTHSYSCONFDIR}])
AC_MSG_RESULT([ SOCKETDIR = ${SOCKETDIR}])
AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
+AC_MSG_RESULT([ Logging provider = ${logging_provider}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Library SONAME = ${SONAME}])
diff --git a/src/Makefile.am b/src/Makefile.am
index e7f5aa2..49c3ac4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,5 +25,13 @@ boothd_LDFLAGS = $(OS_DYFLAGS) -L./
boothd_LDADD = -lplumb -lplumbgpl -lm $(GLIB_LIBS) $(ZLIB_LIBS)
boothd_CFLAGS = $(GLIB_CFLAGS)
+if !LOGGING_LIBQB
+boothd_LDADD += -lplumb
+else
+boothd_LDADD += $(LIBQB_LIBS)
+boothd_SOURCES += alt/logging_libqb.c
+noinst_HEADERS += alt/logging_libqb.h
+endif
+
lint:
-splint $(INCLUDES) $(LINT_FLAGS) $(CFLAGS) *.c
diff --git a/src/alt/logging_libqb.c b/src/alt/logging_libqb.c
new file mode 100644
index 0000000..34cf97c
--- /dev/null
+++ b/src/alt/logging_libqb.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2016 Jan Pokorny <jpokorny@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <qb/qblog.h>
+
+#include "logging_libqb.h"
+
+int debug_level = 0;
+
+/* ENV_X definitions based on glue/lib/clplumbing/cl_log.c of glue project:
+ http://hg.linux-ha.org/glue */
+#define ENV_HADEBUGVAL "HA_debug"
+#define ENV_LOGFENV "HA_logfile" /* well-formed log file :-) */
+#define ENV_DEBUGFENV "HA_debugfile" /* Debug log file */
+#define ENV_LOGFACILITY "HA_logfacility"/* Facility to use for logger */
+#define ENV_SYSLOGFMT "HA_syslogmsgfmt"/* TRUE if we should use syslog message formatting */
+
+void
+alt_qb_inherit_logging_environment(void)
+{
+ char *inherit_env;
+
+ /* Don't need to free the return pointer from getenv */
+ inherit_env = getenv(ENV_HADEBUGVAL);
+ if (inherit_env != NULL && atoi(inherit_env) != 0 )
+ debug_level = atoi(inherit_env);
+
+ inherit_env = getenv(ENV_LOGFENV);
+ if (inherit_env != NULL && *inherit_env != '\0') {
+ int32_t log_fd = qb_log_file_open(inherit_env);
+ qb_log_ctl(log_fd, QB_LOG_CONF_ENABLED, QB_TRUE);
+ /* do not log debug info even if debug_level non-zero */
+ qb_log_filter_ctl(log_fd, QB_LOG_FILTER_ADD,
+ QB_LOG_FILTER_FILE, "*", LOG_INFO);
+ }
+
+ inherit_env = getenv(ENV_DEBUGFENV);
+ if (inherit_env != NULL && *inherit_env != '\0') {
+ int32_t log_fd = qb_log_file_open(inherit_env);
+ qb_log_ctl(log_fd, QB_LOG_CONF_ENABLED, QB_TRUE);
+ }
+
+ inherit_env = getenv(ENV_LOGFACILITY);
+ if (inherit_env != NULL && *inherit_env != '\0') {
+ int fac = qb_log_facility2int(inherit_env);
+ if (fac > 0)
+ qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_FACILITY, fac);
+ else
+ qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE);
+ }
+
+ inherit_env = getenv(ENV_SYSLOGFMT);
+ if (inherit_env != NULL && *inherit_env != '\0'
+ && ( !strcasecmp(inherit_env, "false")
+ || !strcasecmp(inherit_env, "off")
+ || !strcasecmp(inherit_env, "no")
+ || !strcasecmp(inherit_env, "n")
+ || !strcasecmp(inherit_env, "0"))){
+ enum qb_log_target_slot i;
+ for (i = QB_LOG_TARGET_START; i < QB_LOG_TARGET_MAX; i++) {
+ if (i == QB_LOG_SYSLOG || i == QB_LOG_BLACKBOX)
+ continue;
+ qb_log_format_set(i, NULL);
+ }
+ }
+}
diff --git a/src/alt/logging_libqb.h b/src/alt/logging_libqb.h
new file mode 100644
index 0000000..76592d4
--- /dev/null
+++ b/src/alt/logging_libqb.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2016 Jan Pokorny <jpokorny@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <qb/qblog.h>
+
+#include "b_config.h"
+
+/* qb logging compat definitions */
+#if (!defined LOGGING_LIBQB_MAJOR || (LOGGING_LIBQB_MAJOR < 1))
+enum tmp_log_target_slot {
+ TMP_LOG_SYSLOG = QB_LOG_SYSLOG,
+ TMP_LOG_STDERR = QB_LOG_STDERR,
+ TMP_LOG_BLACKBOX = QB_LOG_BLACKBOX,
+ TMP_LOG_TARGET_MAX = QB_LOG_TARGET_MAX,
+};
+
+#undef QB_LOG_SYSLOG
+#undef QB_LOG_STDERR
+#undef QB_LOG_BLACKBOX
+#undef QB_LOG_TARGET_MAX
+
+enum qb_log_target_slot {
+ QB_LOG_TARGET_START,
+ QB_LOG_SYSLOG = TMP_LOG_SYSLOG,
+ QB_LOG_STDERR = TMP_LOG_STDERR,
+ QB_LOG_BLACKBOX = TMP_LOG_BLACKBOX,
+ QB_LOG_TARGET_MAX = TMP_LOG_TARGET_MAX,
+};
+
+#define QB_LOG_CTL2_S(a) (a)
+#define qb_log_ctl2(t, s, a) ((void) 0)
+#endif
+
+
+#ifndef HA_LOG_FACILITY
+/* based on glue/configure.ac of glue project: http://hg.linux-ha.org/glue */
+#define HA_LOG_FACILITY LOG_DAEMON
+#endif
+
+extern int debug_level;
+#define ANYDEBUG (debug_level)
+
+void alt_qb_inherit_logging_environment(void);
+
+#define cl_log_set_entity(ent) \
+ (void) qb_log_ctl2(QB_LOG_SYSLOG, QB_LOG_CONF_IDENT, QB_LOG_CTL2_S(ent))
+
+#define cl_log_enable_stderr(b) \
+ (void) qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, b ? QB_TRUE : QB_FALSE)
+
+#define cl_log_set_facility(f) \
+ (void) qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_FACILITY, f)
+
+#define cl_inherit_logging_environment(logqueuemax) \
+ alt_qb_inherit_logging_environment()
diff --git a/src/log.h b/src/log.h
index 0be4066..e570a8d 100644
--- a/src/log.h
+++ b/src/log.h
@@ -21,26 +21,36 @@
#ifndef _LOG_H
#define _LOG_H
+#include "b_config.h"
+
+#ifndef LOGGING_LIBQB
#include <heartbeat/glue_config.h>
#include <clplumbing/cl_log.h>
+#define priv_log(prio, ...) cl_log(prio, __VA_ARGS__)
+#else
+#include "alt/logging_libqb.h"
+#define priv_log(prio, ...) qb_log(prio, __VA_ARGS__)
+#endif
+
#include "inline-fn.h"
+
#define log_debug(fmt, args...) do { \
- if (ANYDEBUG) cl_log(LOG_DEBUG, fmt, ##args); } \
+ if (ANYDEBUG) priv_log(LOG_DEBUG, fmt, ##args); } \
while (0)
-#define log_info(fmt, args...) cl_log(LOG_INFO, fmt, ##args)
-#define log_warn(fmt, args...) cl_log(LOG_WARNING, fmt, ##args)
-#define log_error(fmt, args...) cl_log(LOG_ERR, fmt, ##args)
+#define log_info(fmt, args...) priv_log(LOG_INFO, fmt, ##args)
+#define log_warn(fmt, args...) priv_log(LOG_WARNING, fmt, ##args)
+#define log_error(fmt, args...) priv_log(LOG_ERR, fmt, ##args)
/* all tk_* macros prepend "%(tk->name): " (the caller needs to
* have the ticket named tk!)
*/
#define tk_cl_log(sev, fmt, args...) \
- cl_log(sev, "%s (%s/%d/%d): " fmt, \
+ priv_log(sev, "%s (%s/%d/%d): " fmt, \
tk->name, state_to_string(tk->state), tk->current_term, term_time_left(tk), \
##args)
#define tk_cl_log_src(sev, fmt, args...) \
- cl_log(sev, "%s:%d: %s (%s/%d/%d): " fmt, \
+ priv_log(sev, "%s:%d: %s (%s/%d/%d): " fmt, \
__FUNCTION__, __LINE__, \
tk->name, state_to_string(tk->state), tk->current_term, term_time_left(tk), \
##args)
diff --git a/src/main.c b/src/main.c
index c377392..498718b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1536,6 +1536,9 @@ int main(int argc, char *argv[], char *envp[])
{
int rv;
const char *cp;
+#ifdef LOGGING_LIBQB
+ enum qb_log_target_slot i;
+#endif
init_set_proc_title(argc, argv, envp);
get_time(&start_time);
@@ -1546,15 +1549,25 @@ int main(int argc, char *argv[], char *envp[])
cl.lockfile[0] = 0;
debug_level = 0;
- cl_log_set_entity(
- (cp = strstr(argv[0], ATTR_PROG)) && !strcmp(cp, ATTR_PROG)
+
+ cp = ((cp = strstr(argv[0], ATTR_PROG)) && !strcmp(cp, ATTR_PROG)
? ATTR_PROG
- : "booth"
- );
+ : "booth");
+#ifndef LOGGING_LIBQB
+ cl_log_set_entity(cp);
+#else
+ qb_log_init(cp, LOG_USER, LOG_DEBUG); /* prio driven by debug_level */
+ for (i = QB_LOG_TARGET_START; i < QB_LOG_TARGET_MAX; i++) {
+ if (i == QB_LOG_SYSLOG || i == QB_LOG_BLACKBOX)
+ continue;
+ qb_log_format_set(i, "%t %H %N: [%P]: %p: %b");
+ }
+ (void) qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
+ QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
+#endif
cl_log_enable_stderr(TRUE);
cl_log_set_facility(0);
-
rv = read_arguments(argc, argv);
if (rv < 0)
goto out;
@@ -1581,6 +1594,9 @@ int main(int argc, char *argv[], char *envp[])
}
out:
+#ifdef LOGGING_LIBQB
+ qb_log_fini();
+#endif
/* Normalize values. 0x100 would be seen as "OK" by waitpid(). */
return (rv >= 0 && rv < 0x70) ? rv : 1;
}
--
2.4.11

View File

@ -0,0 +1,510 @@
From ab2229451827f530959d554920619d87daa34586 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 11 Jul 2018 16:18:25 +0200
Subject: [PATCH] test: make Python files supported _also_ with Python 3.3+
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- use "print" like a function rather than a statement
. where implicit newline is to be suppressed, don't do that
and rather strip it from the string to be printed instead
- use 2+3 compatible convention for parametrizing exceptions
- Python 3 doesn't recognize "basestring" class, and at the place
of use (pre Python 2.7 only), unicode string is really not expected
(also re.UNICODE flag is not used...)
- Python 3 doesn't recognize "xrange" function, but the surrounding
code can be reasonably simplified using "enumerate" function
- arrange dict treatment in a compatible way:
. d.has_key(k) -> k in d
. d.iteritems() -> custom "iter_items", always efficient wrapper
. d.iterkeys(), here incl. lazy mapping and filtering
-> rewrite while retaining laziness
. optimize UT.merge_dicts in script/unit-test.py along
- also in three instances, deal with string/uninterpreted bytes proper
dichotomy introduced in Python 3, and related to that, "string"
module only supports "ascii_lowercase" attribute in Python 3
(as opposed to system-specific plain "lowercase" one)
Note that script/unit-test.py has a pre-existing issue (regardless
of which Python version interpreter is used), so at least document
that in the header for now.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
script/unit-test.py | 65 ++++++++++++++++++++++++++------------------
test/assertions.py | 4 +--
test/boothrunner.py | 32 ++++++++++++----------
test/boothtestenv.py | 6 ++--
test/clienttests.py | 4 +--
test/runtests.py | 2 +-
test/serverenv.py | 18 ++++++------
test/servertests.py | 10 +++----
test/utils.py | 10 +++++--
9 files changed, 84 insertions(+), 67 deletions(-)
diff --git a/script/unit-test.py b/script/unit-test.py
index 6871930..399528e 100755
--- a/script/unit-test.py
+++ b/script/unit-test.py
@@ -1,6 +1,8 @@
#!/usr/bin/python
# vim: fileencoding=utf-8
# see http://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding
+# NOTE: setting the encoding is needed as non-ASCII characters are contained
+# FIXME: apparently, pexpect.EOF is not being excepted properly
import os, sys, time, signal, tempfile, socket, posix, time
import re, shutil, pexpect, logging, pprint
@@ -16,6 +18,16 @@ default_log_format = '%(asctime)s: : %(message)s'
default_log_datefmt = '%b %d %H:%M:%S'
+# Compatibility with dictionary methods not present in Python 3;
+# https://www.python.org/dev/peps/pep-0469/#migrating-to-the-common-subset-of-python-2-and-3
+try:
+ dict.iteritems
+except AttributeError: # Python 3
+ iter_items = lambda d: iter(d.items())
+else: # Python 2
+ iter_items = lambda d: d.iteritems()
+
+
# {{{ pexpect-logging glue
# needed for use as pexpect.logfile, to relay into existing logfiles
class expect_logging():
@@ -28,9 +40,12 @@ class expect_logging():
def flush(self, *arg):
pass
+
def write(self, stg):
if self.test.dont_log_expect == 0:
# TODO: split by input/output, give program
+ if sys.version_info[0] >= 3:
+ stg = str(stg, 'UTF-8')
for line in re.split(r"[\r\n]+", stg):
if line == self.test.prompt:
continue
@@ -110,7 +125,7 @@ class UT():
res = re.match(r"^\s*(\w+)\s*:(?:\s*(#.*?\S))?\s*$", line)
if res:
state = res.group(1)
- if not m.has_key(state):
+ if state not in m:
m[state] = dict_plus()
if res.group(2):
m[state].aux["comment"] = res.group(2)
@@ -188,17 +203,15 @@ class UT():
name = re.sub(r".*/", "", bin)
# How to get stderr, too?
expct = pexpect.spawn(bin,
- env = dict( os.environ.items() +
- [('PATH',
- self.test_base + "/bin/:" +
- os.getenv('PATH')),
- ('UNIT_TEST_PATH', self.test_base),
- ('LC_ALL', 'C'),
- ('LANG', 'C')] +
- env_add ),
- timeout = 30,
- maxread = 32768,
- **args)
+ env=dict(os.environ, **dict({
+ 'PATH': ':'.join((self.test_base + "/bin/",
+ os.getenv('PATH'))),
+ 'UNIT_TEST_PATH': self.test_base,
+ 'LC_ALL': 'C',
+ 'LANG': 'C'}, **dict(env_add))),
+ timeout=30,
+ maxread=32768,
+ **args)
expct.setecho(False)
expct.logfile_read = expect_logging("<- %s" % name, self)
expct.logfile_send = expect_logging(" -> %s" % name, self)
@@ -361,7 +374,7 @@ class UT():
self.current_nr = kv.aux.get("line")
#os.system("strace -f -tt -s 2000 -e write -p" + str(self.gdb.pid) + " &")
- for n, v in kv.iteritems():
+ for n, v in iter_items(kv):
self.set_val( self.translate_shorthand(n, "ticket"), v)
logging.info("set state")
@@ -372,7 +385,7 @@ class UT():
if not sys.stdin.isatty():
logging.error("Not a terminal, stopping.")
else:
- print "\n\nEntering interactive mode.\n\n"
+ print("\n\nEntering interactive mode.\n\n")
self.gdb.sendline("set prompt GDB> \n")
self.gdb.setecho(True)
# can't use send_cmd, doesn't reply with expected prompt anymore.
@@ -415,7 +428,7 @@ class UT():
self.send_cmd("next")
# push message.
- for (n, v) in msg.iteritems():
+ for (n, v) in iter_items(msg):
self.set_val( self.translate_shorthand(n, "message"), v, "htonl")
# set "received" length
@@ -426,7 +439,7 @@ class UT():
def wait_outgoing(self, msg):
self.wait_for_function("booth_udp_send")
ok = True
- for (n, v) in msg.iteritems():
+ for (n, v) in iter_items(msg):
if re.search(r"\.", n):
ok = self.check_value( self.translate_shorthand(n, "inject"), v) and ok
else:
@@ -438,14 +451,12 @@ class UT():
#stopped_at = self.sync()
def merge_dicts(self, base, overlay):
- return dict(base.items() + overlay.items())
+ return dict(base, **overlay)
def loop(self, fn, data):
- matches = map(lambda k: re.match(r"^(outgoing|message)(\d+)$", k), data.iterkeys())
- valid_matches = filter(None, matches)
- nums = map(lambda m: int(m.group(2)), valid_matches)
- loop_max = max(nums)
+ matches = (re.match(r"^(outgoing|message)(\d+)$", k) for k in data)
+ loop_max = max(int(m.group(2)) for m in matches if m)
for counter in range(0, loop_max+1): # incl. last message
kmsg = 'message%d' % counter
@@ -471,14 +482,14 @@ class UT():
logging.info("ticket change %s (%s:%d) %s" % (ktkt, fn, self.current_nr, comment))
self.set_state(tkt)
if gdb:
- for (k, v) in gdb.iteritems():
+ for (k, v) in iter_items(gdb):
self.send_cmd(k + " " + v.replace("§", "\n"))
if msg:
self.current_nr = msg.aux.get("line")
comment = msg.aux.get("comment", "")
logging.info("sending %s (%s:%d) %s" % (kmsg, fn, self.current_nr, comment))
self.send_message(self.merge_dicts(data["message"], msg))
- if data.has_key(kgdb) and len(gdb) == 0:
+ if kgdb in data and len(gdb) == 0:
self.user_debug("manual override")
if out:
self.current_nr = out.aux.get("line")
@@ -520,7 +531,7 @@ class UT():
self.let_booth_go_a_bit()
ok = True
- for (n, v) in data.iteritems():
+ for (n, v) in iter_items(data):
ok = self.check_value( self.translate_shorthand(n, "ticket"), v) and ok
if not ok:
sys.exit(1)
@@ -529,8 +540,8 @@ class UT():
def run(self, start_from="000", end_with="999"):
os.chdir(self.test_base)
# TODO: sorted, random order
- tests = filter( (lambda f: re.match(r"^\d\d\d_.*\.txt$", f)), glob.glob("*"))
- tests.sort()
+ tests = sorted(f for f in glob.glob("*")
+ if re.match(r"^\d\d\d_.*\.txt$", f))
failed = 0
for f in tests:
if f[0:3] < start_from:
@@ -561,7 +572,7 @@ class UT():
except:
failed += 1
logging.error(self.colored_string("Broke in %s:%s %s" % (f, self.current_nr, sys.exc_info()), self.RED))
- for frame in traceback.format_tb(sys.exc_traceback):
+ for frame in traceback.format_tb(sys.exc_info()[2]):
logging.info(" - %s " % frame.rstrip())
finally:
self.stop_processes()
diff --git a/test/assertions.py b/test/assertions.py
index 0b7f995..34333ca 100644
--- a/test/assertions.py
+++ b/test/assertions.py
@@ -21,7 +21,7 @@ class BoothAssertions:
# backported from 2.7 just in case we're running on an older Python
def assertRegexpMatches(self, text, expected_regexp, msg=None):
"""Fail the test unless the text matches the regular expression."""
- if isinstance(expected_regexp, basestring):
+ if isinstance(expected_regexp, str):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(text, MULTILINE):
msg = msg or "Regexp didn't match"
@@ -30,7 +30,7 @@ class BoothAssertions:
def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
"""Fail the test if the text matches the regular expression."""
- if isinstance(unexpected_regexp, basestring):
+ if isinstance(unexpected_regexp, str):
unexpected_regexp = re.compile(unexpected_regexp)
match = unexpected_regexp.search(text)
if match:
diff --git a/test/boothrunner.py b/test/boothrunner.py
index d981183..347912b 100644
--- a/test/boothrunner.py
+++ b/test/boothrunner.py
@@ -1,4 +1,5 @@
import os
+import sys
import subprocess
import time
import unittest
@@ -37,14 +38,14 @@ class BoothRunner:
def show_output(self, stdout, stderr):
if stdout:
- print "STDOUT:"
- print "------"
- print stdout,
+ print("STDOUT:")
+ print("------")
+ print(stdout.rstrip('\n'))
if stderr:
- print "STDERR: (N.B. crm_ticket failures indicate daemon started correctly)"
- print "------"
- print stderr,
- print "-" * 70
+ print("STDERR: (N.B. crm_ticket failures indicate daemon started correctly)")
+ print("------")
+ print(stderr.rstrip('\n'))
+ print("-" * 70)
def subproc_completed_within(self, p, timeout):
start = time.time()
@@ -55,7 +56,7 @@ class BoothRunner:
elapsed = time.time() - start
if elapsed + wait > timeout:
wait = timeout - elapsed
- print "Waiting on %d for %.1fs ..." % (p.pid, wait)
+ print("Waiting on %d for %.1fs ..." % (p.pid, wait))
time.sleep(wait)
elapsed = time.time() - start
if elapsed >= timeout:
@@ -83,26 +84,29 @@ class BoothRunner:
return text
def show_args(self):
- print "\n"
- print "-" * 70
- print "Running", ' '.join(self.all_args())
+ print("\n")
+ print("-" * 70)
+ print("Running", ' '.join(self.all_args()))
msg = "with config from %s" % self.config_file_used()
config_text = self.config_text_used()
if config_text is not None:
msg += ": [%s]" % config_text
- print msg
+ print(msg)
def run(self):
p = subprocess.Popen(self.all_args(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if not p:
- raise RuntimeError, "failed to start subprocess"
+ raise RuntimeError("failed to start subprocess")
- print "Started subprocess pid %d" % p.pid
+ print("Started subprocess pid %d" % p.pid)
completed = self.subproc_completed_within(p, 2)
if completed:
(stdout, stderr) = p.communicate()
+ if sys.version_info[0] >= 3:
+ # only expect ASCII/UTF-8 encodings for the obtained input bytes
+ stdout, stderr = str(stdout, 'UTF-8'), str(stderr, 'UTF-8')
self.show_output(stdout, stderr)
return (p.pid, p.returncode, stdout, stderr)
diff --git a/test/boothtestenv.py b/test/boothtestenv.py
index fcd0c4d..59e25c3 100644
--- a/test/boothtestenv.py
+++ b/test/boothtestenv.py
@@ -17,7 +17,7 @@ class BoothTestEnvironment(unittest.TestCase, BoothAssertions):
def setUp(self):
if not self._testMethodName.startswith('test_'):
- raise RuntimeError, "unexpected test method name: " + self._testMethodName
+ raise RuntimeError("unexpected test method name: " + self._testMethodName)
self.test_name = self._testMethodName[5:]
self.test_path = os.path.join(self.test_run_path, self.test_name)
os.makedirs(self.test_path)
@@ -54,11 +54,11 @@ class BoothTestEnvironment(unittest.TestCase, BoothAssertions):
def check_return_code(self, pid, return_code, expected_exitcode):
if return_code is None:
- print "pid %d still running" % pid
+ print("pid %d still running" % pid)
if expected_exitcode is not None:
self.fail("expected exit code %d, not long-running process" % expected_exitcode)
else:
- print "pid %d exited with code %d" % (pid, return_code)
+ print("pid %d exited with code %d" % (pid, return_code))
if expected_exitcode is None:
msg = "should not exit"
else:
diff --git a/test/clienttests.py b/test/clienttests.py
index c4b9d8a..512620e 100644
--- a/test/clienttests.py
+++ b/test/clienttests.py
@@ -7,14 +7,14 @@ class ClientConfigTests(ClientTestEnvironment):
def test_site_buffer_overflow(self):
# https://bugzilla.novell.com/show_bug.cgi?id=750256
- longfile = (string.lowercase * 3)[:63]
+ longfile = (string.ascii_lowercase * 3)[:63]
expected_error = "'%s' exceeds maximum site name length" % longfile
args = [ 'grant', '-s', longfile, '-t', 'ticket' ]
self._test_buffer_overflow(expected_error, args=args)
def test_ticket_buffer_overflow(self):
# https://bugzilla.novell.com/show_bug.cgi?id=750256
- longfile = (string.lowercase * 3)[:63]
+ longfile = (string.ascii_lowercase * 3)[:63]
expected_error = "'%s' exceeds maximum ticket name length" % longfile
args = [ 'grant', '-s', 'site', '-t', longfile ]
self._test_buffer_overflow(expected_error, args=args)
diff --git a/test/runtests.py b/test/runtests.py
index 0532c01..833b1a7 100755
--- a/test/runtests.py
+++ b/test/runtests.py
@@ -53,5 +53,5 @@ if __name__ == '__main__':
shutil.rmtree(test_run_path)
sys.exit(0)
else:
- print "Left %s for debugging" % test_run_path
+ print("Left %s for debugging" % test_run_path)
sys.exit(1)
diff --git a/test/serverenv.py b/test/serverenv.py
index c6d4e30..5d6c6c4 100644
--- a/test/serverenv.py
+++ b/test/serverenv.py
@@ -73,12 +73,10 @@ ticket="ticketB"
where return_code/stdout/stderr are None iff pid is still running.
'''
if expected_daemon and expected_exitcode is not None and expected_exitcode != 0:
- raise RuntimeError, \
- "Shouldn't ever expect daemon to start and then failure"
+ raise RuntimeError("Shouldn't ever expect daemon to start and then failure")
if not expected_daemon and expected_exitcode == 0:
- raise RuntimeError, \
- "Shouldn't ever expect success without starting daemon"
+ raise RuntimeError("Shouldn't ever expect success without starting daemon")
self.init_log()
@@ -122,9 +120,9 @@ ticket="ticketB"
return config_file
def kill_pid(self, pid):
- print "killing %d ..." % pid
+ print("killing %d ..." % pid)
os.kill(pid, 15)
- print "killed"
+ print("killed")
def check_daemon_handling(self, runner, expected_daemon):
'''
@@ -154,7 +152,7 @@ ticket="ticketB"
Returns the pid contained in lock_file, or None if it doesn't exist.
'''
if not os.path.exists(lock_file):
- print "%s does not exist" % lock_file
+ print("%s does not exist" % lock_file)
return None
l = open(lock_file)
@@ -162,7 +160,7 @@ ticket="ticketB"
l.close()
self.assertEqual(len(lines), 1, "Lock file should contain one line")
pid = re.search('\\bbooth_pid="?(\\d+)"?', lines[0]).group(1)
- print "lockfile contains: <%s>" % pid
+ print("lockfile contains: <%s>" % pid)
return pid
def is_pid_running_daemon(self, pid):
@@ -185,11 +183,11 @@ ticket="ticketB"
c = open("/proc/%s/cmdline" % pid)
cmdline = "".join(c.readlines())
- print cmdline
+ print(cmdline)
c.close()
if cmdline.find('boothd') == -1:
- print 'no boothd in cmdline:', cmdline
+ print('no boothd in cmdline:', cmdline)
return False
# self.assertRegexpMatches(
diff --git a/test/servertests.py b/test/servertests.py
index 71e808e..288d19f 100644
--- a/test/servertests.py
+++ b/test/servertests.py
@@ -35,13 +35,13 @@ class ServerTests(ServerTestEnvironment):
def test_config_file_buffer_overflow(self):
# https://bugzilla.novell.com/show_bug.cgi?id=750256
- longfile = (string.lowercase * 5)[:127]
+ longfile = (string.ascii_lowercase * 5)[:127]
expected_error = "'%s' exceeds maximum config name length" % longfile
self._test_buffer_overflow(expected_error, config_file=longfile)
def test_lock_file_buffer_overflow(self):
# https://bugzilla.novell.com/show_bug.cgi?id=750256
- longfile = (string.lowercase * 5)[:127]
+ longfile = (string.ascii_lowercase * 5)[:127]
expected_error = "'%s' exceeds maximum lock file length" % longfile
self._test_buffer_overflow(expected_error, lock_file=longfile)
@@ -54,12 +54,12 @@ class ServerTests(ServerTestEnvironment):
# quotes no longer required
return True
orig_lines = self.working_config.split("\n")
- for i in xrange(len(orig_lines)):
+ for (i, line) in enumerate(orig_lines):
new_lines = copy.copy(orig_lines)
- new_lines[i] = new_lines[i].replace('"', '')
+ new_lines[i] = line.replace('"', '')
new_config = "\n".join(new_lines)
- line_contains_IP = re.search('^\s*(site|arbitrator)=.*[0-9]\.', orig_lines[i])
+ line_contains_IP = re.search('^\s*(site|arbitrator)=.*[0-9]\.', line)
if line_contains_IP:
# IP addresses need to be surrounded by quotes,
# so stripping them should cause it to fail
diff --git a/test/utils.py b/test/utils.py
index 5b70cfc..aca3592 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -1,5 +1,6 @@
import subprocess
import re
+import sys
def run_cmd(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -9,8 +10,11 @@ def run_cmd(cmd):
def get_IP():
(stdout, stderr, returncode) = run_cmd(['hostname', '-i'])
if returncode != 0:
- raise RuntimeError, "Failed to run hostname -i:\n" + stderr
+ raise RuntimeError("Failed to run hostname -i:\n" + stderr)
# in case multiple IP addresses are returned, use only the first
- # and also strip '%<device>' part possibly present with IPv6 address
- ret = re.sub(r'\s.*', '', stdout)
+ # and also strip '%<device>' part possibly present with IPv6 address;
+ # in Python 3 context, only expect ASCII/UTF-8 encodings for the
+ # obtained input bytes
+ ret = re.sub(r'\s.*', '',
+ stdout if sys.version_info[0] < 3 else str(stdout, 'UTF-8'))
return "::1" if '%' in ret else ret
--
2.18.0.rc2

View File

@ -1,179 +0,0 @@
From cd8c7245e4f50269ec62b36cb56ef21e659c7578 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 24 Feb 2016 02:12:34 +0100
Subject: [PATCH 3/6] Feature: alternative range2random provider: glib
Also check if cl_rand_from_interval is actually defined in
<clplumbing/cl_random.h> (not the case with older glue/plumb lib).
---
booth.spec | 2 ++
configure.ac | 24 ++++++++++++++++++++++++
src/Makefile.am | 8 ++++++++
src/alt/range2random_glib.c | 33 +++++++++++++++++++++++++++++++++
src/alt/range2random_glib.h | 22 ++++++++++++++++++++++
src/ticket.c | 6 +++++-
6 files changed, 94 insertions(+), 1 deletion(-)
create mode 100644 src/alt/range2random_glib.c
create mode 100644 src/alt/range2random_glib.h
diff --git a/booth.spec b/booth.spec
index cc73af2..b88ff4c 100644
--- a/booth.spec
+++ b/booth.spec
@@ -69,6 +69,8 @@ BuildRequires: libglue-devel
%else
# logging provider
BuildRequires: pkgconfig(libqb)
+# random2range provider
+BuildRequires: pkgconfig(glib-2.0)
%endif
BuildRequires: libxml2-devel
BuildRequires: zlib-devel
diff --git a/configure.ac b/configure.ac
index 32a7dd1..10e131d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -245,6 +245,29 @@ libqb)
esac
AM_CONDITIONAL([LOGGING_LIBQB], [test "x$logging_provider" = "xlibqb"])
+# figure out range2random provider
+range2random_provider=""
+if test "x$range2random_provider" = "x" && test "x$with_glue" = "xyes"; then
+ AC_CHECK_LIB([plumb], [get_next_random], [range2random_provider="libplumb"])
+ AC_CHECK_DECL([cl_rand_from_interval], [], [range2random_provider=""],
+ [#include <clplumbing/cl_random.h>])
+fi
+if test "x$range2random_provider" = "x" && test "x$with_glue" = "xno"; then
+ AC_CHECK_LIB([glib-2.0], [g_random_int_range], [range2random_provider="glib"])
+fi
+case "$range2random_provider" in
+libplumb)
+ ;;
+glib)
+ PKG_CHECK_MODULES([GLIB], [glib-2.0])
+ AC_DEFINE([RANGE2RANDOM_GLIB], [], [use glib as a range2random provider])
+ ;;
+*)
+ AC_MSG_ERROR([range2random provider required (libplumb, or glib when --without-glue)])
+ ;;
+esac
+AM_CONDITIONAL([RANGE2RANDOM_GLIB], [test "x$range2random_provider" = "xglib"])
+
# OS detection
# THIS SECTION MUST DIE!
CP=cp
@@ -474,6 +497,7 @@ AC_MSG_RESULT([ booth config dir = ${BOOTHSYSCONFDIR}])
AC_MSG_RESULT([ SOCKETDIR = ${SOCKETDIR}])
AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
AC_MSG_RESULT([ Logging provider = ${logging_provider}])
+AC_MSG_RESULT([ Range2random provider = ${range2random_provider}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Library SONAME = ${SONAME}])
diff --git a/src/Makefile.am b/src/Makefile.am
index 49c3ac4..317710e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,5 +33,13 @@ boothd_SOURCES += alt/logging_libqb.c
noinst_HEADERS += alt/logging_libqb.h
endif
+if !RANGE2RANDOM_GLIB
+boothd_LDADD += -lplumb
+else
+boothd_LDADD += $(GLIB_LIBS)
+boothd_SOURCES += alt/range2random_glib.c
+noinst_HEADERS += alt/range2random_glib.h
+endif
+
lint:
-splint $(INCLUDES) $(LINT_FLAGS) $(CFLAGS) *.c
diff --git a/src/alt/range2random_glib.c b/src/alt/range2random_glib.c
new file mode 100644
index 0000000..8363559
--- /dev/null
+++ b/src/alt/range2random_glib.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Jan Pokorny <jpokorny@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "range2random_glib.h"
+#include "ticket.h"
+
+int
+alt_glib_rand_from_interval(int from, int to)
+{
+ assert(from >= 0 && from < to);
+ assert(sizeof(to) <= sizeof(gint32) || (to < 0x7fffffff));
+ return (int) g_random_int_range(from, to);
+}
diff --git a/src/alt/range2random_glib.h b/src/alt/range2random_glib.h
new file mode 100644
index 0000000..4b87c46
--- /dev/null
+++ b/src/alt/range2random_glib.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2016 Jan Pokorny <jpokorny@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+int alt_glib_rand_from_interval(int from, int to);
+
+#define cl_rand_from_interval(from, to) \
+ alt_glib_rand_from_interval(from, to)
diff --git a/src/ticket.c b/src/ticket.c
index 09743f7..8d4cc12 100644
--- a/src/ticket.c
+++ b/src/ticket.c
@@ -25,8 +25,12 @@
#include <stdio.h>
#include <assert.h>
#include <time.h>
-#include <clplumbing/cl_random.h>
#include "b_config.h"
+#ifndef RANGE2RANDOM_GLIB
+#include <clplumbing/cl_random.h>
+#else
+#include "alt/range2random_glib.h"
+#endif
#include "ticket.h"
#include "config.h"
#include "pacemaker.h"
--
2.4.11

View File

@ -0,0 +1,89 @@
From 31133e8ac07c08b607ee7799c0074c1dce37a952 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 11 Jul 2018 14:18:50 +0200
Subject: [PATCH] build: parametrize Python invocations in the shebangs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Consequently, there's no reason to have the affected files marked as
executable (processing the files by the means of AC_CONFIG_FILES will
get rid of any such permission bits, anyway), but at the very least,
test/runtests.py needs to be set executable afterwards so as no to
cause failures with the current "make check" arrangement that invokes
TESTS subtargets directly (i.e. no extension-based LOG_COMPILER set).
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
configure.ac | 12 +++++++++++-
script/{unit-test.py => unit-test.py.in} | 2 +-
test/{runtests.py => runtests.py.in} | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
rename script/{unit-test.py => unit-test.py.in} (99%)
mode change 100755 => 100644
rename test/{runtests.py => runtests.py.in} (98%)
mode change 100755 => 100644
diff --git a/configure.ac b/configure.ac
index 3bf41b3..a6ad86e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,14 @@ CPPFLAGS="$CPPFLAGS $XML2HEAD"
PKG_CHECK_MODULES(GLIB, [glib-2.0])
+# Python casing, prefer 3.3+ to 2.{6...}
+AM_PATH_PYTHON([3.3], , [PYTHON=:])
+if test "x$PYTHON" = x:; then
+ AM_PATH_PYTHON([2.6])
+fi
+PYTHON_SHEBANG="$PYTHON ${PYTHON_OPTS--Es}"
+AC_ARG_VAR([PYTHON_SHEBANG], [Python invocation used in shebangs])
+
# Checks for header files.
AC_FUNC_ALLOCA
AC_HEADER_DIRENT
@@ -157,7 +165,9 @@ AC_CONFIG_FILES([Makefile
docs/Makefile
conf/Makefile])
AC_CONFIG_FILES([conf/booth-arbitrator.service conf/booth@.service])
-
+AC_CONFIG_FILES([script/unit-test.py test/runtests.py],
+ dnl Following required at least for "make check"
+ [chmod +x test/runtests.py])
AC_CONFIG_FILES([script/service-runnable], [chmod +x script/service-runnable])
# ===============================================
diff --git a/script/unit-test.py b/script/unit-test.py.in
old mode 100755
new mode 100644
similarity index 99%
rename from script/unit-test.py
rename to script/unit-test.py.in
index 399528e..4f3cf62
--- a/script/unit-test.py
+++ b/script/unit-test.py.in
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!@PYTHON_SHEBANG@
# vim: fileencoding=utf-8
# see http://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding
# NOTE: setting the encoding is needed as non-ASCII characters are contained
diff --git a/test/runtests.py b/test/runtests.py.in
old mode 100755
new mode 100644
similarity index 98%
rename from test/runtests.py
rename to test/runtests.py.in
index 833b1a7..ec59159
--- a/test/runtests.py
+++ b/test/runtests.py.in
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!@PYTHON_SHEBANG@
import os
import re
--
2.18.0.rc2

View File

@ -1,239 +0,0 @@
From 6b9e9cd87e41bc07cfbfd5a607a739cfebb2e2ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 24 Feb 2016 02:15:47 +0100
Subject: [PATCH 4/6] Feature: alternative "nametag" provider: libsystemd
---
booth.spec | 2 ++
configure.ac | 22 ++++++++++++
src/Makefile.am | 10 +++++-
src/alt/nametag_libsystemd.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
src/alt/nametag_libsystemd.h | 23 +++++++++++++
src/main.c | 6 +++-
6 files changed, 142 insertions(+), 2 deletions(-)
create mode 100644 src/alt/nametag_libsystemd.c
create mode 100644 src/alt/nametag_libsystemd.h
diff --git a/booth.spec b/booth.spec
index b88ff4c..18387f7 100644
--- a/booth.spec
+++ b/booth.spec
@@ -71,6 +71,8 @@ BuildRequires: libglue-devel
BuildRequires: pkgconfig(libqb)
# random2range provider
BuildRequires: pkgconfig(glib-2.0)
+# nametag provider
+BuildRequires: pkgconfig(libsystemd)
%endif
BuildRequires: libxml2-devel
BuildRequires: zlib-devel
diff --git a/configure.ac b/configure.ac
index 10e131d..bb2e3a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -268,6 +268,27 @@ glib)
esac
AM_CONDITIONAL([RANGE2RANDOM_GLIB], [test "x$range2random_provider" = "xglib"])
+# figure out nametag/distinguished-role provider
+nametag_provider=""
+if test "x$nametag_provider" = "x" && test "x$with_glue" != "xno"; then
+ AC_CHECK_LIB([plumbgpl], [set_proc_title], [nametag_provider="libplumbgpl"])
+fi
+if test "x$nametag_provider" = "x" && test "x$with_glue" = "xno"; then
+ AC_CHECK_LIB([systemd], [sd_notify], [nametag_provider="libsystemd"])
+fi
+case "$nametag_provider" in
+libplumbgpl)
+ ;;
+libsystemd)
+ PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd])
+ AC_DEFINE([NAMETAG_LIBSYSTEMD], [], [use libsystemd as a nametag provider])
+ ;;
+*)
+ AC_MSG_ERROR([nametag provider required (libplumbgpl, or libsystemd when --without-glue)])
+ ;;
+esac
+AM_CONDITIONAL([NAMETAG_LIBSYSTEMD], [test "x$nametag_provider" = "xlibsystemd"])
+
# OS detection
# THIS SECTION MUST DIE!
CP=cp
@@ -498,6 +519,7 @@ AC_MSG_RESULT([ SOCKETDIR = ${SOCKETDIR}])
AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
AC_MSG_RESULT([ Logging provider = ${logging_provider}])
AC_MSG_RESULT([ Range2random provider = ${range2random_provider}])
+AC_MSG_RESULT([ Nametag provider = ${nametag_provider}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Library SONAME = ${SONAME}])
diff --git a/src/Makefile.am b/src/Makefile.am
index 317710e..69b7b48 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,7 @@ boothd_SOURCES += auth.c
endif
boothd_LDFLAGS = $(OS_DYFLAGS) -L./
-boothd_LDADD = -lplumb -lplumbgpl -lm $(GLIB_LIBS) $(ZLIB_LIBS)
+boothd_LDADD = -lplumb -lm $(GLIB_LIBS) $(ZLIB_LIBS)
boothd_CFLAGS = $(GLIB_CFLAGS)
if !LOGGING_LIBQB
@@ -41,5 +41,13 @@ boothd_SOURCES += alt/range2random_glib.c
noinst_HEADERS += alt/range2random_glib.h
endif
+if !NAMETAG_LIBSYSTEMD
+boothd_LDADD += -lplumbgpl
+else
+boothd_LDADD += $(LIBSYSTEMD_LIBS)
+boothd_SOURCES += alt/nametag_libsystemd.c
+noinst_HEADERS += alt/nametag_libsystemd.h
+endif
+
lint:
-splint $(INCLUDES) $(LINT_FLAGS) $(CFLAGS) *.c
diff --git a/src/alt/nametag_libsystemd.c b/src/alt/nametag_libsystemd.c
new file mode 100644
index 0000000..1fb9ffa
--- /dev/null
+++ b/src/alt/nametag_libsystemd.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016 Jan Pokorny <jpokorny@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include <systemd/sd-daemon.h>
+
+#include "nametag_libsystemd.h"
+#include "booth.h"
+#include "log.h"
+#include "transport.h"
+
+/* assume first argument after "fmt" is for DAEMON_NAME, that is
+ really not of interest in our "nametag" function based on
+ sd_notify (that very data point is provided implicitly) */
+void sd_notify_wrapper(const char *fmt, ...)
+{
+ /* assume that first %s in fmt is intended for DAEMON_NAME,
+ i.e., for first argument following fmt in original
+ set_proc_title invocation, which has already been dropped
+ before it boils down here (using the wrapping macro trick);
+ we now simply append the reset after that first %s
+ (with whitespace stripped) to the "Running: " prefix */
+ int rv;
+ char buffer[255];
+ char *fmt_iter;
+ char *suffix = NULL;
+ va_list ap;
+
+ switch (local->type) {
+ case ARBITRATOR:
+ case GEOSTORE:
+ break;
+ default:
+ return; /* not expected to be run as system service */
+ }
+
+ fmt_iter = strchr(fmt, '%');
+ while (fmt_iter) {
+ switch (*++fmt_iter) {
+ case 's': suffix = fmt_iter;
+ /* fall through */
+ default: fmt_iter = NULL;
+ }
+ }
+ if (!suffix) {
+ log_warn("%s:%d: invalid format: %s", __FILE__, __LINE__, fmt);
+ return;
+ }
+ while (isspace(*++suffix)) /* noop */ ;
+
+ va_start(ap, fmt);
+ fmt_iter = va_arg(ap, char *); /* just shift by one */
+ assert(!strcmp(fmt_iter, DAEMON_NAME));
+ rv = vsnprintf(buffer, sizeof(buffer), suffix, ap);
+ va_end(ap);
+
+ rv = sd_notifyf(0, "READY=1\n"
+ "STATUS=Running: %s",
+ buffer);
+ if (rv < 0)
+ log_warn("%s:%d: sd_notifyf fail", __FILE__, __LINE__);
+}
diff --git a/src/alt/nametag_libsystemd.h b/src/alt/nametag_libsystemd.h
new file mode 100644
index 0000000..2c1dc1e
--- /dev/null
+++ b/src/alt/nametag_libsystemd.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2016 Jan Pokorny <jpokorny@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+void
+sd_notify_wrapper(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+
+#define init_set_proc_title(c, a, e) /* omitted */
+#define set_proc_title sd_notify_wrapper
diff --git a/src/main.c b/src/main.c
index 498718b..27d285c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,7 +34,6 @@
#include <sys/poll.h>
#include <sys/wait.h>
#include <pacemaker/crm/services.h>
-#include <clplumbing/setproctitle.h>
#include <sys/prctl.h>
#include <clplumbing/coredumps.h>
#include <fcntl.h>
@@ -49,6 +48,11 @@
#include <arpa/inet.h>
#include <sys/types.h>
#include "b_config.h"
+#ifndef NAMETAG_LIBSYSTEMD
+#include <clplumbing/setproctitle.h>
+#else
+#include "alt/nametag_libsystemd.h"
+#endif
#include "log.h"
#include "booth.h"
#include "config.h"
--
2.4.11

View File

@ -0,0 +1,36 @@
From 541e6184fca60a01ff7e8c1bba794c083ac4245f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 10 Jul 2018 19:25:34 +0200
Subject: [PATCH] test: drop underqualified identifier in unittest's 2.6 compat
"polyfill"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Specifically, in supplemented unittest.TestCase.assertRegexpMatches
method. In Python 2.7's implementation, there's no re.MULTILINE
modifier at that very place, either.
Not sure what the original purpose of introducing that with c1c47f5 was.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
test/assertions.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/assertions.py b/test/assertions.py
index 34333ca..fafb291 100644
--- a/test/assertions.py
+++ b/test/assertions.py
@@ -23,7 +23,7 @@ class BoothAssertions:
"""Fail the test unless the text matches the regular expression."""
if isinstance(expected_regexp, str):
expected_regexp = re.compile(expected_regexp)
- if not expected_regexp.search(text, MULTILINE):
+ if not expected_regexp.search(text):
msg = msg or "Regexp didn't match"
msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern, text)
raise self.failureException(msg)
--
2.18.0.rc2

View File

@ -1,115 +0,0 @@
From b0eee73d593b0d8c884b01d5691857506f24daba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 26 Apr 2016 16:50:50 +0200
Subject: [PATCH 5/6] Feature: allow skipping "coredump nursing" phase
This effectively eliminates the last dependency on glue libraries.
---
configure.ac | 11 +++++++++++
src/Makefile.am | 6 +++++-
src/main.c | 12 +++++++++---
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index bb2e3a8..cb4eeb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -289,6 +289,16 @@ libsystemd)
esac
AM_CONDITIONAL([NAMETAG_LIBSYSTEMD], [test "x$nametag_provider" = "xlibsystemd"])
+# figure out if "coredump nursing" supported and desired
+coredump_nursing="no"
+if test "x$with_glue" != "xno"; then
+ AC_CHECK_LIB([plumb], [cl_enable_coredumps], [coredump_nursing="libplumb"])
+fi
+if test "x$coredump_nursing" != "xno"; then
+ AC_DEFINE(COREDUMP_NURSING, [], [eligible for coredump nursing])
+fi
+AM_CONDITIONAL([COREDUMP_NURSING], [test "x$coredump_nursing" != "xno"])
+
# OS detection
# THIS SECTION MUST DIE!
CP=cp
@@ -520,6 +530,7 @@ AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
AC_MSG_RESULT([ Logging provider = ${logging_provider}])
AC_MSG_RESULT([ Range2random provider = ${range2random_provider}])
AC_MSG_RESULT([ Nametag provider = ${nametag_provider}])
+AC_MSG_RESULT([ Coredump nursing = ${coredump_nursing}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Library SONAME = ${SONAME}])
diff --git a/src/Makefile.am b/src/Makefile.am
index 69b7b48..2a985ae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,7 @@ boothd_SOURCES += auth.c
endif
boothd_LDFLAGS = $(OS_DYFLAGS) -L./
-boothd_LDADD = -lplumb -lm $(GLIB_LIBS) $(ZLIB_LIBS)
+boothd_LDADD = -lm $(GLIB_LIBS) $(ZLIB_LIBS)
boothd_CFLAGS = $(GLIB_CFLAGS)
if !LOGGING_LIBQB
@@ -49,5 +49,9 @@ boothd_SOURCES += alt/nametag_libsystemd.c
noinst_HEADERS += alt/nametag_libsystemd.h
endif
+if COREDUMP_NURSING
+boothd_LDADD += -lplumb
+endif
+
lint:
-splint $(INCLUDES) $(LINT_FLAGS) $(CFLAGS) *.c
diff --git a/src/main.c b/src/main.c
index 27d285c..0693f18 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,9 +33,6 @@
#include <sys/un.h>
#include <sys/poll.h>
#include <sys/wait.h>
-#include <pacemaker/crm/services.h>
-#include <sys/prctl.h>
-#include <clplumbing/coredumps.h>
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
@@ -47,12 +44,19 @@
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/types.h>
+
+#include <pacemaker/crm/services.h>
+
#include "b_config.h"
#ifndef NAMETAG_LIBSYSTEMD
#include <clplumbing/setproctitle.h>
#else
#include "alt/nametag_libsystemd.h"
#endif
+#ifdef COREDUMP_NURSING
+#include <sys/prctl.h>
+#include <clplumbing/coredumps.h>
+#endif
#include "log.h"
#include "booth.h"
#include "config.h"
@@ -1457,11 +1461,13 @@ static int do_server(int type)
if (rv)
return rv;
+#ifdef COREDUMP_NURSING
if (cl_enable_coredumps(TRUE) < 0){
log_error("enabling core dump failed");
}
cl_cdtocoredir();
prctl(PR_SET_DUMPABLE, (unsigned long)TRUE, 0UL, 0UL, 0UL);
+#endif
signal(SIGCHLD, (__sighandler_t)wait_child);
rv = loop(lock_fd);
--
2.4.11

View File

@ -0,0 +1,90 @@
From 6a6834a8110d9e6aff50cd6d6935976af4cbdb8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Thu, 12 Jul 2018 20:18:07 +0200
Subject: [PATCH] test: drop/comment out superfluous imports
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
test/boothrunner.py | 2 --
test/boothtestenv.py | 1 -
test/runtests.py.in | 3 +--
test/serverenv.py | 2 --
test/servertests.py | 1 -
5 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/test/boothrunner.py b/test/boothrunner.py
index 347912b..31c2213 100644
--- a/test/boothrunner.py
+++ b/test/boothrunner.py
@@ -1,8 +1,6 @@
-import os
import sys
import subprocess
import time
-import unittest
class BoothRunner:
default_config_file = '/etc/booth/booth.conf'
diff --git a/test/boothtestenv.py b/test/boothtestenv.py
index 59e25c3..ba54360 100644
--- a/test/boothtestenv.py
+++ b/test/boothtestenv.py
@@ -5,7 +5,6 @@ import tempfile
import unittest
from assertions import BoothAssertions
-from boothrunner import BoothRunner
class BoothTestEnvironment(unittest.TestCase, BoothAssertions):
test_src_path = os.path.abspath(os.path.dirname(__file__))
diff --git a/test/runtests.py.in b/test/runtests.py.in
index ec59159..73d70a3 100644
--- a/test/runtests.py.in
+++ b/test/runtests.py.in
@@ -1,7 +1,6 @@
#!@PYTHON_SHEBANG@
import os
-import re
import shutil
import sys
import tempfile
@@ -10,7 +9,7 @@ import unittest
from clienttests import ClientConfigTests
from sitetests import SiteConfigTests
-from arbtests import ArbitratorConfigTests
+#from arbtests import ArbitratorConfigTests
if __name__ == '__main__':
if os.geteuid() == 0:
diff --git a/test/serverenv.py b/test/serverenv.py
index 5d6c6c4..7b8915d 100644
--- a/test/serverenv.py
+++ b/test/serverenv.py
@@ -1,9 +1,7 @@
import os
import re
import time
-import unittest
-from assertions import BoothAssertions
from boothrunner import BoothRunner
from boothtestenv import BoothTestEnvironment
from utils import get_IP
diff --git a/test/servertests.py b/test/servertests.py
index 288d19f..f72dbed 100644
--- a/test/servertests.py
+++ b/test/servertests.py
@@ -1,5 +1,4 @@
import copy
-from pprint import pprint, pformat
import re
import string
--
2.18.0.rc2

View File

@ -1,202 +0,0 @@
From 2531e70e3014ae80d1799478b1cd95aa2076a484 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 2 Mar 2016 19:38:46 +0100
Subject: [PATCH 6/6] Feature: alternative logger (in service-runnable script)
This effectively eliminates the last dependency on glue project as such.
---
Makefile.am | 2 +-
configure.ac | 5 ++++
script/service-runnable | 62 ----------------------------------------------
script/service-runnable.in | 61 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+), 63 deletions(-)
delete mode 100755 script/service-runnable
create mode 100755 script/service-runnable.in
diff --git a/Makefile.am b/Makefile.am
index 5f360c4..076d461 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,7 @@ bootharbitrator_SCRIPTS = script/lsb/booth-arbitrator
boothnoarchdir = $(datadir)/$(PACKAGE_NAME)
-boothnoarch_SCRIPTS = script/service-runnable
+nodist_boothnoarch_SCRIPTS = script/service-runnable
sbin_SCRIPTS = script/booth-keygen
diff --git a/configure.ac b/configure.ac
index cb4eeb1..f67c972 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,6 +147,8 @@ AC_CONFIG_FILES([Makefile
src/Makefile
docs/Makefile])
+AC_CONFIG_FILES([script/service-runnable], [chmod +x script/service-runnable])
+
# ===============================================
# Helpers
# ===============================================
@@ -230,6 +232,7 @@ if test "x$logging_provider" = "x" && test "x$with_glue" = "xno"; then
fi
case "$logging_provider" in
libplumb)
+ LOGGER="ha_logger"
;;
libqb)
PKG_CHECK_MODULES([LIBQB], [libqb])
@@ -238,12 +241,14 @@ libqb)
[AC_DEFINE([LOGGING_LIBQB_MAJOR], [1],
[libqb major version lower bound])],
[AC_MSG_WARN([[syslog identifier will not get changed]])])
+ LOGGER="logger -t booth-script"
;;
*)
AC_MSG_ERROR([logging provider required (libplumb, or libqb when --without-glue)])
;;
esac
AM_CONDITIONAL([LOGGING_LIBQB], [test "x$logging_provider" = "xlibqb"])
+AC_SUBST([LOGGER])
# figure out range2random provider
range2random_provider=""
diff --git a/script/service-runnable b/script/service-runnable
deleted file mode 100755
index ed90c5e..0000000
--- a/script/service-runnable
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# This script is part of Booth.
-# It checks whether the given resource (service) still has a chance
-# to run on the local cluster, so that booth knows whether to
-# acquire the ticket here.
-
-service="${1:?Need a resource name as first argument.}"
-if [ -z "$service" ]; then
- ha_logger "$0: bad usage: no resource name"
- exit 1
-fi
-tmpshadow=`mktemp booth-check.XXXXXX`
-if [ $? -ne 0 -o ! -f "$tmpshadow" ]; then
- ha_logger "$0: mktemp failed"
- exit 1
-fi
-
-trap "rm -f $tmpshadow" EXIT
-
-
-# We expect an output like
-# p_dummy (ocf::pacemaker:Dummy): Started geo-rz2-a
-
-status=`crm_simulate -O $tmpshadow --ticket-grant "$BOOTH_TICKET" --simulate --live-check 2>&1`
-if [ $? -ne 0 ]; then
- ha_logger "$0: crm_simulate failed"
- ha_logger "$0: crm_simulate: $status"
- exit 1
-fi
-
-if echo "$status" |
- sed -n '/^Revised cluster status:/,$p' |
- egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
-then
- # can be started - we're done.
- exit 0
-fi
-
-# If target-role is Stopped, it judges with being stopped explicitly.
-output=$(crm_resource --meta --get-parameter="target-role" --resource=$service 2>/dev/null)
-rc=$?
-if [ $rc -eq 0 -a "$output" = "Stopped" ]; then
- exit 0
-fi
-
-# is ticket in standby?
-output=$(crm_ticket --ticket "$BOOTH_TICKET" --get-attr standby)
-rc=$?
-if [ $rc -eq 0 -a "$output" = true ]; then
- exit 0
-fi
-
-# Some error occured.
-# Try to help the admin with a bit of diagnostic.
-#
-# disallow ms-resources, ie. only primitives wanted here
-if ! crm_resource -l | grep -v ":" | grep "$service" ; then
- ha_logger "Defined resource '$service' in $BOOTH_CONF_PATH is not a primitive??"
-fi
-
-exit 1
-
diff --git a/script/service-runnable.in b/script/service-runnable.in
new file mode 100755
index 0000000..9ea33d4
--- /dev/null
+++ b/script/service-runnable.in
@@ -0,0 +1,61 @@
+#!/bin/bash
+# This script is part of Booth.
+# It checks whether the given resource (service) still has a chance
+# to run on the local cluster, so that booth knows whether to
+# acquire the ticket here.
+
+service="${1:?Need a resource name as first argument.}"
+if [ -z "$service" ]; then
+ @LOGGER@ "$0: bad usage: no resource name"
+ exit 1
+fi
+tmpshadow=`mktemp booth-check.XXXXXX`
+if [ $? -ne 0 -o ! -f "$tmpshadow" ]; then
+ @LOGGER@ "$0: mktemp failed"
+ exit 1
+fi
+
+trap "rm -f $tmpshadow" EXIT
+
+
+# We expect an output like
+# p_dummy (ocf::pacemaker:Dummy): Started geo-rz2-a
+
+status=`crm_simulate -O $tmpshadow --ticket-grant "$BOOTH_TICKET" --simulate --live-check 2>&1`
+if [ $? -ne 0 ]; then
+ @LOGGER@ "$0: crm_simulate failed"
+ @LOGGER@ "$0: crm_simulate: $status"
+ exit 1
+fi
+
+if echo "$status" |
+ sed -n '/^Revised cluster status:/,$p' |
+ egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
+then
+ # can be started - we're done.
+ exit 0
+fi
+
+# If target-role is Stopped, it judges with being stopped explicitly.
+output=$(crm_resource --meta --get-parameter="target-role" --resource=$service 2>/dev/null)
+rc=$?
+if [ $rc -eq 0 -a "$output" = "Stopped" ]; then
+ exit 0
+fi
+
+# is ticket in standby?
+output=$(crm_ticket --ticket "$BOOTH_TICKET" --get-attr standby)
+rc=$?
+if [ $rc -eq 0 -a "$output" = true ]; then
+ exit 0
+fi
+
+# Some error occured.
+# Try to help the admin with a bit of diagnostic.
+#
+# disallow ms-resources, ie. only primitives wanted here
+if ! crm_resource -l | grep -v ":" | grep "$service" ; then
+ @LOGGER@ "Defined resource '$service' in $BOOTH_CONF_PATH is not a primitive??"
+fi
+
+exit 1
--
2.4.11

View File

@ -0,0 +1,178 @@
From 34cc2fcda6804d42ee66fa5a417fc42b64fe3806 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 10 Jul 2018 19:45:56 +0200
Subject: [PATCH] test: avoid dangerous mutable/sticky default value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Incl. slight refactoring towards more frequent use of tuples where
advantage of lists are dubious.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
script/unit-test.py.in | 34 ++++++++++++++++------------------
test/assertions.py | 2 +-
test/boothrunner.py | 14 +++++++-------
test/clientenv.py | 4 ++--
test/serverenv.py | 4 ++--
5 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/script/unit-test.py.in b/script/unit-test.py.in
index 4f3cf62..fc98bc1 100644
--- a/script/unit-test.py.in
+++ b/script/unit-test.py.in
@@ -199,7 +199,7 @@ class UT():
self.booth.close( force=self.booth.isalive() )
- def start_a_process(self, bin, env_add=[], **args):
+ def start_a_process(self, bin, env_add=(), **args):
name = re.sub(r".*/", "", bin)
# How to get stderr, too?
expct = pexpect.spawn(bin,
@@ -220,16 +220,15 @@ class UT():
def start_processes(self, test):
self.booth = self.start_a_process(self.binary,
- args = [ "daemon", "-D",
- "-c", self.test_base + "/booth.conf",
- "-s", "127.0.0.1",
- "-l", self.lockfile,
- ],
- env_add=[ ('UNIT_TEST', test),
+ args = ["daemon", "-D",
+ "-c", self.test_base + "/booth.conf",
+ "-s", "127.0.0.1",
+ "-l", self.lockfile],
+ env_add=( ('UNIT_TEST', test),
('UNIT_TEST_FILE', os.path.realpath(test)),
# provide some space, so that strcpy(getenv()) works
('UNIT_TEST_AUX', "".zfill(1024)),
- ]);
+ ));
logging.info("started booth with PID %d, lockfile %s" % (self.booth.pid, self.lockfile))
self.booth.expect("BOOTH site \S+ \(build \S+\) daemon is starting", timeout=2)
@@ -237,16 +236,15 @@ class UT():
self.gdb = self.start_a_process("gdb",
args=["-quiet",
- "-p", str(self.booth.pid),
- # Don't use .gdbinit
- "-nx", "-nh",
- # Run until the defined point.
- # This is necessary so that ticket state setting doesn't
- # happen _before_ the call to pcmk_load_ticket()
- # (which would overwrite our data)
- "-ex", "break ticket_cron",
- "-ex", "continue",
- ])
+ "-p", str(self.booth.pid),
+ # Don't use .gdbinit
+ "-nx", "-nh",
+ # Run until the defined point.
+ # This is necessary so that ticket state setting doesn't
+ # happen _before_ the call to pcmk_load_ticket()
+ # (which would overwrite our data)
+ "-ex", "break ticket_cron",
+ "-ex", "continue"])
logging.info("started GDB with PID %d" % self.gdb.pid)
self.gdb.expect("(gdb)")
self.gdb.sendline("set pagination off\n")
diff --git a/test/assertions.py b/test/assertions.py
index fafb291..db6fcd8 100644
--- a/test/assertions.py
+++ b/test/assertions.py
@@ -10,7 +10,7 @@ class BoothAssertions:
self.assertRegexpMatches(stderr, expected_error)
def assertLockFileError(self, config_file=None, config_text=None,
- lock_file=True, args=[]):
+ lock_file=True, args=()):
(pid, ret, stdout, stderr, runner) = \
self.run_booth(config_text=config_text, config_file=config_file,
lock_file=lock_file, args=args, expected_exitcode=1)
diff --git a/test/boothrunner.py b/test/boothrunner.py
index 31c2213..0285fe6 100644
--- a/test/boothrunner.py
+++ b/test/boothrunner.py
@@ -8,14 +8,14 @@ class BoothRunner:
def __init__(self, boothd_path, mode, args):
self.boothd_path = boothd_path
- self.args = [ mode ]
- self.final_args = args # will be appended to self.args
+ self.args = (mode, )
+ self.final_args = tuple(args) # will be appended to self.args
self.mode = mode
self.config_file = None
self.lock_file = None
def set_config_file_arg(self):
- self.args += [ '-c', self.config_file ]
+ self.args += ('-c', self.config_file)
def set_config_file(self, config_file):
self.config_file = config_file
@@ -23,16 +23,16 @@ class BoothRunner:
def set_lock_file(self, lock_file):
self.lock_file = lock_file
- self.args += [ '-l', self.lock_file ]
+ self.args += ('-l', self.lock_file)
def set_debug(self):
- self.args += [ '-D' ]
+ self.args += ('-D', )
def set_foreground(self):
- self.args += [ '-S' ]
+ self.args += ('-S', )
def all_args(self):
- return [ self.boothd_path ] + self.args + self.final_args
+ return (self.boothd_path, ) + self.args + self.final_args
def show_output(self, stdout, stderr):
if stdout:
diff --git a/test/clientenv.py b/test/clientenv.py
index 73b2791..141e33c 100644
--- a/test/clientenv.py
+++ b/test/clientenv.py
@@ -4,8 +4,8 @@ from boothrunner import BoothRunner
class ClientTestEnvironment(BoothTestEnvironment):
mode = 'client'
- def run_booth(self, config_text=None, config_file=None, lock_file=True, args=[],
- expected_exitcode=0, debug=False):
+ def run_booth(self, config_text=None, config_file=None, lock_file=True,
+ args=(), expected_exitcode=0, debug=False):
'''
Runs boothd.
diff --git a/test/serverenv.py b/test/serverenv.py
index 7b8915d..62c37d0 100644
--- a/test/serverenv.py
+++ b/test/serverenv.py
@@ -29,7 +29,7 @@ ticket="ticketB"
def run_booth(self, expected_exitcode, expected_daemon,
config_text=None, config_file=None, lock_file=True,
- args=[], debug=False, foreground=False):
+ args=(), debug=False, foreground=False):
'''
Runs boothd. Defaults to using a temporary lock file and the
standard config file path. There are four possible types of
@@ -52,7 +52,7 @@ ticket="ticketB"
True: pass a temporary lockfile parameter to booth via -l
string: pass the given lockfile path to booth via -l
args
- array of extra args to pass to booth
+ iterable of extra args to pass to booth
expected_exitcode
an integer, or False if booth is not expected to terminate
within the timeout
--
2.18.0.rc2

View File

@ -0,0 +1,41 @@
From 0a7b51d1eb6f948724c08e94148e8ff1f448d100 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Fri, 13 Jul 2018 14:10:28 +0200
Subject: [PATCH] test: unit-test.py: daemon will not stay in foreground with
-D anymore
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit a66ac33 missed this impact (it may have missed impact on
test/boothrunner.py but it appears to be fine either way).
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
script/unit-test.py.in | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/script/unit-test.py.in b/script/unit-test.py.in
index fc98bc1..74a014b 100644
--- a/script/unit-test.py.in
+++ b/script/unit-test.py.in
@@ -2,7 +2,6 @@
# vim: fileencoding=utf-8
# see http://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding
# NOTE: setting the encoding is needed as non-ASCII characters are contained
-# FIXME: apparently, pexpect.EOF is not being excepted properly
import os, sys, time, signal, tempfile, socket, posix, time
import re, shutil, pexpect, logging, pprint
@@ -220,7 +219,7 @@ class UT():
def start_processes(self, test):
self.booth = self.start_a_process(self.binary,
- args = ["daemon", "-D",
+ args = ["daemon", "-DS",
"-c", self.test_base + "/booth.conf",
"-s", "127.0.0.1",
"-l", self.lockfile],
--
2.18.0.rc2

View File

@ -0,0 +1,50 @@
From d3bf9f5ced41ad0f4e8ae87e80c7e44df4157b61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Fri, 13 Jul 2018 14:40:07 +0200
Subject: [PATCH] Refactor: fix "strncpy may miss trailing null byte" warnings
of GCC 8.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Verbatim warning:
> strncpy specified bound 64 equals destination size [-Wstringop-truncation]
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
src/config.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/config.c b/src/config.c
index 9df5767..e4d36ab 100644
--- a/src/config.c
+++ b/src/config.c
@@ -75,7 +75,10 @@ static void hostname_to_ip(char * hostname)
/* Return the first found address */
if (addr_list[0] != NULL) {
- strncpy(hostname, inet_ntoa(*addr_list[0]), BOOTH_NAME_LEN);
+ strncpy(hostname, inet_ntoa(*addr_list[0]), BOOTH_NAME_LEN - 1);
+ /* buffer overflow will not happen (IPv6 notation < 63 chars),
+ but suppress the warnings */
+ hostname[BOOTH_NAME_LEN - 1] = '\0';
}
else {
log_error("no IP addresses found for the host \"%s\"", hostname);
@@ -106,7 +109,12 @@ static int add_site(char *addr_string, int type)
site->family = AF_INET;
site->type = type;
- strncpy(site->addr_string, addr_string, sizeof(site->addr_string));
+ /* buffer overflow will not hapen (we've already checked that
+ addr_string will fit incl. terminating '\0' above), but
+ suppress the warnings with copying everything but the boundary
+ byte, which is valid as-is, since this last byte will be safely
+ pre-zeroed from the struct booth_config initialization */
+ strncpy(site->addr_string, addr_string, sizeof(site->addr_string) - 1);
if (!(inet_pton(AF_INET, site->addr_string, &site->sa4.sin_addr) > 0) &&
!(inet_pton(AF_INET6, site->addr_string, &site->sa6.sin6_addr) > 0)) {
--
2.18.0.rc2

View File

@ -22,11 +22,14 @@
%bcond_with html_man
%bcond_with glue
%global specver 2
# Disable automatic compilation of Python files in extra directories
%global _python_bytecompile_extra 0
%global specver 3
%global boothver 1.0
# set following to the actual commit or, for final release, concatenate
# "boothver" macro to "v" (will yield a tag per the convention)
%global commit 570876d74c47a93bcdededd1c192a13610eb1d18
%global commit f2d38ce3d61502bda2a28e79db103737a691faf4
%global lparen (
%global rparen )
%global shortcommit %(c=%{commit}; case ${c} in
@ -54,18 +57,21 @@
Name: booth
Version: %{boothver}
Release: %{boothrel}%{dist}.6
Release: %{boothrel}%{dist}
Summary: Ticket Manager for Multi-site Clusters
Group: System Environment/Daemons
License: GPLv2+
Url: https://github.com/%{github_owner}/%{name}
Source0: https://github.com/%{github_owner}/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Patch0: 0001-Feature-offer-alternatives-to-libraries-from-cluster.patch
Patch1: 0002-Feature-alternative-logging-provider-libqb.patch
Patch2: 0003-Feature-alternative-range2random-provider-glib.patch
Patch3: 0004-Feature-alternative-nametag-provider-libsystemd.patch
Patch4: 0005-Feature-allow-skipping-coredump-nursing-phase.patch
Patch5: 0006-Feature-alternative-logger-in-service-runnable-scrip.patch
Patch0: 0000-test-remove-superfluous-shebangs-for-import-only-mod.patch
Patch1: 0001-test-do-not-mix-tabs-with-spaces-in-Python-code.patch
Patch2: 0002-test-make-Python-files-supported-_also_-with-Python-.patch
Patch3: 0003-build-parametrize-Python-invocations-in-the-shebangs.patch
Patch4: 0004-test-drop-underqualified-identifier-in-unittest-s-2..patch
Patch5: 0005-test-drop-comment-out-superfluous-imports.patch
Patch6: 0006-test-avoid-dangerous-mutable-sticky-default-value.patch
Patch7: 0007-test-unit-test.py-daemon-will-not-stay-in-foreground.patch
Patch8: 0008-Refactor-fix-strncpy-may-miss-trailing-null-byte-war.patch
# direct build process dependencies
BuildRequires: autoconf
@ -75,7 +81,7 @@ BuildRequires: make
## ./autogen.sh
BuildRequires: /bin/sh
# general build dependencies
BuildRequires: asciidoc
BuildRequires: asciidoctor
BuildRequires: gcc
BuildRequires: pkgconfig
# linking dependencies
@ -93,7 +99,7 @@ BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libsystemd)
# check scriptlet (for hostname and killall respectively)
BuildRequires: hostname psmisc
BuildRequires: python2-devel
BuildRequires: python3-devel
# spec file specifics
## for _unitdir, systemd_requires and specific scriptlet macros
BuildRequires: systemd
@ -172,13 +178,15 @@ Group: System Environment/Daemons
BuildArch: noarch
# runtests.py suite (for hostname and killall respectively)
Requires: hostname psmisc
Requires: python(abi) < 3
# any of the following internal dependencies will pull -core package
## for booth@booth.service
Requires: %{name}-arbitrator = %{version}-%{release}
## for booth-site and service-runnable scripts
## (and /usr/lib/ocf/resource.d/booth)
Requires: %{name}-site = %{version}-%{release}
Requires: gdb
Requires: python3
Requires: python3-pexpect
%description test
Automated tests for running Booth, ticket manager for multi-site clusters.
@ -186,7 +194,7 @@ Automated tests for running Booth, ticket manager for multi-site clusters.
# BUILD #
%prep
%autosetup -n %{name}-%{commit} -S git
%autosetup -n %{name}-%{commit} -S git_am
%build
./autogen.sh
@ -222,6 +230,9 @@ mkdir -p %{buildroot}/%{test_path}/src
ln -s -t %{buildroot}/%{test_path}/src \
-- %{_sbindir}/boothd
# https://fedoraproject.org/wiki/Packaging:Python_Appendix#Manual_byte_compilation
%py_byte_compile %{__python3} %{buildroot}/%{test_path}
%check
# alternatively: test/runtests.py
VERBOSE=1 make check
@ -267,6 +278,14 @@ VERBOSE=1 make check
/usr/lib/ocf/resource.d/booth/sharedrsc
%changelog
* Fri Jul 13 2018 Jan Pokorný <jpokorny+rpm-booth@fedoraproject.org> - 1.0-3.f2d38ce.git
- update for another, current snapshot beyond booth-1.0
(commit f2d38ce), including:
. support for solely manually managed tickets (9a365f9)
. use asciidoctor instead of asciidoc for generating man pages (65e6a6b)
- switch to using Python 3 for the tests instead of Python 2
(behind unversioned "python" references; rhbz#1555651)
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-2.570876d.git.6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

View File

@ -1 +1 @@
ac33d4fff4d578a2eedf4624b89f2fbd booth-570876d.tar.gz
SHA512 (booth-f2d38ce.tar.gz) = fb172b06640959e3f33953516fa7609a09a1b16467f1dee20cbd831e07597548f74fa1d6d162cbe2cdcbb8e4b15144beeae71a4d7528f259a995f4170bbc6be6