Skip to content

Commit 03303ab

Browse files
committed
Fix tests
rule_field_matches_string failed because it relied on UB as discussed in #1171
1 parent 298c3a7 commit 03303ab

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
env:
7474
CC: gcc
7575
EXTRA_CFLAGS: "-Werror"
76+
MAKE: gmake
7677

7778
steps:
7879
- uses: actions/checkout@v4
@@ -82,7 +83,7 @@ jobs:
8283
- name: Test in FreeBSD
8384
uses: vmactions/freebsd-vm@v1
8485
with:
85-
envs: "CC EXTRA_CFLAGS"
86+
envs: "CC EXTRA_CFLAGS MAKE"
8687
usesh: true
8788
sync: rsync
8889
copyback: false
@@ -101,7 +102,7 @@ jobs:
101102
./test/test-install.sh
102103
103104
echo "* Run valgrind test"
104-
gmake clean && gmake -j test-valgrind
105+
gmake -j test-valgrind
105106
106107
doxygen:
107108
steps:

src/rules.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static inline bool rule_field_matches_string(const char *value, const char *patt
282282
}
283283
regex_t regex;
284284

285+
// TODO check if regex pattern is not empty
285286
// TODO compile each regex only once
286287
int err = regcomp(&regex, pattern, REG_NEWLINE | REG_EXTENDED | REG_NOSUB);
287288
if (err) {

test/rules.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ TEST test_pattern_match(void) {
4141
ASSERT(rule_field_matches_string("ffffasd", ".*asd"));
4242

4343
// Substring matching
44-
ASSERT(rule_field_matches_string("asd", ""));
4544
ASSERT(rule_field_matches_string("asd", "sd"));
4645
ASSERT(rule_field_matches_string("asd", "a"));
4746
ASSERT(rule_field_matches_string("asd", "d"));

test/test-install.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Throw error any time a command fails
44
set -euo pipefail
55

6+
MAKE=${MAKE:-make}
7+
68
# Export parameters so they are useable by subshells and make
79
export BASE="$(dirname "$(dirname "$(readlink -f "$0")")")"
810
export DESTDIR="${BASE}/install"
@@ -14,7 +16,7 @@ export SERVICEDIR_SYSTEMD="/systemd"
1416
export SERVICEDIR_DBUS="/dbus"
1517

1618
do_make() { # for convenience/conciseness
17-
make -C "${BASE}" "$@"
19+
${MAKE} -C "${BASE}" "$@"
1820
}
1921

2022
check_dest() {

0 commit comments

Comments
 (0)