X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Funit%2Ftest_fd_tracker.c;h=0de1729e6b6808e690c406db42e6d247f0790324;hb=898ba13216992affd6cb40fe11c64bdc6e65ca9e;hp=99b0dae2c3268c60d454e0b8a5f394f9d9b679a2;hpb=f7c3ffd79ddcece895eb0de616001d549aced5fc;p=lttng-tools.git diff --git a/tests/unit/test_fd_tracker.c b/tests/unit/test_fd_tracker.c index 99b0dae2c..0de1729e6 100644 --- a/tests/unit/test_fd_tracker.c +++ b/tests/unit/test_fd_tracker.c @@ -1,18 +1,8 @@ /* - * Copyright (c) - 2018 Jérémie Galarneau + * Copyright (C) 2018 Jérémie Galarneau * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by as - * published by the Free Software Foundation; only version 2 of the License. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -86,6 +76,7 @@ void get_temporary_directories(char **_test_directory, char **_unlink_directory) } } +static int fd_count(void) { DIR *dir; @@ -197,7 +188,7 @@ void test_unsuspendable_basic(void) ok(tracker, "Created an fd tracker with a limit of %d simulateously opened file descriptors", TRACKER_FD_LIMIT); if (!tracker) { - return; + goto end; } track_std_fds(tracker); @@ -206,6 +197,7 @@ void test_unsuspendable_basic(void) fd_tracker_destroy(tracker); ret = rmdir(test_directory); ok(ret == 0, "Test directory is empty"); +end: free(test_directory); free(unlinked_files_directory); } @@ -389,7 +381,7 @@ void test_unsuspendable_close_untracked(void) tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT); if (!tracker) { - return; + goto end;; } ret = pipe(unknown_fds); @@ -412,6 +404,7 @@ void test_unsuspendable_close_untracked(void) fd_tracker_destroy(tracker); ret = rmdir(test_directory); ok(ret == 0, "Test directory is empty"); +end: free(test_directory); free(unlinked_files_directory); } @@ -516,7 +509,7 @@ void test_suspendable_limit(void) tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT); if (!tracker) { - return; + goto end; } dir_handle = lttng_directory_handle_create(test_directory); @@ -537,6 +530,7 @@ void test_suspendable_limit(void) ok(ret == 0, "Test directory is empty"); fd_tracker_destroy(tracker); lttng_directory_handle_put(dir_handle); +end: free(test_directory); free(unlinked_files_directory); } @@ -560,7 +554,7 @@ void test_mixed_limit(void) tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT); if (!tracker) { - return; + goto end; } dir_handle = lttng_directory_handle_create(test_directory); @@ -596,6 +590,7 @@ void test_mixed_limit(void) ok(ret == 0, "Test directory is empty"); fd_tracker_destroy(tracker); lttng_directory_handle_put(dir_handle); +end: free(test_directory); free(unlinked_files_directory); } @@ -632,7 +627,7 @@ void test_suspendable_restore(void) tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT); if (!tracker) { - return; + goto end; } dir_handle = lttng_directory_handle_create(test_directory); @@ -739,6 +734,7 @@ skip_write: ok(ret == 0, "Test directory is empty"); fd_tracker_destroy(tracker); lttng_directory_handle_put(dir_handle); +end: free(test_directory); free(unlinked_files_directory); } @@ -768,7 +764,7 @@ void test_unlink(void) tracker = fd_tracker_create(unlinked_files_directory, 1); if (!tracker) { - return; + goto end; } dir_handle = lttng_directory_handle_create(test_directory); @@ -780,7 +776,7 @@ void test_unlink(void) ok(!ret, "Successfully opened %i handles to %s/%s", handles_to_open, test_directory, file_name); if (ret) { - return; + goto end; } /* @@ -869,6 +865,7 @@ void test_unlink(void) ret = rmdir(test_directory); ok(ret == 0, "Test directory is empty"); +end: fd_tracker_destroy(tracker); free(test_directory); free(unlinked_files_directory);