From c963046ad68ec5f56e2d348d366daad84ebcaefb Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:13:54 +0100 Subject: [PATCH 1/9] Add freebsd runner --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9598926e6..1b8d6f745 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,6 +67,38 @@ jobs: container: image: ghcr.io/dunst-project/docker-images:${{ matrix.distro }} + + freebsd: + runs-on: ubuntu-latest + + env: + CC: gcc + EXTRA_CFLAGS: "-Werror" + + steps: + - uses: actions/checkout@v4 + - name: Test in FreeBSD + uses: vmactions/freebsd-vm@v1 + with: + envs: "CC EXTRA_CFLAGS" + usesh: true + sync: rsync + + prepare: | + pkg install -y x11-toolkits/pango devel/glib20 graphics/gdk-pixbuf2 graphics/cairo graphics/wayland devel/libnotify devel/dbus x11/libXScrnSaver x11/libXrandr x11/libXext x11/libX11 lang/perl5.36 devel/pkgconf devel/gmake devel/evdev-proto + + run: | + pwd + ls -lah + whoami + env + freebsd-version + sysctl hw.model + sysctl hw.ncpu + sysctl hw.physmem + sysctl hw.usermem + find / -name 'CHANGELOG.md' + coverage: needs: build env: From d7f108b27816f0fbfeeb969f07d929ac98dda25f Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:22:52 +0100 Subject: [PATCH 2/9] Refactor workflow --- .github/workflows/main.yml | 51 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b8d6f745..cb1042962 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: - name: enforce-g_malloc run: "! git grep -P '(? Date: Fri, 24 Jan 2025 00:28:46 +0100 Subject: [PATCH 3/9] Add missing deps --- .github/workflows/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb1042962..086dc567e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,17 +76,22 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Test in FreeBSD uses: vmactions/freebsd-vm@v1 with: envs: "CC EXTRA_CFLAGS" usesh: true sync: rsync + copyback: false prepare: | pkg install -y x11-toolkits/pango devel/glib20 graphics/gdk-pixbuf2 graphics/cairo graphics/wayland \ devel/libnotify devel/dbus x11/libXScrnSaver x11/libXrandr x11/libXext x11/libX11 lang/perl5.36 \ - devel/pkgconf devel/gmake devel/evdev-proto valgrind + devel/pkgconf devel/gmake devel/evdev-proto valgrind x11/libXinerama graphics/wayland-protocols \ + devel/gettext-runtime x11-fonts/fontconfig x11-fonts/dejavu lang/gcc git librsvg2 bash run: | echo "* Run test suite" From 03303abf321f62a6b8c0c40b607a44f88311016f Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:17:09 +0100 Subject: [PATCH 4/9] Fix tests rule_field_matches_string failed because it relied on UB as discussed in #1171 --- .github/workflows/main.yml | 5 +++-- src/rules.c | 1 + test/rules.c | 1 - test/test-install.sh | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 086dc567e..eb502cd6f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,6 +73,7 @@ jobs: env: CC: gcc EXTRA_CFLAGS: "-Werror" + MAKE: gmake steps: - uses: actions/checkout@v4 @@ -82,7 +83,7 @@ jobs: - name: Test in FreeBSD uses: vmactions/freebsd-vm@v1 with: - envs: "CC EXTRA_CFLAGS" + envs: "CC EXTRA_CFLAGS MAKE" usesh: true sync: rsync copyback: false @@ -101,7 +102,7 @@ jobs: ./test/test-install.sh echo "* Run valgrind test" - gmake clean && gmake -j test-valgrind + gmake -j test-valgrind doxygen: steps: diff --git a/src/rules.c b/src/rules.c index 111b5bcc2..b4ce2828c 100644 --- a/src/rules.c +++ b/src/rules.c @@ -282,6 +282,7 @@ static inline bool rule_field_matches_string(const char *value, const char *patt } regex_t regex; + // TODO check if regex pattern is not empty // TODO compile each regex only once int err = regcomp(®ex, pattern, REG_NEWLINE | REG_EXTENDED | REG_NOSUB); if (err) { diff --git a/test/rules.c b/test/rules.c index 04df52147..39763edb0 100644 --- a/test/rules.c +++ b/test/rules.c @@ -41,7 +41,6 @@ TEST test_pattern_match(void) { ASSERT(rule_field_matches_string("ffffasd", ".*asd")); // Substring matching - ASSERT(rule_field_matches_string("asd", "")); ASSERT(rule_field_matches_string("asd", "sd")); ASSERT(rule_field_matches_string("asd", "a")); ASSERT(rule_field_matches_string("asd", "d")); diff --git a/test/test-install.sh b/test/test-install.sh index bf366cc07..c9d5410b1 100755 --- a/test/test-install.sh +++ b/test/test-install.sh @@ -3,6 +3,8 @@ # Throw error any time a command fails set -euo pipefail +MAKE=${MAKE:-make} + # Export parameters so they are useable by subshells and make export BASE="$(dirname "$(dirname "$(readlink -f "$0")")")" export DESTDIR="${BASE}/install" @@ -14,7 +16,7 @@ export SERVICEDIR_SYSTEMD="/systemd" export SERVICEDIR_DBUS="/dbus" do_make() { # for convenience/conciseness - make -C "${BASE}" "$@" + ${MAKE} -C "${BASE}" "$@" } check_dest() { From bda7e8683f29a69cc1d6f4a49dd013ffca6f5f8d Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:35:22 +0100 Subject: [PATCH 5/9] Add valgrind suppressions --- .valgrind.suppressions | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.valgrind.suppressions b/.valgrind.suppressions index 28f4e9c4f..51458eb44 100644 --- a/.valgrind.suppressions +++ b/.valgrind.suppressions @@ -136,6 +136,25 @@ ... } +# The same functions leak even without fontconfig :x +{ + other_pango_leaks + Memcheck:Leak + fun:*alloc + ... + fun:pango_layout_get_pixel_size + ... +} + +{ + other_pango_leaks2 + Memcheck:Leak + fun:*alloc + ... + fun:pango_renderer_draw_layout + ... +} + { rsvg_conditional_jump Memcheck:Cond @@ -194,3 +213,24 @@ fun:notification_load_icon_with_scaling ... } + +{ + # FreeBSD part1 + glib_leak_freebsd1 + Memchek:Leak + fun:*alloc + ... + fun:g_dbus_address_get_stream_sync + ... +} + +{ + # FreeBSD part2 + # XXX: Why isn't memory freed in g_bus_unown_name? + glib_leak_freebsd2 + Memchek:Leak + fun:*alloc + ... + fun:g_bus_own_name + ... +} From a2349211bd8239b4d8a8254524814f771e35e0c5 Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:58:55 +0100 Subject: [PATCH 6/9] Fix install test --- .github/workflows/main.yml | 14 +++++++++++--- .valgrind.suppressions | 2 -- Makefile | 36 ++++++++++++++++++------------------ config.mk | 10 ++++++++-- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb502cd6f..a49268c9c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,6 +74,10 @@ jobs: CC: gcc EXTRA_CFLAGS: "-Werror" MAKE: gmake + INSTALL: ginstall + FIND: gfind + SED: gsed + AWK: gawk steps: - uses: actions/checkout@v4 @@ -83,7 +87,7 @@ jobs: - name: Test in FreeBSD uses: vmactions/freebsd-vm@v1 with: - envs: "CC EXTRA_CFLAGS MAKE" + envs: "CC EXTRA_CFLAGS MAKE INSTALL FIND SED AWK" usesh: true sync: rsync copyback: false @@ -91,10 +95,14 @@ jobs: prepare: | pkg install -y x11-toolkits/pango devel/glib20 graphics/gdk-pixbuf2 graphics/cairo graphics/wayland \ devel/libnotify devel/dbus x11/libXScrnSaver x11/libXrandr x11/libXext x11/libX11 lang/perl5.36 \ - devel/pkgconf devel/gmake devel/evdev-proto valgrind x11/libXinerama graphics/wayland-protocols \ - devel/gettext-runtime x11-fonts/fontconfig x11-fonts/dejavu lang/gcc git librsvg2 bash + devel/pkgconf devel/evdev-proto valgrind x11/libXinerama graphics/wayland-protocols \ + devel/gettext-runtime x11-fonts/dejavu lang/gcc git librsvg2 bash findutils coreutils gmake run: | + echo "* Info" + ls -la + git describe --tags + echo "* Run test suite" gmake -j test diff --git a/.valgrind.suppressions b/.valgrind.suppressions index 51458eb44..8338b8580 100644 --- a/.valgrind.suppressions +++ b/.valgrind.suppressions @@ -218,7 +218,6 @@ # FreeBSD part1 glib_leak_freebsd1 Memchek:Leak - fun:*alloc ... fun:g_dbus_address_get_stream_sync ... @@ -229,7 +228,6 @@ # XXX: Why isn't memory freed in g_bus_unown_name? glib_leak_freebsd2 Memchek:Leak - fun:*alloc ... fun:g_bus_own_name ... diff --git a/Makefile b/Makefile index eb25f1dc8..2fab00036 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ endif test: test/test clean-coverage-run # Make sure an error code is returned when the test fails /usr/bin/env bash -c 'set -euo pipefail;\ - TESTDIR=./test ./test/test -v | ./test/greenest.awk ' + TESTDIR=./test ./test/test -v | ${AWK} -f ./test/greenest.awk ' test-valgrind: test/test TESTDIR=./test ${VALGRIND} \ @@ -223,49 +223,49 @@ clean-wayland-protocols: install: install-dunst install-dunstctl install-dunstrc install-service install-dunst: dunst doc - install -Dm755 dunst ${DESTDIR}${BINDIR}/dunst - install -Dm644 docs/dunst.1 ${DESTDIR}${MANPREFIX}/man1/dunst.1 - install -Dm644 docs/dunst.5 ${DESTDIR}${MANPREFIX}/man5/dunst.5 - install -Dm644 docs/dunstctl.1 ${DESTDIR}${MANPREFIX}/man1/dunstctl.1 - install -Dm644 docs/dunstify.1 ${DESTDIR}${MANPREFIX}/man1/dunstify.1 + ${INSTALL} -Dm755 dunst ${DESTDIR}${BINDIR}/dunst + ${INSTALL} -Dm644 docs/dunst.1 ${DESTDIR}${MANPREFIX}/man1/dunst.1 + ${INSTALL} -Dm644 docs/dunst.5 ${DESTDIR}${MANPREFIX}/man5/dunst.5 + ${INSTALL} -Dm644 docs/dunstctl.1 ${DESTDIR}${MANPREFIX}/man1/dunstctl.1 + ${INSTALL} -Dm644 docs/dunstify.1 ${DESTDIR}${MANPREFIX}/man1/dunstify.1 install-dunstctl: dunstctl - install -Dm755 dunstctl ${DESTDIR}${BINDIR}/dunstctl + ${INSTALL} -Dm755 dunstctl ${DESTDIR}${BINDIR}/dunstctl ifeq (1,${SYSCONF_FORCE_NEW}) install-dunstrc: - install -Dm644 dunstrc ${DESTDIR}${SYSCONFFILE} + ${INSTALL} -Dm644 dunstrc ${DESTDIR}${SYSCONFFILE} endif install-service: install-service-dbus install-service-dbus: service-dbus - install -Dm644 org.knopwob.dunst.service ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service + ${INSTALL} -Dm644 org.knopwob.dunst.service ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service ifneq (0,${SYSTEMD}) install-service: install-service-systemd install-service-systemd: service-systemd - install -Dm644 dunst.systemd.service ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service + ${INSTALL} -Dm644 dunst.systemd.service ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service endif ifneq (0,${DUNSTIFY}) install: install-dunstify install-dunstify: dunstify - install -Dm755 dunstify ${DESTDIR}${BINDIR}/dunstify + ${INSTALL} -Dm755 dunstify ${DESTDIR}${BINDIR}/dunstify endif ifneq (0,${COMPLETIONS}) install: install-completions install-completions: - install -Dm644 completions/dunst.bashcomp ${DESTDIR}${BASHCOMPLETIONDIR}/dunst - install -Dm644 completions/dunstctl.bashcomp ${DESTDIR}${BASHCOMPLETIONDIR}/dunstctl - install -Dm644 completions/_dunst.zshcomp ${DESTDIR}${ZSHCOMPLETIONDIR}/_dunst - install -Dm644 completions/_dunstctl.zshcomp ${DESTDIR}${ZSHCOMPLETIONDIR}/_dunstctl - install -Dm644 completions/dunst.fishcomp ${DESTDIR}${FISHCOMPLETIONDIR}/dunst.fish - install -Dm644 completions/dunstctl.fishcomp ${DESTDIR}${FISHCOMPLETIONDIR}/dunstctl.fish + ${INSTALL} -Dm644 completions/dunst.bashcomp ${DESTDIR}${BASHCOMPLETIONDIR}/dunst + ${INSTALL} -Dm644 completions/dunstctl.bashcomp ${DESTDIR}${BASHCOMPLETIONDIR}/dunstctl + ${INSTALL} -Dm644 completions/_dunst.zshcomp ${DESTDIR}${ZSHCOMPLETIONDIR}/_dunst + ${INSTALL} -Dm644 completions/_dunstctl.zshcomp ${DESTDIR}${ZSHCOMPLETIONDIR}/_dunstctl + ${INSTALL} -Dm644 completions/dunst.fishcomp ${DESTDIR}${FISHCOMPLETIONDIR}/dunst.fish + ${INSTALL} -Dm644 completions/dunstctl.fishcomp ${DESTDIR}${FISHCOMPLETIONDIR}/dunstctl.fish ifneq (0,${DUNSTIFY}) install: install-completions-dunstify install-completions-dunstify: - install -Dm644 completions/dunstify.fishcomp ${DESTDIR}${FISHCOMPLETIONDIR}/dunstify.fish + ${INSTALL} -Dm644 completions/dunstify.fishcomp ${DESTDIR}${FISHCOMPLETIONDIR}/dunstify.fish endif endif diff --git a/config.mk b/config.mk index 1def34580..5ac790bf4 100644 --- a/config.mk +++ b/config.mk @@ -15,15 +15,21 @@ SERVICEDIR_SYSTEMD ?= ${PREFIX}/lib/systemd/user EXTRA_CFLAGS ?= DOXYGEN ?= doxygen -FIND ?= find GCOVR ?= gcovr GIT ?= git PKG_CONFIG ?= pkg-config POD2MAN ?= pod2man -SED ?= sed SYSTEMDAEMON ?= systemd VALGRIND ?= valgrind +# Provided for compatibility with BSDs +# You will need to prepend g's to these programs +INSTALL ?= install +MAKE ?= make +FIND ?= find +SED ?= sed +AWK ?= awk + # Disable systemd service file installation, # if you don't want to use systemd albeit installed #SYSTEMD ?= 0 From d151d18ae3afae660764a6bd243b299a6152e042 Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 02:37:26 +0100 Subject: [PATCH 7/9] Fix git error --- .github/workflows/main.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a49268c9c..b05f4d219 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -95,12 +95,11 @@ jobs: prepare: | pkg install -y x11-toolkits/pango devel/glib20 graphics/gdk-pixbuf2 graphics/cairo graphics/wayland \ devel/libnotify devel/dbus x11/libXScrnSaver x11/libXrandr x11/libXext x11/libX11 lang/perl5.36 \ - devel/pkgconf devel/evdev-proto valgrind x11/libXinerama graphics/wayland-protocols \ - devel/gettext-runtime x11-fonts/dejavu lang/gcc git librsvg2 bash findutils coreutils gmake + devel/pkgconf devel/evdev-proto valgrind x11/libXinerama graphics/wayland-protocols x11-fonts/dejavu \ + devel/gettext-runtime gsed gawk gcc git librsvg2 bash findutils coreutils gmake run: | - echo "* Info" - ls -la + git config --global --add safe.directory '*' git describe --tags echo "* Run test suite" From fa89e61aeed97e70d84b1628aa5e451e934b3446 Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 02:44:47 +0100 Subject: [PATCH 8/9] Fix find --- test/test-install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test-install.sh b/test/test-install.sh index c9d5410b1..5595fc0b5 100755 --- a/test/test-install.sh +++ b/test/test-install.sh @@ -4,6 +4,7 @@ set -euo pipefail MAKE=${MAKE:-make} +FIND=${FIND:-find} # Export parameters so they are useable by subshells and make export BASE="$(dirname "$(dirname "$(readlink -f "$0")")")" @@ -21,7 +22,7 @@ do_make() { # for convenience/conciseness check_dest() { # Check file list given on stdin and see if all are actually present - diff -u <(find "${DESTDIR}" -type f -printf "%P\n" | sort) <(sort -) + diff -u <($FIND "${DESTDIR}" -type f -printf "%P\n" | sort) <(sort -) } do_make install @@ -56,8 +57,8 @@ EOF do_make uninstall-purge # Expect empty -if ! [ -z "$(find "${DESTDIR}" -type f)" ]; then +if ! [ -z "$($FIND "${DESTDIR}" -type f)" ]; then echo "Uninstall failed, following files weren't removed" - find "${DESTDIR}" -type f + $FIND "${DESTDIR}" -type f exit 1 fi From 3b5e92548a5bde3d11801eaa54f383ce8c8c0155 Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Fri, 24 Jan 2025 02:48:34 +0100 Subject: [PATCH 9/9] Update valgrind supression --- .github/workflows/main.yml | 3 ++- .valgrind.suppressions | 55 +++++++++++++++++++++++++++++++------- Makefile | 2 +- config.mk | 1 + 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b05f4d219..e3503898f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,6 +78,7 @@ jobs: FIND: gfind SED: gsed AWK: gawk + RMDIR: grmdir steps: - uses: actions/checkout@v4 @@ -87,7 +88,7 @@ jobs: - name: Test in FreeBSD uses: vmactions/freebsd-vm@v1 with: - envs: "CC EXTRA_CFLAGS MAKE INSTALL FIND SED AWK" + envs: "CC EXTRA_CFLAGS MAKE INSTALL FIND SED AWK RMDIR" usesh: true sync: rsync copyback: false diff --git a/.valgrind.suppressions b/.valgrind.suppressions index 8338b8580..f401bdf27 100644 --- a/.valgrind.suppressions +++ b/.valgrind.suppressions @@ -110,7 +110,7 @@ # a librsvg memoryleak that shows up in arch, but not in the CI environment { - + librsvg-arch Memcheck:Leak match-leak-kinds: definite fun:malloc @@ -215,20 +215,55 @@ } { - # FreeBSD part1 - glib_leak_freebsd1 - Memchek:Leak + g_bus_own_name_supp + Memcheck:Leak + match-leak-kinds: definite + fun:*alloc ... - fun:g_dbus_address_get_stream_sync + obj:/usr/local/lib/libgio-2.0.so.0.8000.5 + ... + fun:g_bus_own_name + fun:dbus_init + fun:test_dbus_init ... } { - # FreeBSD part2 - # XXX: Why isn't memory freed in g_bus_unown_name? - glib_leak_freebsd2 - Memchek:Leak + gdk_pixbuf_new_from_file_freebsd + Memcheck:Leak + match-leak-kinds: definite + fun:calloc ... - fun:g_bus_own_name + obj:/usr/local/lib/librsvg-2.so.2.40.21 + ... + obj:/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so + obj:/usr/local/lib/libgdk_pixbuf-2.0.so.0.4200.10 + fun:gdk_pixbuf_new_from_file + fun:notification_setup_raw_image + ... +} + +{ + freebsd_dbus_leak + Memcheck:Leak + match-leak-kinds: definite + fun:calloc + fun:g_malloc0 + fun:g_type_create_instance + fun:g_param_spec_internal + ... + obj:/usr/local/lib/libgio-2.0.so.0.8000.5 + obj:/usr/local/lib/libgobject-2.0.so.0.8000.5 + ... + fun:g_object_new + ... +} + +{ + glib_freebsd + Memcheck:Leak + fun:*alloc + ... + fun:g_dbus_address_get_stream_sync ... } diff --git a/Makefile b/Makefile index 2fab00036..b58533b35 100644 --- a/Makefile +++ b/Makefile @@ -281,7 +281,7 @@ uninstall-keepconf: uninstall-service uninstall-dunstctl uninstall-completions uninstall-dunstrc: rm -f ${DESTDIR}${SYSCONFFILE} - rmdir --ignore-fail-on-non-empty ${DESTDIR}${SYSCONFDIR}/dunst + ${RMDIR} --ignore-fail-on-non-empty ${DESTDIR}${SYSCONFDIR}/dunst uninstall-dunstctl: rm -f ${DESTDIR}${BINDIR}/dunstctl diff --git a/config.mk b/config.mk index 5ac790bf4..2590c282c 100644 --- a/config.mk +++ b/config.mk @@ -29,6 +29,7 @@ MAKE ?= make FIND ?= find SED ?= sed AWK ?= awk +RMDIR ?= rmdir # Disable systemd service file installation, # if you don't want to use systemd albeit installed