Skip to content

Commit

Permalink
Merge branch 'master' into edgar-add-support-zstd
Browse files Browse the repository at this point in the history
  • Loading branch information
kiplingw authored Oct 17, 2024
2 parents acb30d4 + 5144616 commit 35de6b2
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 17 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ jobs:
apt -y update
apt -y install $compiler meson pkg-config cmake rapidjson-dev libssl-dev netbase '?exact-name(libhowardhinnant-date-dev)' '?exact-name(libgmock-dev) (?version([1-9]\.[1-9][1-9]) | ?version([1-9]\.[2-9][0-9]))' '?exact-name(libcpp-httplib-dev)' libcurl4-openssl-dev git ca-certificates curl gpg gpgv gpg-agent lcov llvm-dev --no-install-recommends
# Periodically, debian:testing fails with clang, saying that
# libstdc++ cannot be found. In debian:testing/clang, normally
# libstdc++-dev is installed as a dependency of meson. In the
# situation where the build breaks, the meson dependency is
# different to the latest available libstdc++; for instance,
# installing meson dependencies might install
# libstdc++-13-dev, whereas apt has access to
# libstdc++-14-dev. In other situations, the meson dependency
# libstdc++-..-dev may be the same as the latest
# libstdc++-..-dev to which apt has access.
#
# To prevent the build breaking, we need to install the latest
# libstdc++-..-dev to which apt has access - not the N-1
# version which may be installed as a meson dependency.
if [ ${{ matrix.compiler }} = clang ] && [ ${{ matrix.os == 'debian:testing' }} ]; then libstdcpp_latest=$(apt-cache search "libstdc++" | grep "libstdc++-..-dev " | sort -r | head -c 16); libstdcpp_latest_fst9=$(echo "${libstdcpp_latest}" | head -c 9); libstdcpp_latest_lst3=$(echo "${libstdcpp_latest}" | tail -c 4 | head -c 3); if [ ${libstdcpp_latest_fst9} = "libstdc++" ] && [ ${libstdcpp_latest_lst3} = "dev" ]; then apt -y install ${libstdcpp_latest} --no-install-recommends; fi; fi
- name: Install dependencies (Red Hat)
if: contains(matrix.os, 'redhat')
run: |
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ 'macos-12', 'macos-13', 'macos-latest' ]
os: [ 'macos-12', 'macos-13', 'macos-14', 'macos-15' ]
compiler: [ 'gcc', 'clang' ]
sanitizer: [ 'address', 'undefined', 'none' ]
tls: [ 'true', 'false' ]
Expand All @@ -44,9 +44,23 @@ jobs:
if: contains(matrix.os, 'macos')
run: |
if [ ${{ matrix.compiler }} = gcc ]; then compiler=g++; else compiler="clang lld ?exact-name(libclang-rt-dev)"; fi
brew update
brew install meson
# Avoid doing "brew update" - the brew formulas that are
# preinstalled on the github runner image are likely
# consistent with the pre-installed software on the image. If
# we do "brew upate", and then install something new with
# brew, and the "something new" depends on pre-installed
# software on the image, and there are new versions of the
# pre-installed software revealed by doing "brew update", then
# when we install the "something new" brew may try and also
# install a new version of the pre-installed software on which
# the "something new" depends, but that attempt to install a
# new version of the pre-installed software can fail as a
# result of being blocked by the software that is already
# installed.
if ! type "meson" > /dev/null; then brew install meson --overwrite; fi
brew install lcov
brew install --quiet --cask doxygen
brew install googletest
Expand Down
1 change: 1 addition & 0 deletions include/pistache/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ namespace Pistache
// Since it's Single-Consumer, the store does not need to be atomic
tail = next;
new (&res->storage) T(std::move(next->data()));
next->data().~T();
return res;
}
return nullptr;
Expand Down
25 changes: 17 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,23 @@ endif
# #1230.
# Note: If 'dl' is not available, per Meson it suggests that the
# functionality is provided by libc
has_dladdr_func = compiler.has_function('dladdr')
if not has_dladdr_func
libdl_dep += dependency('dl')
has_dladdr_func = compiler.has_function('dladdr', dependencies: libdl_dep)
if not has_dladdr_func
warning('Unable to find dladdr(), even when trying to link to libdl')
endif
libpistache_deps += libdl_dep

# It would be nice to use compiler.has_function('dladdr') to test if
# we need to add libdl, but unfortunately that approach seems to break
# certain Redhat builds, specifically the Redhat builds that use
# ubi-8. In such cases, it appears meson creates a test file that
# includes the comment:
# With some toolchains ... the compiler provides various builtins
# which are not really implemented... [If] the user provides a
# header, including the header didn't lead to the function being
# defined, and the function we are checking isn't a builtin itself,
# we assume the builtin is not functional and error out
# To avoid generating such an error, we take the simpler approach of
# trying to add libdl but making it optional (i.e. not required).
if meson.version().version_compare('>=0.62.0')
deps_libpistache += dependency('dl', required: false)
else
deps_libpistache += compiler.find_library('dl', required: false)
endif

version_array = []
Expand Down
48 changes: 43 additions & 5 deletions tests/mailbox_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,47 @@

struct Data
{
static int num_instances;
static inline int num_instances = 0;
static constexpr int fingerprint = 0xdeadbeef;

Data()
: val(Data::fingerprint)
, payload(std::string(100, 'x'))
{
num_instances++;
}

Data(Data&&)
: val(Data::fingerprint)
, payload(std::string(100, 'x'))
{
num_instances++;
}

Data(const Data&) = delete;

~Data()
{
EXPECT_EQ(val, Data::fingerprint);
EXPECT_GE(0, --num_instances);
EXPECT_GE(--num_instances, 0);
}

int val;

// Dynamic allocation is required to detect a potential memory leak here
std::string payload;
};

int Data::num_instances = 0;
constexpr int Data::fingerprint;
class QueueTest : public testing::Test
{
public:
void SetUp() override
{
Data::num_instances = 0;
}
};

TEST(queue_test, destructor_test)
TEST_F(QueueTest, destructor_test)
{
Pistache::Queue<Data> queue;
EXPECT_TRUE(queue.empty());
Expand All @@ -41,3 +60,22 @@ TEST(queue_test, destructor_test)
}
// Should call Data::~Data 5 times and not 6 (placeholder entry)
}

TEST_F(QueueTest, push_pop)
{
auto queue = std::make_unique<Pistache::Queue<Data>>();
EXPECT_TRUE(queue->empty());

for (int i = 0; i < 5; i++)
{
queue->push(Data());
}

for (int i = 0; i < 5; i++)
{
EXPECT_NE(queue->popSafe(), nullptr);
}

EXPECT_TRUE(queue->empty());
EXPECT_EQ(Data::num_instances, 0);
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.8.20241011
0.4.10.20241017

0 comments on commit 35de6b2

Please sign in to comment.