Skip to content
39 changes: 34 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Differential ShellCheck
Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out source repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v4
with:
Expand All @@ -76,7 +76,7 @@ jobs:
steps:
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
Expand All @@ -90,7 +90,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- name: Initialize the directory
Expand All @@ -103,12 +103,41 @@ jobs:
cat adaptived/adaptived-*/_build/sub/tests/ftests/ftests-wrapper.sh.log
cat adaptived/adaptived-*/_build/sub/tests/ftests/ftests-c-wrapper.sh.log

build-with-clang:
name: Build with Clang
runs-on: ubuntu-latest
env:
CC: clang
CXX: clang++
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Fail on all warnings
run: |
CFLAGS=-Werror
export CFLAGS
- name: Install Dependencies
run: |
while sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do sleep 3; done
sudo apt-get update
sudo apt-get install libjson-c-dev lcov cmake bison flex autoconf automake libtool libsystemd-dev clang -y
- name: Build adaptived
run: cd adaptived && ./autogen.sh && ./configure && make check-build
- name: Run functional tests
run: cd adaptived && make check
- name: Display test logs
if: ${{ always() }}
run: |
cat adaptived/tests/ftests/ftests-wrapper.sh.log
cat adaptived/tests/ftests/ftests-c-wrapper.sh.log

functional_tests_cgv2:
name: Adaptived Functional Tests v2
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- name: Fail on all warnings
Expand Down
3 changes: 1 addition & 2 deletions adaptived/src/shared_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ API int adaptived_get_shared_data(const struct adaptived_cause * const cse, int
API void free_shared_data(struct adaptived_cause * const cse, bool force_delete)
{
struct shared_data *cur, *next, *prev_valid = NULL, *first_valid = NULL;
struct adaptived_name_and_value *name_value;
bool do_free, persist;

if (cse == NULL)
Expand Down Expand Up @@ -215,8 +216,6 @@ API void free_shared_data(struct adaptived_cause * const cse, bool force_delete)
free(cur->data);
break;
case ADAPTIVED_SDATA_NAME_VALUE:
struct adaptived_name_and_value *name_value;

name_value = (struct adaptived_name_and_value *)cur->data;

free(name_value->name);
Expand Down
2 changes: 1 addition & 1 deletion adaptived/src/utils/cgroup_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ API int adaptived_cgroup_set_str(const char * const setting, const char * const
return ret;

if (strlen(validate_value) != strlen(value) ||
strncmp(validate_value, value, strlen(validate_value) != 0)) {
strncmp(validate_value, value, strlen(validate_value)) != 0) {
adaptived_err("Failed to validate %s. Expected %s, read %s\n",
setting, value, validate_value);
free(validate_value);
Expand Down
2 changes: 1 addition & 1 deletion adaptived/src/utils/sd_bus_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ API int adaptived_sd_bus_set_str(const char * const target, const char * const p
return -EFAULT;
}
if (strlen(validate_value) != strlen(value) ||
strncmp(validate_value, value, strlen(validate_value) != 0)) {
strncmp(validate_value, value, strlen(validate_value)) != 0) {
adaptived_err("Failed to validate %s. Expected %s, read %s\n",
property, value, validate_value);
free(validate_value);
Expand Down
8 changes: 5 additions & 3 deletions adaptived/tests/ftests/015-load_rule_at_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char *argv[])
struct adaptived_cause *cse;
struct adaptived_rule *rule;
pthread_t adaptived_thread;
struct adaptived_ctx *ctx;
struct adaptived_ctx *ctx = NULL;
char *time_str = NULL;
void *tret;
int ret;
Expand Down Expand Up @@ -177,8 +177,10 @@ int main(int argc, char *argv[])
adaptived_release_effect(&eff);
adaptived_release_rule(&rule);

adaptived_unload_rule(ctx, rule_name);
adaptived_release(&ctx);
if (ctx) {
adaptived_unload_rule(ctx, rule_name);
adaptived_release(&ctx);
}

return AUTOMAKE_HARD_ERROR;
}
8 changes: 5 additions & 3 deletions adaptived/tests/ftests/016-unload_rule_at_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char *argv[])
struct adaptived_cause *cse;
struct adaptived_rule *rule;
pthread_t adaptived_thread;
struct adaptived_ctx *ctx;
struct adaptived_ctx *ctx = NULL;
char *time_str = NULL;
void *tret;
int ret;
Expand Down Expand Up @@ -187,8 +187,10 @@ int main(int argc, char *argv[])
adaptived_release_effect(&eff);
adaptived_release_rule(&rule);

adaptived_unload_rule(ctx, rule_name);
adaptived_release(&ctx);
if (ctx) {
adaptived_unload_rule(ctx, rule_name);
adaptived_release(&ctx);
}

return AUTOMAKE_HARD_ERROR;
}
2 changes: 1 addition & 1 deletion adaptived/tests/ftests/018-effect-cgroup_setting_set_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char *argv[])
struct adaptived_effect *eff = NULL;
struct adaptived_rule *rule = NULL;
struct adaptived_ctx *ctx = NULL;
struct adaptived_cause *cse;
struct adaptived_cause *cse = NULL;
int ret;

ctx = adaptived_init(NULL);
Expand Down
2 changes: 1 addition & 1 deletion adaptived/tests/gunit/011-kill_processes_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SortPidListTest : public ::testing::Test {

TEST_F(SortPidListTest, Sort)
{
struct pid_info pida[array_size] = { 0 };
struct pid_info pida[array_size] = { { 0 } };
int i;

for (i = 0; i < array_size; i++) {
Expand Down
1 change: 1 addition & 0 deletions adaptived/tests/gunit/012-shared_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ TEST_F(SharedDataTest, CustomDataShare)

populate_cause(&cse, 0);

type = ADAPTIVED_SDATA_STR;
ret = adaptived_update_shared_data(&cse, 0, type, &read_data, 0);
ASSERT_EQ(ret, -ERANGE);

Expand Down
Loading