mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
cmdgen: rescue test suite from bit rot.
cmdgen.c has contained code for ages to build a test main() if you compile with -DTEST_CMDGEN. But it's painful to do so manually, since you've still got to link in all the same supporting objects, and also nobody can have actually done that for a while because the stub test code hasn't been kept up to date with changes in the internal APIs (specifically prompt_t). Now we have the ability to include our test programs in Recipe as [UT] or [XT] so as to leave them out of 'make install', that seems like a useful thing to do with cmdgen's test suite. So here's a Recipe change that builds it as 'cgtest', plus fixes for compiler warnings and bit rot. Pleasantly, the test suite still _passes_ after those are fixed.
This commit is contained in:
parent
435b29da88
commit
3e40566bb0
1
.gitignore
vendored
1
.gitignore
vendored
@ -43,6 +43,7 @@
|
||||
/unix/Pterm.app
|
||||
/fuzzterm
|
||||
/testbn
|
||||
/cgtest
|
||||
/*.DSA
|
||||
/*.RSA
|
||||
/*.cnt
|
||||
|
4
Recipe
4
Recipe
@ -311,10 +311,12 @@ puttytel : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_NOSSH
|
||||
plink : [U] uxplink uxcons NONSSH UXSSH U_BE_ALL logging UXMISC uxsignal
|
||||
+ ux_x11 noterm
|
||||
|
||||
puttygen : [U] cmdgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
|
||||
PUTTYGEN_UNIX = sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
|
||||
+ sshrand uxnoise sshsha misc sshrsa sshdss uxcons uxstore uxmisc
|
||||
+ sshpubk sshaes sshsh256 sshsh512 IMPORT puttygen.res time tree234
|
||||
+ uxgen notiming conf sshecc sshecdsag
|
||||
puttygen : [U] cmdgen PUTTYGEN_UNIX
|
||||
cgtest : [UT] cgtest PUTTYGEN_UNIX
|
||||
|
||||
pscp : [U] pscp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC
|
||||
psftp : [U] psftp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC
|
||||
|
6
cgtest.c
Normal file
6
cgtest.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* cgtest.c: stub file to compile cmdgen.c in self-test mode
|
||||
*/
|
||||
|
||||
#define TEST_CMDGEN
|
||||
#include "cmdgen.c"
|
7
cmdgen.c
7
cmdgen.c
@ -19,7 +19,7 @@
|
||||
#ifdef TEST_CMDGEN
|
||||
/*
|
||||
* This section overrides some definitions below for test purposes.
|
||||
* When compiled with -DTEST_CMDGEN:
|
||||
* When compiled with -DTEST_CMDGEN (as cgtest.c will do):
|
||||
*
|
||||
* - Calls to get_random_data() are replaced with the diagnostic
|
||||
* function below (I #define the name so that I can still link
|
||||
@ -52,8 +52,7 @@ int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
|
||||
int ret = 1;
|
||||
for (i = 0; i < p->n_prompts; i++) {
|
||||
if (promptsgot < nprompts) {
|
||||
assert(strlen(prompts[promptsgot]) < p->prompts[i]->result_len);
|
||||
strcpy(p->prompts[i]->result, prompts[promptsgot++]);
|
||||
p->prompts[i]->result = dupstr(prompts[promptsgot++]);
|
||||
} else {
|
||||
promptsgot++; /* track number of requests anyway */
|
||||
ret = 0;
|
||||
@ -1193,7 +1192,7 @@ char *cleanup_fp(char *s)
|
||||
s += strspn(s, " \n\t");
|
||||
s += strcspn(s, " \n\t");
|
||||
|
||||
return dupprintf("%.*s", s - p, p);
|
||||
return dupprintf("%.*s", (int)(s - p), p);
|
||||
}
|
||||
|
||||
char *get_fp(char *filename)
|
||||
|
Loading…
Reference in New Issue
Block a user