SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / tests / unit / test_fd_tracker.c
index 99b0dae2c3268c60d454e0b8a5f394f9d9b679a2..928f3755a6241243291613f3b2744c8beca79c30 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (c) - 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * 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 <stdlib.h>
@@ -86,7 +76,7 @@ void get_temporary_directories(char **_test_directory, char **_unlink_directory)
        }
 }
 
-int fd_count(void)
+static int fd_count(void)
 {
        DIR *dir;
        struct dirent *entry;
@@ -197,7 +187,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 +196,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 +380,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 +403,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 +508,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 +529,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 +553,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 +589,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 +626,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 +733,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 +763,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 +775,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 +864,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);
This page took 0.027747 seconds and 5 git commands to generate.