mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
tests: Use descriptive temporary file names.
* tests/gpgscm/ffi.c (do_get_isotime): New function. (ffi_init): Add parameter 'scriptname', bind new function and scriptname. * tests/gpgscm/ffi.h (ffi_init): Update prototype. * tests/gpgscm/main.c (main): Hand in the script name. * tests/gpgscm/tests.scm (mkdtemp): Use current time and script name for the names of temporary directories. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
998643666c
commit
83a406b38a
@ -460,6 +460,16 @@ do_rmdir (scheme *sc, pointer args)
|
||||
FFI_RETURN (sc);
|
||||
}
|
||||
|
||||
static pointer
|
||||
do_get_isotime (scheme *sc, pointer args)
|
||||
{
|
||||
FFI_PROLOG ();
|
||||
gnupg_isotime_t timebuf;
|
||||
FFI_ARGS_DONE_OR_RETURN (sc, args);
|
||||
gnupg_get_isotime (timebuf);
|
||||
FFI_RETURN_STRING (sc, timebuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* estream functions. */
|
||||
@ -1209,7 +1219,8 @@ ffi_scheme_eval (scheme *sc, const char *format, ...)
|
||||
}
|
||||
|
||||
gpg_error_t
|
||||
ffi_init (scheme *sc, const char *argv0, int argc, const char **argv)
|
||||
ffi_init (scheme *sc, const char *argv0, const char *scriptname,
|
||||
int argc, const char **argv)
|
||||
{
|
||||
int i;
|
||||
pointer args = sc->NIL;
|
||||
@ -1255,6 +1266,7 @@ ffi_init (scheme *sc, const char *argv0, int argc, const char **argv)
|
||||
ffi_define_function (sc, getcwd);
|
||||
ffi_define_function (sc, mkdir);
|
||||
ffi_define_function (sc, rmdir);
|
||||
ffi_define_function (sc, get_isotime);
|
||||
|
||||
/* Process management. */
|
||||
ffi_define_function (sc, spawn_process);
|
||||
@ -1288,6 +1300,7 @@ ffi_init (scheme *sc, const char *argv0, int argc, const char **argv)
|
||||
ffi_define_function_name (sc, "*set-verbose!*", set_verbose);
|
||||
|
||||
ffi_define (sc, "*argv0*", sc->vptr->mk_string (sc, argv0));
|
||||
ffi_define (sc, "*scriptname*", sc->vptr->mk_string (sc, scriptname));
|
||||
for (i = argc - 1; i >= 0; i--)
|
||||
{
|
||||
pointer value = sc->vptr->mk_string (sc, argv[i]);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <gpg-error.h>
|
||||
#include "scheme.h"
|
||||
|
||||
gpg_error_t ffi_init (scheme *sc, const char *argv0,
|
||||
gpg_error_t ffi_init (scheme *sc, const char *argv0, const char *scriptname,
|
||||
int argc, const char **argv);
|
||||
|
||||
#endif /* GPGSCM_FFI_H */
|
||||
|
@ -263,7 +263,8 @@ main (int argc, char **argv)
|
||||
if (! err)
|
||||
err = load (sc, "ffi.scm", 0, 1);
|
||||
if (! err)
|
||||
err = ffi_init (sc, argv0, argc, (const char **) argv);
|
||||
err = ffi_init (sc, argv0, script ? script : "interactive",
|
||||
argc, (const char **) argv);
|
||||
if (! err)
|
||||
err = load (sc, "lib.scm", 0, 1);
|
||||
if (! err)
|
||||
|
@ -253,7 +253,10 @@
|
||||
;; generic name is used.
|
||||
(define (mkdtemp . components)
|
||||
(_mkdtemp (if (null? components)
|
||||
(path-join (getenv "TMP") "gpgscm-XXXXXX")
|
||||
(path-join (getenv "TMP")
|
||||
(string-append "gpgscm-" (get-isotime) "-"
|
||||
(basename-suffix *scriptname* ".scm")
|
||||
"-XXXXXX"))
|
||||
(apply path-join components))))
|
||||
|
||||
(macro (with-temporary-working-directory form)
|
||||
|
Loading…
x
Reference in New Issue
Block a user