Skip to content

Commit

Permalink
Merge pull request openSUSE#920 from aschnell/master
Browse files Browse the repository at this point in the history
usual tiny improvements and cleanup
  • Loading branch information
aschnell authored Jul 8, 2024
2 parents 20aef71 + 480b496 commit 150006f
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.0
0.11.1
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ AC_CONFIG_FILES([
examples/c/Makefile
examples/c++-lib/Makefile
dbus/Makefile
dbus/testsuite/Makefile
server/Makefile
client/Makefile
client/utils/Makefile
Expand Down
2 changes: 2 additions & 0 deletions dbus/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Makefile.am for snapper/dbus
#

SUBDIRS = . testsuite

AM_CPPFLAGS = -I$(top_srcdir) $(DBUS_CFLAGS)

noinst_LTLIBRARIES = libdbus.la
Expand Down
5 changes: 5 additions & 0 deletions dbus/testsuite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.log
*.o
*.test
*.trs
test-suite.log
14 changes: 14 additions & 0 deletions dbus/testsuite/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Makefile.am for snapper/dbus/testsuite
#

AM_CPPFLAGS = -I$(top_srcdir) $(DBUS_CFLAGS)

LDADD = ../../snapper/libsnapper.la ../libdbus.la -lboost_unit_test_framework

check_PROGRAMS = escape.test

TESTS = $(check_PROGRAMS)

AM_DEFAULT_SOURCE_EXT = .cc

File renamed without changes.
6 changes: 6 additions & 0 deletions dists/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
snapper (0.11.1) stable; urgency=low

* Updated to version 0.11.1

-- Arvin Schnell <aschnell@suse.com> Fri, 5 Jul 2024 14:33:53 +0000

snapper (0.11.0) stable; urgency=low

* Updated to version 0.11.0
Expand Down
1 change: 1 addition & 0 deletions package/snapper.changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Fri Jul 05 16:03:42 CEST 2024 - aschnell@suse.com

- handle content-length of stomp in zypper plugin
(gh#openSUSE/snapper#918)
- version 0.11.1

-------------------------------------------------------------------
Wed May 22 17:21:18 CEST 2024 - aschnell@suse.com
Expand Down
14 changes: 13 additions & 1 deletion stomp/Stomp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/


#include <iostream>
#include <regex>


Expand Down Expand Up @@ -48,6 +47,7 @@ namespace Stomp
{
string line;
getline(is, line);
line = strip_cr(line);

if (state == State::Start)
{
Expand Down Expand Up @@ -150,6 +150,18 @@ namespace Stomp
}


std::string
strip_cr(const std::string& in)
{
string::size_type length = in.size();

if (length > 0 && in[length - 1] == '\r')
return in.substr(0, length - 1);

return in;
}


std::string
escape_header(const std::string& in)
{
Expand Down
2 changes: 2 additions & 0 deletions stomp/Stomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace Stomp
Message ack();
Message nack();

std::string strip_cr(const std::string& in);

std::string escape_header(const std::string& in);
std::string unescape_header(const std::string& in);

Expand Down
22 changes: 20 additions & 2 deletions stomp/testsuite/read1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ BOOST_AUTO_TEST_CASE(test1)

BOOST_AUTO_TEST_CASE(test2)
{
// optional content-lenght
// optional content-lenght and body with null character

istringstream s1("HELLO\nkey:value\ncontent-length:5\n\nWORLD" + null);
istringstream s1("HELLO\nkey:value\ncontent-length:5\n\nW" + null + "RLD" + null);
istream s2(s1.rdbuf());

Message msg = read_message(s2);
Expand All @@ -51,6 +51,24 @@ BOOST_AUTO_TEST_CASE(test2)
BOOST_CHECK_EQUAL(msg.headers["key"], "value");
BOOST_CHECK_EQUAL(msg.headers["content-length"], "5");

BOOST_CHECK_EQUAL(msg.body, "W" + null + "RLD");
}


BOOST_AUTO_TEST_CASE(cr1)
{
// optional carriage returns

istringstream s1("HELLO\r\nkey:value\r\n\r\nWORLD" + null);
istream s2(s1.rdbuf());

Message msg = read_message(s2);

BOOST_CHECK_EQUAL(msg.command, "HELLO");

BOOST_CHECK_EQUAL(msg.headers.size(), 1);
BOOST_CHECK_EQUAL(msg.headers["key"], "value");

BOOST_CHECK_EQUAL(msg.body, "WORLD");
}

Expand Down
19 changes: 19 additions & 0 deletions stomp/testsuite/strip.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE snapper

#include <boost/test/unit_test.hpp>

#include "../Stomp.h"


using namespace std;
using namespace Stomp;


BOOST_AUTO_TEST_CASE(cr)
{
BOOST_CHECK_EQUAL(Stomp::strip_cr("hello"), "hello");
BOOST_CHECK_EQUAL(Stomp::strip_cr("hello\r"), "hello");
BOOST_CHECK_EQUAL(Stomp::strip_cr("hello\r\n"), "hello\r\n");
}
2 changes: 1 addition & 1 deletion testsuite/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AM_CPPFLAGS = -I$(top_srcdir) $(DBUS_CFLAGS)
LDADD = ../snapper/libsnapper.la ../dbus/libdbus.la -lboost_unit_test_framework

check_PROGRAMS = sysconfig-get1.test dirname1.test basename1.test \
equal-date.test dbus-escape.test cmp-lt.test humanstring.test uuid.test \
equal-date.test cmp-lt.test humanstring.test uuid.test \
table.test table-formatter.test csv-formatter.test json-formatter.test \
getopts.test scan-datetime.test root-prefix.test range.test limit.test

Expand Down
1 change: 0 additions & 1 deletion zypp-plugin/snapper-zypp-plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <sys/types.h>
#include <unistd.h>

#include <iostream>
#include <map>
#include <set>
#include <string>
Expand Down
4 changes: 0 additions & 4 deletions zypp-plugin/zypp-plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
*/


#include <iostream>
#include <boost/algorithm/string/trim.hpp>
#include <string>
#include <regex>

using namespace std;

Expand Down

0 comments on commit 150006f

Please sign in to comment.