diff options
| author | Aaron Merey <[email protected]> | 2025-01-30 20:21:03 -0500 |
|---|---|---|
| committer | Aaron Merey <[email protected]> | 2025-02-07 17:13:51 -0500 |
| commit | dda201db20d039df51d52c3c4478fc3318e2c546 (patch) | |
| tree | 01c0b5789ac68bf5de78315be5ba4c357c832ccd /tests | |
| parent | 91d89c007b1a99bfdff79fa5dd55a208289cec1e (diff) | |
tests: Avoid leaking file descriptors
Add calls to close for all test programs that leak file descriptors
in order to prevent test failures when run under valgrind
--track-fds=yes.
Signed-off-by: Aaron Merey <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/all-dwarf-ranges.c | 2 | ||||
| -rw-r--r-- | tests/alldts.c | 1 | ||||
| -rw-r--r-- | tests/dwarf-getmacros.c | 3 | ||||
| -rw-r--r-- | tests/dwarf-ranges.c | 3 | ||||
| -rw-r--r-- | tests/dwarfcfi.c | 1 | ||||
| -rw-r--r-- | tests/dwfl-core-noncontig.c | 2 | ||||
| -rw-r--r-- | tests/early-offscn.c | 1 | ||||
| -rw-r--r-- | tests/ecp.c | 1 | ||||
| -rw-r--r-- | tests/newfile.c | 1 | ||||
| -rw-r--r-- | tests/rerequest_tag.c | 2 | ||||
| -rw-r--r-- | tests/test-elf_cntl_gelf_getshdr.c | 4 | ||||
| -rw-r--r-- | tests/test-flag-nobits.c | 2 | ||||
| -rw-r--r-- | tests/update1.c | 1 | ||||
| -rw-r--r-- | tests/update2.c | 1 | ||||
| -rw-r--r-- | tests/update3.c | 1 | ||||
| -rw-r--r-- | tests/update4.c | 1 |
16 files changed, 25 insertions, 2 deletions
diff --git a/tests/all-dwarf-ranges.c b/tests/all-dwarf-ranges.c index 4331a05b..5924c0ff 100644 --- a/tests/all-dwarf-ranges.c +++ b/tests/all-dwarf-ranges.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <assert.h> #include <inttypes.h> +#include <unistd.h> static void ranges_die (Dwarf_Die *die) @@ -85,6 +86,7 @@ main (int argc, char *argv[]) walk_tree (&die); } dwarf_end (dbg); + close (fd); return 0; } diff --git a/tests/alldts.c b/tests/alldts.c index d0fe4f24..cd12c14d 100644 --- a/tests/alldts.c +++ b/tests/alldts.c @@ -268,5 +268,6 @@ main (void) return 1; } + close (fd); return 0; } diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c index 8381d42c..a9f90ee4 100644 --- a/tests/dwarf-getmacros.c +++ b/tests/dwarf-getmacros.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <assert.h> #include <inttypes.h> +#include <unistd.h> static void include (Dwarf *dbg, Dwarf_Off macoff, ptrdiff_t token); @@ -174,6 +175,6 @@ main (int argc, char *argv[]) } dwarf_end (dbg); - + close (fd); return 0; } diff --git a/tests/dwarf-ranges.c b/tests/dwarf-ranges.c index 4bcf96ce..e111a608 100644 --- a/tests/dwarf-ranges.c +++ b/tests/dwarf-ranges.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <assert.h> #include <inttypes.h> +#include <unistd.h> int main (int argc, char *argv[]) @@ -52,6 +53,6 @@ main (int argc, char *argv[]) start, end, base); dwarf_end (dbg); - + close (fd); return 0; } diff --git a/tests/dwarfcfi.c b/tests/dwarfcfi.c index 29849e71..5f25228d 100644 --- a/tests/dwarfcfi.c +++ b/tests/dwarfcfi.c @@ -170,6 +170,7 @@ main (int argc, char *argv[]) dwarf_end (dwarf); elf_end (elf); + close (fd); return result; } diff --git a/tests/dwfl-core-noncontig.c b/tests/dwfl-core-noncontig.c index 04558e28..f4170206 100644 --- a/tests/dwfl-core-noncontig.c +++ b/tests/dwfl-core-noncontig.c @@ -21,6 +21,7 @@ #include <assert.h> #include ELFUTILS_HEADER(dwfl) #include ELFUTILS_HEADER(elf) +#include <unistd.h> static const Dwfl_Callbacks cb = { @@ -77,6 +78,7 @@ main (int argc, char **argv) dwfl_end (dwfl); elf_end (elf); + close (fd); return 0; } diff --git a/tests/early-offscn.c b/tests/early-offscn.c index af29da5a..9ebba29c 100644 --- a/tests/early-offscn.c +++ b/tests/early-offscn.c @@ -48,5 +48,6 @@ main (int argc, char *argv[]) error (3, 0, "gelf_offscn: %s", elf_errmsg (-1)); elf_end (elf); + close (fd); return 0; } diff --git a/tests/ecp.c b/tests/ecp.c index 44a7bda2..eb16eb4a 100644 --- a/tests/ecp.c +++ b/tests/ecp.c @@ -94,6 +94,7 @@ main (int argc, char *argv[]) close (outfd); elf_end (inelf); + close (infd); return 0; } diff --git a/tests/newfile.c b/tests/newfile.c index 5eabdcb7..be3bd42a 100644 --- a/tests/newfile.c +++ b/tests/newfile.c @@ -166,5 +166,6 @@ main (int argc, char *argv[] __attribute__ ((unused))) (void) elf_end (elf); } + close (fd); return result; } diff --git a/tests/rerequest_tag.c b/tests/rerequest_tag.c index b4d46271..058b8c49 100644 --- a/tests/rerequest_tag.c +++ b/tests/rerequest_tag.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <string.h> #include <assert.h> +#include <unistd.h> int main (int argc, char **argv) @@ -43,5 +44,6 @@ main (int argc, char **argv) assert (dwarf_tag (die) == 0); dwarf_end (dw); + close (i); return 0; } diff --git a/tests/test-elf_cntl_gelf_getshdr.c b/tests/test-elf_cntl_gelf_getshdr.c index 7371110c..a7359334 100644 --- a/tests/test-elf_cntl_gelf_getshdr.c +++ b/tests/test-elf_cntl_gelf_getshdr.c @@ -103,5 +103,9 @@ main (int argc, char *argv[]) } elf_end (elf); + + if (!close_fd) + close (fd); + exit (0); } diff --git a/tests/test-flag-nobits.c b/tests/test-flag-nobits.c index 15d44ea8..c6658d9f 100644 --- a/tests/test-flag-nobits.c +++ b/tests/test-flag-nobits.c @@ -21,6 +21,7 @@ #include <fcntl.h> #include <stdlib.h> #include <gelf.h> +#include <unistd.h> int main (int argc, char **argv) @@ -38,5 +39,6 @@ main (int argc, char **argv) elf_flagdata (elf_getdata (scn, NULL), ELF_C_SET, ELF_F_DIRTY); elf_end (stripped); + close (fd); return 0; } diff --git a/tests/update1.c b/tests/update1.c index b7be4e5f..4d436126 100644 --- a/tests/update1.c +++ b/tests/update1.c @@ -123,6 +123,7 @@ main (int argc, char *argv[] __attribute__ ((unused))) } unlink (fname); + close (fd); return 0; } diff --git a/tests/update2.c b/tests/update2.c index 71455633..f5d7230f 100644 --- a/tests/update2.c +++ b/tests/update2.c @@ -146,6 +146,7 @@ main (int argc, char *argv[] __attribute__ ((unused))) } unlink (fname); + close (fd); return 0; } diff --git a/tests/update3.c b/tests/update3.c index 62f67f74..9f2adab5 100644 --- a/tests/update3.c +++ b/tests/update3.c @@ -201,6 +201,7 @@ main (int argc, char *argv[] __attribute__ ((unused))) } unlink (fname); + close (fd); return 0; } diff --git a/tests/update4.c b/tests/update4.c index a703b592..30d2b9f1 100644 --- a/tests/update4.c +++ b/tests/update4.c @@ -353,6 +353,7 @@ main (int argc, char *argv[] __attribute__ ((unused))) } unlink (fname); + close (fd); return 0; } |
