2011-02-06 16:50:33 +03:00
|
|
|
/*
|
|
|
|
* torture.c - torture library for testing libssh
|
|
|
|
*
|
|
|
|
* This file is part of the SSH Library
|
|
|
|
*
|
2014-01-07 19:08:23 +04:00
|
|
|
* Copyright (c) 2008-2009 by Andreas Schneider <asn@cryptomilk.org>
|
2011-02-06 16:50:33 +03:00
|
|
|
*
|
|
|
|
* The SSH Library is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* The SSH Library is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with the SSH Library; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
* MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2010-03-02 15:47:14 +03:00
|
|
|
#ifndef _TORTURE_H
|
|
|
|
#define _TORTURE_H
|
|
|
|
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2010-12-28 15:43:32 +03:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
2010-03-02 15:47:14 +03:00
|
|
|
|
2011-02-06 13:15:05 +03:00
|
|
|
#include "libssh/priv.h"
|
2014-04-17 08:29:52 +04:00
|
|
|
#include "libssh/server.h"
|
2011-02-06 16:50:33 +03:00
|
|
|
#include "libssh/sftp.h"
|
2011-01-13 20:34:04 +03:00
|
|
|
|
2012-10-07 13:10:27 +04:00
|
|
|
#include <cmocka.h>
|
2011-12-27 10:14:08 +04:00
|
|
|
|
2011-01-13 20:34:04 +03:00
|
|
|
/* Used by main to communicate with parse_opt. */
|
|
|
|
struct argument_s {
|
|
|
|
char *args[2];
|
|
|
|
int verbose;
|
|
|
|
};
|
|
|
|
|
2011-02-06 16:58:28 +03:00
|
|
|
struct torture_sftp {
|
|
|
|
ssh_session ssh;
|
|
|
|
sftp_session sftp;
|
|
|
|
char *testdir;
|
|
|
|
};
|
|
|
|
|
2011-01-13 20:34:04 +03:00
|
|
|
void torture_cmdline_parse(int argc, char **argv, struct argument_s *arguments);
|
|
|
|
|
2011-02-06 16:57:29 +03:00
|
|
|
int torture_rmdirs(const char *path);
|
2011-02-06 16:58:03 +03:00
|
|
|
int torture_isdir(const char *path);
|
2011-02-06 16:57:29 +03:00
|
|
|
|
2010-03-02 15:47:14 +03:00
|
|
|
/*
|
2010-12-28 15:43:32 +03:00
|
|
|
* Returns the verbosity level asked by user
|
2010-05-19 01:02:41 +04:00
|
|
|
*/
|
|
|
|
int torture_libssh_verbosity(void);
|
|
|
|
|
2011-02-06 13:15:05 +03:00
|
|
|
ssh_session torture_ssh_session(const char *host,
|
2014-04-19 23:27:48 +04:00
|
|
|
const unsigned int *port,
|
2011-02-06 13:15:05 +03:00
|
|
|
const char *user,
|
|
|
|
const char *password);
|
2010-05-19 01:02:41 +04:00
|
|
|
|
2014-04-17 08:29:52 +04:00
|
|
|
ssh_bind torture_ssh_bind(const char *addr,
|
|
|
|
const unsigned int port,
|
|
|
|
const char *private_key_file);
|
|
|
|
|
2011-02-06 16:58:28 +03:00
|
|
|
struct torture_sftp *torture_sftp_session(ssh_session session);
|
|
|
|
void torture_sftp_close(struct torture_sftp *t);
|
|
|
|
|
2014-08-15 14:23:53 +04:00
|
|
|
const char *torture_get_testkey(enum ssh_keytypes_e type,
|
|
|
|
int ecdsa_bits,
|
|
|
|
int with_passphrase);
|
|
|
|
const char *torture_get_testkey_pub(enum ssh_keytypes_e type, int ecdsa_bits);
|
2014-08-15 14:27:31 +04:00
|
|
|
const char *torture_get_testkey_passphrase(void);
|
2014-08-15 14:23:53 +04:00
|
|
|
|
2014-08-15 13:23:03 +04:00
|
|
|
void torture_write_file(const char *filename, const char *data);
|
|
|
|
|
2010-05-19 00:25:06 +04:00
|
|
|
/*
|
|
|
|
* This function must be defined in every unit test file.
|
|
|
|
*/
|
2010-12-28 15:43:32 +03:00
|
|
|
int torture_run_tests(void);
|
2010-05-19 00:25:06 +04:00
|
|
|
|
2010-03-02 15:47:14 +03:00
|
|
|
#endif /* _TORTURE_H */
|