Skip to content

Commit

Permalink
tests: set NLTST_IN_CI for not skipping tests accidentally
Browse files Browse the repository at this point in the history
In CI, we know which tests should be skipped. Let github actions set
NLTST_IN_CI=1, and disable certain skip checks.
  • Loading branch information
thom311 committed May 17, 2024
1 parent dcb9e2e commit d784f2c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
pull_request:

env:
NLTST_IN_CI: 1

jobs:
clang-format:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions tests/nl-test-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,13 @@ void _nltst_assert_link_exists_full(const char *ifname, bool exists)

/*****************************************************************************/

bool _nltst_in_ci(void)
{
return _nl_streq0(getenv("NLTST_IN_CI"), "1");
}

/*****************************************************************************/

bool _nltst_has_iproute2(void)
{
static int has = -1;
Expand All @@ -693,6 +700,10 @@ bool _nltst_skip_no_iproute2(const char *msg)
if (_nltst_has_iproute2())
return false;

ck_assert_msg(
!_nltst_in_ci(),
"We seem to not have iproute2, but we are in NLTST_IN_CI=1. This is fatal.");

printf("skip test due to missing iproute2%s%s%s\n", msg ? " (" : "",
msg ?: "", msg ? ")" : "");
return true;
Expand Down
2 changes: 2 additions & 0 deletions tests/nl-test-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ void nltst_netns_leave(struct nltst_netns *nsdata);

#define _nltst_system(command) _nltst_assert_retcode(system(command))

bool _nltst_in_ci(void);

bool _nltst_has_iproute2(void);
bool _nltst_skip_no_iproute2(const char *msg);

Expand Down

0 comments on commit d784f2c

Please sign in to comment.