diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-11-01 15:40:43 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-11-01 15:41:43 -0400 |
commit | e8d8cce69b34481a27562267d94a1aff19b05518 (patch) | |
tree | 7bb4449140dc52e2e46a88551a01f0fc5311e0ca /gdb/unittests | |
parent | 33ea299c25134ce23805faa6b2b1e7fe6327f6bb (diff) | |
download | gdb-e8d8cce69b34481a27562267d94a1aff19b05518.zip gdb-e8d8cce69b34481a27562267d94a1aff19b05518.tar.gz gdb-e8d8cce69b34481a27562267d94a1aff19b05518.tar.bz2 |
Import mkdtemp gnulib module, fix mingw build
Building with mingw currently fails:
CXX unittests/mkdir-recursive-selftests.o
/home/emaisin/src/binutils-gdb/gdb/unittests/mkdir-recursive-selftests.c: In function ‘void selftests::mkdir_recursive::test()’:
/home/emaisin/src/binutils-gdb/gdb/unittests/mkdir-recursive-selftests.c:49:20: error: ‘mkdtemp’ was not declared in this scope
if (mkdtemp (base) == NULL)
^
Commit
e418a61a67a ("Move mkdir_recursive to common/filestuff.c")
moved this code, but also removed the HAVE_MKDTEMP guard which prevented
the mkdtemp call to be compiled on mingw.
We can either put back the HAVE_MKDTEMP ifdef, or import the gnulib
mkdtemp module, which provides the function for mingw. Since the
mkdir_recursive is susceptible to be used on mingw at some point, I
think it would be nice to have it tested on mingw, so I did the latter.
Once built, I tested it on Windows (copied the resulting gdb.exe on a
Windows machine, ran it, and ran "maint selftest mkdir_recursive"). It
failed, because the temporary directory is hardcoded to "/tmp/...". I
therefore added and used a new get_standard_temp_dir function, which
returns an appropriate temporary directory for the host platform.
gdb/ChangeLog:
* common/pathstuff.c (get_standard_temp_dir): New.
* common/pathstuff.h (get_standard_temp_dir): New.
* config.in: Re-generate.
* configure: Re-generate.
* configure.ac: Don't check for mkdtemp.
* gnulib/aclocal-m4-deps.mk: Re-generate.
* gnulib/aclocal.m4: Re-generate.
* gnulib/config.in: Re-generate.
* gnulib/configure: Re-generate.
* gnulib/import/Makefile.am: Re-generate.
* gnulib/import/Makefile.in: Re-generate.
* gnulib/import/m4/gnulib-cache.m4: Re-generate.
* gnulib/import/m4/gnulib-comp.m4: Re-generate.
* gnulib/import/m4/mkdtemp.m4: New file.
* gnulib/import/mkdtemp.c: New file.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES):
Add mkdtemp module.
* unittests/mkdir-recursive-selftests.c (test): Use
get_standard_temp_dir.
(_initialize_mkdir_recursive_selftests): Remove HAVE_MKDTEMP
ifdef.
* compile/compile.c (get_compile_file_tempdir): Likewise.
Diffstat (limited to 'gdb/unittests')
-rw-r--r-- | gdb/unittests/mkdir-recursive-selftests.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gdb/unittests/mkdir-recursive-selftests.c b/gdb/unittests/mkdir-recursive-selftests.c index d501f8e..5a5c453 100644 --- a/gdb/unittests/mkdir-recursive-selftests.c +++ b/gdb/unittests/mkdir-recursive-selftests.c @@ -21,6 +21,8 @@ #include "common/filestuff.h" #include "selftest.h" +#include "common/byte-vector.h" +#include "common/pathstuff.h" namespace selftests { namespace mkdir_recursive { @@ -44,9 +46,10 @@ create_dir_and_check (const char *dir) static void test () { - char base[] = "/tmp/gdb-selftests-XXXXXX"; + std::string tmp = get_standard_temp_dir () + "/gdb-selftests"; + gdb::char_vector base = make_temp_filename (tmp); - if (mkdtemp (base) == NULL) + if (mkdtemp (base.data ()) == NULL) perror_with_name (("mkdtemp")); /* Try not to leave leftover directories. */ @@ -66,12 +69,12 @@ test () private: const char *m_base; - } cleanup_dirs (base); + } cleanup_dirs (base.data ()); - std::string dir = string_printf ("%s/a/b", base); + std::string dir = string_printf ("%s/a/b", base.data ()); SELF_CHECK (create_dir_and_check (dir.c_str ())); - dir = string_printf ("%s/a/b/c//d/e/", base); + dir = string_printf ("%s/a/b/c//d/e/", base.data ()); SELF_CHECK (create_dir_and_check (dir.c_str ())); } @@ -81,9 +84,7 @@ test () void _initialize_mkdir_recursive_selftests () { -#if defined (HAVE_MKDTEMP) selftests::register_test ("mkdir_recursive", selftests::mkdir_recursive::test); -#endif } |