Added verbosity flag for unit tests

This commit is contained in:
Aris Adamantiadis
2010-05-18 23:02:41 +02:00
parent 7c0ce909ed
commit 4fbe572c02
4 changed files with 26 additions and 1 deletions

View File

@@ -20,6 +20,14 @@ static struct argp_option options[] = {
.doc = "Don't fork the testcases", .doc = "Don't fork the testcases",
.group = 0 .group = 0
}, },
{
.name = "verbose",
.key = 'v',
.arg = NULL,
.flags = 0,
.doc = "Make libssh test more verbose",
.group = 0
},
{NULL, 0, NULL, 0, NULL, 0} {NULL, 0, NULL, 0, NULL, 0}
}; };
@@ -37,6 +45,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
case 'n': case 'n':
arguments->nofork = 1; arguments->nofork = 1;
break; break;
case 'v':
arguments->verbose++;
break;
case ARGP_KEY_ARG: case ARGP_KEY_ARG:
/* End processing here. */ /* End processing here. */
cmdline = &state->argv [state->next - 1]; cmdline = &state->argv [state->next - 1];

View File

@@ -24,6 +24,11 @@ void torture_create_case_timeout(Suite *s, const char *name, TFun function, int
tcase_add_test(tc_new, function); tcase_add_test(tc_new, function);
} }
static int verbosity=0;
int torture_libssh_verbosity(void){
return verbosity;
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
Suite *s = NULL; Suite *s = NULL;
SRunner *sr = NULL; SRunner *sr = NULL;
@@ -33,7 +38,7 @@ int main(int argc, char **argv) {
memset(&arguments,0,sizeof(struct argument_s)); memset(&arguments,0,sizeof(struct argument_s));
torture_cmdline_parse(argc, argv, &arguments); torture_cmdline_parse(argc, argv, &arguments);
verbosity=arguments.verbose;
s = torture_make_suite(); s = torture_make_suite();
sr = srunner_create(s); sr = srunner_create(s);

View File

@@ -13,6 +13,7 @@
struct argument_s { struct argument_s {
char *args[2]; char *args[2];
int nofork; int nofork;
int verbose;
}; };
void torture_cmdline_parse(int argc, char **argv, struct argument_s *arguments); void torture_cmdline_parse(int argc, char **argv, struct argument_s *arguments);
@@ -31,6 +32,12 @@ void torture_create_case_fixture(Suite *s, const char *name, TFun function,
void torture_create_case_timeout(Suite *s, const char *name, TFun function, void torture_create_case_timeout(Suite *s, const char *name, TFun function,
int timeout); int timeout);
/*
* returns the verbosity level asked by user
*/
int torture_libssh_verbosity(void);
/* /*
* This function must be defined in every unit test file. * This function must be defined in every unit test file.
*/ */

View File

@@ -28,8 +28,10 @@
ssh_session session; ssh_session session;
static void setup(void) { static void setup(void) {
int verbosity=torture_libssh_verbosity();
session = ssh_new(); session = ssh_new();
ssh_options_set(session,SSH_OPTIONS_HOST,"localhost"); ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
ssh_options_set(session,SSH_OPTIONS_LOG_VERBOSITY,&verbosity);
} }
static void teardown(void) { static void teardown(void) {