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 <ame...@redhat.com> --- tests/all-dwarf-ranges.c | 2 ++ tests/alldts.c | 1 + tests/dwarf-getmacros.c | 3 ++- tests/dwarf-ranges.c | 3 ++- tests/dwarfcfi.c | 1 + tests/dwfl-core-noncontig.c | 2 ++ tests/early-offscn.c | 1 + tests/ecp.c | 1 + tests/newfile.c | 1 + tests/rerequest_tag.c | 2 ++ tests/test-flag-nobits.c | 2 ++ tests/update1.c | 1 + tests/update2.c | 1 + tests/update3.c | 1 + tests/update4.c | 1 + 15 files changed, 21 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-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; } -- 2.48.1