X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Frotation%2Fschedule_api.c;h=3a195c12b932c6c50a0dd497e4a759441ad2d75c;hb=HEAD;hp=491fe7b908aea41fa233e33b1188d0e85843f5d3;hpb=4edd268b3d6c2b41c879d3f96de711b4a7e07ac1;p=lttng-tools.git diff --git a/tests/regression/tools/rotation/schedule_api.c b/tests/regression/tools/rotation/schedule_api.c index 491fe7b90..3a195c12b 100644 --- a/tests/regression/tools/rotation/schedule_api.c +++ b/tests/regression/tools/rotation/schedule_api.c @@ -5,40 +5,25 @@ * * Copyright (C) 2018 Jérémie Galarneau * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ -#include +#include + #include +#include #include -#include - #define NUM_TESTS 26 #define SIZE_THRESHOLD_BYTES 1024 -#define PERIODIC_TIME_US 1000000 +#define PERIODIC_TIME_US 1000000 const char *session_name; -bool schedules_equal(const struct lttng_rotation_schedule *a, - const struct lttng_rotation_schedule *b) +static bool schedules_equal(const struct lttng_rotation_schedule *a, + const struct lttng_rotation_schedule *b) { bool equal = false; enum lttng_rotation_schedule_type a_type, b_type; @@ -48,22 +33,19 @@ bool schedules_equal(const struct lttng_rotation_schedule *a, a_type = lttng_rotation_schedule_get_type(a); b_type = lttng_rotation_schedule_get_type(b); if (a_type != b_type) { - diag("Schedules are not of the same type (%i != %i)", - a_type, b_type); + diag("Schedules are not of the same type (%i != %i)", a_type, b_type); goto end; } switch (a_type) { case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD: { - status = lttng_rotation_schedule_size_threshold_get_threshold(a, - &a_value); + status = lttng_rotation_schedule_size_threshold_get_threshold(a, &a_value); if (status != LTTNG_ROTATION_STATUS_OK) { diag("Failed to retrieve size threshold of schedule 'a'"); goto end; } - status = lttng_rotation_schedule_size_threshold_get_threshold(b, - &b_value); + status = lttng_rotation_schedule_size_threshold_get_threshold(b, &b_value); if (status != LTTNG_ROTATION_STATUS_OK) { diag("Failed to retrieve size threshold of schedule 'b'"); goto end; @@ -72,14 +54,12 @@ bool schedules_equal(const struct lttng_rotation_schedule *a, } case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC: { - status = lttng_rotation_schedule_periodic_get_period(a, - &a_value); + status = lttng_rotation_schedule_periodic_get_period(a, &a_value); if (status != LTTNG_ROTATION_STATUS_OK) { diag("Failed to retrieve period of schedule 'a'"); goto end; } - status = lttng_rotation_schedule_periodic_get_period(b, - &b_value); + status = lttng_rotation_schedule_periodic_get_period(b, &b_value); if (status != LTTNG_ROTATION_STATUS_OK) { diag("Failed to retrieve period of schedule 'b'"); goto end; @@ -99,7 +79,7 @@ end: return equal; } -void test_add_null_session(void) +static void test_add_null_session(void) { enum lttng_rotation_status status; struct lttng_rotation_schedule *size_schedule = NULL; @@ -108,46 +88,43 @@ void test_add_null_session(void) status = lttng_session_add_rotation_schedule(NULL, size_schedule); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "NULL session name rejected by lttng_session_add_rotation_schedule()"); + "NULL session name rejected by lttng_session_add_rotation_schedule()"); lttng_rotation_schedule_destroy(size_schedule); } -void test_add_null_schedule(void) +static void test_add_null_schedule(void) { enum lttng_rotation_status status; status = lttng_session_add_rotation_schedule(session_name, NULL); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "NULL schedule rejected by lttng_session_add_rotation_schedule()"); + "NULL schedule rejected by lttng_session_add_rotation_schedule()"); } -void test_add_uninitialized_schedule(void) +static void test_add_uninitialized_schedule(void) { enum lttng_rotation_status status; - struct lttng_rotation_schedule *size_schedule = NULL, - *periodic_schedule = NULL; + struct lttng_rotation_schedule *size_schedule = NULL, *periodic_schedule = NULL; size_schedule = lttng_rotation_schedule_size_threshold_create(); ok(size_schedule, "Created a size threshold session rotation schedule"); - status = lttng_session_add_rotation_schedule(session_name, - size_schedule); + status = lttng_session_add_rotation_schedule(session_name, size_schedule); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "Uninitialized size schedule rejected by lttng_session_add_rotation_schedule()"); + "Uninitialized size schedule rejected by lttng_session_add_rotation_schedule()"); periodic_schedule = lttng_rotation_schedule_periodic_create(); ok(periodic_schedule, "Created a periodic session rotation schedule"); - status = lttng_session_add_rotation_schedule(session_name, - periodic_schedule); + status = lttng_session_add_rotation_schedule(session_name, periodic_schedule); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "Uninitialized periodic schedule rejected by lttng_session_add_rotation_schedule()"); + "Uninitialized periodic schedule rejected by lttng_session_add_rotation_schedule()"); lttng_rotation_schedule_destroy(size_schedule); lttng_rotation_schedule_destroy(periodic_schedule); } -void test_remove_null_session(void) +static void test_remove_null_session(void) { enum lttng_rotation_status status; struct lttng_rotation_schedule *size_schedule = NULL; @@ -156,67 +133,59 @@ void test_remove_null_session(void) status = lttng_session_remove_rotation_schedule(NULL, size_schedule); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "NULL session name rejected by lttng_session_remove_rotation_schedule()"); + "NULL session name rejected by lttng_session_remove_rotation_schedule()"); lttng_rotation_schedule_destroy(size_schedule); } -void test_remove_null_schedule(void) +static void test_remove_null_schedule(void) { enum lttng_rotation_status status; status = lttng_session_remove_rotation_schedule(session_name, NULL); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "NULL schedule rejected by lttng_session_remove_rotation_schedule()"); + "NULL schedule rejected by lttng_session_remove_rotation_schedule()"); } -void test_remove_uninitialized_schedule(void) +static void test_remove_uninitialized_schedule(void) { enum lttng_rotation_status status; - struct lttng_rotation_schedule *size_schedule = NULL, - *periodic_schedule = NULL; + struct lttng_rotation_schedule *size_schedule = NULL, *periodic_schedule = NULL; size_schedule = lttng_rotation_schedule_size_threshold_create(); - status = lttng_session_remove_rotation_schedule(session_name, - size_schedule); + status = lttng_session_remove_rotation_schedule(session_name, size_schedule); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "Uninitialized size schedule rejected by lttng_session_remove_rotation_schedule()"); + "Uninitialized size schedule rejected by lttng_session_remove_rotation_schedule()"); periodic_schedule = lttng_rotation_schedule_periodic_create(); - status = lttng_session_remove_rotation_schedule(session_name, - periodic_schedule); + status = lttng_session_remove_rotation_schedule(session_name, periodic_schedule); ok(status == LTTNG_ROTATION_STATUS_INVALID, - "Uninitialized periodic schedule rejected by lttng_session_remove_rotation_schedule()"); + "Uninitialized periodic schedule rejected by lttng_session_remove_rotation_schedule()"); lttng_rotation_schedule_destroy(size_schedule); lttng_rotation_schedule_destroy(periodic_schedule); } -void test_uninitialized_schedule_get(void) +static void test_uninitialized_schedule_get(void) { uint64_t value; enum lttng_rotation_status status; - struct lttng_rotation_schedule *size_schedule = NULL, - *periodic_schedule = NULL; + struct lttng_rotation_schedule *size_schedule = NULL, *periodic_schedule = NULL; size_schedule = lttng_rotation_schedule_size_threshold_create(); periodic_schedule = lttng_rotation_schedule_periodic_create(); - status = lttng_rotation_schedule_size_threshold_get_threshold( - size_schedule, &value); + status = lttng_rotation_schedule_size_threshold_get_threshold(size_schedule, &value); ok(status == LTTNG_ROTATION_STATUS_UNAVAILABLE, - "Getter on size threshold rotation schedule returns LTTNG_ROTATION_STATUS_UNAVAILABLE by default"); - status = lttng_rotation_schedule_periodic_get_period(periodic_schedule, - &value); + "Getter on size threshold rotation schedule returns LTTNG_ROTATION_STATUS_UNAVAILABLE by default"); + status = lttng_rotation_schedule_periodic_get_period(periodic_schedule, &value); ok(status == LTTNG_ROTATION_STATUS_UNAVAILABLE, - "Getter on periodic rotation schedule returns LTTNG_ROTATION_STATUS_UNAVAILABLE by default"); + "Getter on periodic rotation schedule returns LTTNG_ROTATION_STATUS_UNAVAILABLE by default"); lttng_rotation_schedule_destroy(size_schedule); lttng_rotation_schedule_destroy(periodic_schedule); - } -void test_add_list_remove_schedule( - const struct lttng_rotation_schedule *original_schedule) +static void test_add_list_remove_schedule(const struct lttng_rotation_schedule *original_schedule) { int ret; unsigned int schedules_count = 0; @@ -224,66 +193,57 @@ void test_add_list_remove_schedule( const struct lttng_rotation_schedule *list_schedule; struct lttng_rotation_schedules *list_schedules; - status = lttng_session_add_rotation_schedule(session_name, - original_schedule); + status = lttng_session_add_rotation_schedule(session_name, original_schedule); ok(status == LTTNG_ROTATION_STATUS_OK, - "Add a rotation schedule to session \'%s\'", - session_name); + "Add a rotation schedule to session \'%s\'", + session_name); - ret = lttng_session_list_rotation_schedules(session_name, - &list_schedules); + ret = lttng_session_list_rotation_schedules(session_name, &list_schedules); ok(ret == LTTNG_OK && list_schedules, - "List rotation schedules of session \'%s\'", - session_name); + "List rotation schedules of session \'%s\'", + session_name); - status = lttng_rotation_schedules_get_count(list_schedules, - &schedules_count); + status = lttng_rotation_schedules_get_count(list_schedules, &schedules_count); ok(status == LTTNG_ROTATION_STATUS_OK && schedules_count == 1, - "Listing returned 1 rotation schedule"); + "Listing returned 1 rotation schedule"); - list_schedule = lttng_rotation_schedules_get_at_index(list_schedules, - 0); - ok(list_schedule, - "Obtain the first schedule of a schedules list"); + list_schedule = lttng_rotation_schedules_get_at_index(list_schedules, 0); + ok(list_schedule, "Obtain the first schedule of a schedules list"); ok(schedules_equal(original_schedule, list_schedule), - "Schedule returned by the listing is equal to the reference schedule that was added"); + "Schedule returned by the listing is equal to the reference schedule that was added"); - status = lttng_session_remove_rotation_schedule(session_name, - list_schedule); + status = lttng_session_remove_rotation_schedule(session_name, list_schedule); ok(status == LTTNG_ROTATION_STATUS_OK, - "Remove rotation schedule returned by the schedules listing"); + "Remove rotation schedule returned by the schedules listing"); lttng_rotation_schedules_destroy(list_schedules); - (void) lttng_session_list_rotation_schedules(session_name, - &list_schedules); - status = lttng_rotation_schedules_get_count(list_schedules, - &schedules_count); + (void) lttng_session_list_rotation_schedules(session_name, &list_schedules); + status = lttng_rotation_schedules_get_count(list_schedules, &schedules_count); ok(status == LTTNG_ROTATION_STATUS_OK && schedules_count == 0, - "Listing returned 0 rotation schedules after removal"); - + "Listing returned 0 rotation schedules after removal"); + lttng_rotation_schedules_destroy(list_schedules); } -void test_add_list_remove_size_schedule(void) +static void test_add_list_remove_size_schedule(void) { struct lttng_rotation_schedule *size_schedule; diag("Add, list, and remove a size threshold rotation schedule"); size_schedule = lttng_rotation_schedule_size_threshold_create(); - (void) lttng_rotation_schedule_size_threshold_set_threshold( - size_schedule, SIZE_THRESHOLD_BYTES); + (void) lttng_rotation_schedule_size_threshold_set_threshold(size_schedule, + SIZE_THRESHOLD_BYTES); test_add_list_remove_schedule(size_schedule); lttng_rotation_schedule_destroy(size_schedule); } -void test_add_list_remove_periodic_schedule(void) +static void test_add_list_remove_periodic_schedule(void) { struct lttng_rotation_schedule *periodic_schedule; diag("Add, list, and remove a periodic rotation schedule"); periodic_schedule = lttng_rotation_schedule_periodic_create(); - (void) lttng_rotation_schedule_periodic_set_period( - periodic_schedule, PERIODIC_TIME_US); + (void) lttng_rotation_schedule_periodic_set_period(periodic_schedule, PERIODIC_TIME_US); test_add_list_remove_schedule(periodic_schedule); lttng_rotation_schedule_destroy(periodic_schedule); }