aboutsummaryrefslogtreecommitdiff
path: root/tests/torture.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2014-08-15 11:23:03 +0200
committerAndreas Schneider <asn@cryptomilk.org>2014-08-15 12:32:37 +0200
commit83aed7610ca37c8354bfb27eeb3fdfe3900e2766 (patch)
tree028eace5c04b0223749ea1305b1b80afe39d17dd /tests/torture.c
parent5fa4721c6eb1f6f507b94a2e1972177c2f41141b (diff)
downloadlibssh-83aed7610ca37c8354bfb27eeb3fdfe3900e2766.tar.gz
libssh-83aed7610ca37c8354bfb27eeb3fdfe3900e2766.tar.xz
libssh-83aed7610ca37c8354bfb27eeb3fdfe3900e2766.zip
tests: Make write file a public torture function.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
Diffstat (limited to 'tests/torture.c')
-rw-r--r--tests/torture.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/torture.c b/tests/torture.c
index 38e4e56b..c6213709 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -25,9 +25,11 @@
#include <stdio.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#ifndef _WIN32
-# include <sys/types.h>
-# include <sys/stat.h>
# include <dirent.h>
# include <errno.h>
#endif
@@ -302,6 +304,22 @@ void torture_sftp_close(struct torture_sftp *t) {
#endif /* _WIN32 */
+void torture_write_file(const char *filename, const char *data){
+ int fd;
+ int rc;
+
+ assert_non_null(filename);
+ assert_true(filename[0] != '\0');
+ assert_non_null(data);
+
+ fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0755);
+ assert_true(fd >= 0);
+
+ rc = write(fd, data, strlen(data));
+ assert_int_equal(rc, strlen(data));
+
+ close(fd);
+}
int torture_libssh_verbosity(void){
return verbosity;