mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add get_fname_rnd for unit tests that want a unique path every time
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
{print_ = (I64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION)
|
||||
|
||||
const char *get_fname(const char *name);
|
||||
const char *get_fname_rnd(const char *name);
|
||||
struct crypto_pk_t *pk_generate(int idx);
|
||||
|
||||
#define US2_CONCAT_2__(a, b) a ## __ ## b
|
||||
|
||||
@@ -125,6 +125,18 @@ get_fname(const char *name)
|
||||
return get_fname_suffix(name, NULL);
|
||||
}
|
||||
|
||||
/** Return a filename with a random suffix, relative to our testing temporary
|
||||
* directory. If name is NULL, return the name of the testing temporary
|
||||
* directory, without any suffix. */
|
||||
const char *
|
||||
get_fname_rnd(const char *name)
|
||||
{
|
||||
char rnd[256], rnd32[256];
|
||||
crypto_rand(rnd, RAND_PATH_BYTES);
|
||||
base32_encode(rnd32, sizeof(rnd32), rnd, RAND_PATH_BYTES);
|
||||
return get_fname_suffix(name, rnd32);
|
||||
}
|
||||
|
||||
/* Remove a directory and all of its subdirectories */
|
||||
static void
|
||||
rm_rf(const char *dir)
|
||||
|
||||
Reference in New Issue
Block a user