aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.h
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-11-28 00:00:05 +0100
committerJulius Bünger <buenger@mytum.de>2018-11-28 00:00:05 +0100
commit3cb06d8896196df2238c2b6dda59ba871af8b276 (patch)
tree6bc76a2a07657291a5a8620d0e1f501d421bb6c7 /src/rps/rps-test_util.h
parent8e9283304a3cdcdaec6be207e60b172642af5a17 (diff)
downloadgnunet-3cb06d8896196df2238c2b6dda59ba871af8b276.tar.gz
gnunet-3cb06d8896196df2238c2b6dda59ba871af8b276.zip
RPS tests/profiler: Keep files for dumping internals open
Diffstat (limited to 'src/rps/rps-test_util.h')
-rw-r--r--src/rps/rps-test_util.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index a806f11cd..5dfcc5f6a 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -39,23 +39,43 @@ char *
39create_file (const char *name); 39create_file (const char *name);
40 40
41/** 41/**
42 * @brief Get file handle
43 *
44 * If necessary, create file handle and store it with the other file handles.
45 *
46 * @param name Name of the file
47 *
48 * @return File handle
49 */
50struct GNUNET_DISK_FileHandle *
51get_file_handle (const char *name);
52
53/**
54 * @brief Close all files that were opened with #get_file_handle
55 *
56 * @return Success of iterating over files
57 */
58int
59close_all_files ();
60
61/**
42 * This function is used to facilitate writing important information to disk 62 * This function is used to facilitate writing important information to disk
43 */ 63 */
44#ifdef TO_FILE 64#ifdef TO_FILE
45# define to_file(file_name, ...) do {char tmp_buf[512] = "";\ 65#define to_file(file_name, ...) do {GNUNET_assert (NULL != file_name);\
66 char tmp_buf[512] = "";\
46 int size;\ 67 int size;\
47 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ 68 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
48 if (0 > size)\ 69 if (0 > size)\
49 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ 70 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
50 "Failed to create tmp_buf\n");\ 71 "Failed to create tmp_buf\n");\
51 else\ 72 else\
52 GNUNET_DISK_fn_write(file_name, tmp_buf, strnlen(tmp_buf, 512),\ 73 GNUNET_DISK_file_write (get_file_handle (file_name),\
53 GNUNET_DISK_PERM_USER_READ |\ 74 tmp_buf,\
54 GNUNET_DISK_PERM_USER_WRITE |\ 75 strnlen (tmp_buf, 512));\
55 GNUNET_DISK_PERM_GROUP_READ |\
56 GNUNET_DISK_PERM_OTHER_READ);\
57 } while (0); 76 } while (0);
58 77
78
59#define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\ 79#define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\
60 int size;\ 80 int size;\
61 memset (tmp_buf, 0, len);\ 81 memset (tmp_buf, 0, len);\
@@ -64,11 +84,9 @@ create_file (const char *name);
64 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ 84 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
65 "Failed to create tmp_buf\n");\ 85 "Failed to create tmp_buf\n");\
66 else\ 86 else\
67 GNUNET_DISK_fn_write(file_name, tmp_buf, strnlen(tmp_buf, len), \ 87 GNUNET_DISK_file_write (get_file_handle (file_name),\
68 GNUNET_DISK_PERM_USER_READ |\ 88 tmp_buf,\
69 GNUNET_DISK_PERM_USER_WRITE |\ 89 strnlen (tmp_buf, 512));\
70 GNUNET_DISK_PERM_GROUP_READ |\
71 GNUNET_DISK_PERM_OTHER_READ);\
72 } while (0); 90 } while (0);
73#else /* TO_FILE */ 91#else /* TO_FILE */
74# define to_file(file_name, ...) 92# define to_file(file_name, ...)