mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
cgtest: add a 'verbose' flag.
Activated by setting CGTEST_VERBOSE in the environment, since we already use the whole cgtest command line for other purposes.
This commit is contained in:
parent
7ae5c35419
commit
6cae94be7e
35
cmdgen.c
35
cmdgen.c
@ -36,6 +36,7 @@
|
|||||||
* I define another main() which calls the former repeatedly to
|
* I define another main() which calls the former repeatedly to
|
||||||
* run tests.
|
* run tests.
|
||||||
*/
|
*/
|
||||||
|
bool cgtest_verbose = false;
|
||||||
#define get_random_data get_random_data_diagnostic
|
#define get_random_data get_random_data_diagnostic
|
||||||
char *get_random_data(int len, const char *device)
|
char *get_random_data(int len, const char *device)
|
||||||
{
|
{
|
||||||
@ -53,9 +54,15 @@ int console_get_userpass_input(prompts_t *p)
|
|||||||
for (i = 0; i < p->n_prompts; i++) {
|
for (i = 0; i < p->n_prompts; i++) {
|
||||||
if (promptsgot < nprompts) {
|
if (promptsgot < nprompts) {
|
||||||
p->prompts[i]->result = dupstr(prompts[promptsgot++]);
|
p->prompts[i]->result = dupstr(prompts[promptsgot++]);
|
||||||
|
if (cgtest_verbose)
|
||||||
|
printf(" prompt \"%s\": response \"%s\"\n",
|
||||||
|
p->prompts[i]->prompt, p->prompts[i]->result);
|
||||||
} else {
|
} else {
|
||||||
promptsgot++; /* track number of requests anyway */
|
promptsgot++; /* track number of requests anyway */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
if (cgtest_verbose)
|
||||||
|
printf(" prompt \"%s\": no response preloaded\n",
|
||||||
|
p->prompts[i]->prompt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -1126,6 +1133,31 @@ void test(int retval, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
promptsgot = 0;
|
promptsgot = 0;
|
||||||
|
if (cgtest_verbose) {
|
||||||
|
printf("run:");
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
static const char okchars[] =
|
||||||
|
"0123456789abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ%+,-./:=[]^_";
|
||||||
|
const char *arg = argv[i];
|
||||||
|
|
||||||
|
printf(" ");
|
||||||
|
if (arg[strspn(arg, okchars)]) {
|
||||||
|
printf("'");
|
||||||
|
for (const char *c = argv[i]; *c; c++) {
|
||||||
|
if (*c == '\'') {
|
||||||
|
printf("'\\''");
|
||||||
|
} else {
|
||||||
|
putchar(*c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("'");
|
||||||
|
} else {
|
||||||
|
fputs(arg, stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
ret = cmdgen_main(argc, argv);
|
ret = cmdgen_main(argc, argv);
|
||||||
|
|
||||||
if (ret != retval) {
|
if (ret != retval) {
|
||||||
@ -1243,6 +1275,9 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
static char *const keytypes[] = { "rsa1", "dsa", "rsa" };
|
static char *const keytypes[] = { "rsa1", "dsa", "rsa" };
|
||||||
|
|
||||||
|
if (getenv("CGTEST_VERBOSE"))
|
||||||
|
cgtest_verbose = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Even when this thing is compiled for automatic test mode,
|
* Even when this thing is compiled for automatic test mode,
|
||||||
* it's helpful to be able to invoke it with command-line
|
* it's helpful to be able to invoke it with command-line
|
||||||
|
Loading…
Reference in New Issue
Block a user