1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

Move some tests into the test subdirectory.

Now testcrypt has _two_ header files, that's more files than I want at
the top level, so I decided to move it.

It has a good claim to live in either 'test' or 'crypto', but in the
end I decided it wasn't quite specific enough to crypto (it already
also tests things in keygen and proxy), and also, the Python half of
the mechanism already lives in 'test', so it can live alongside that.

Having done that, it seemed silly to leave testsc and testzlib at the
top level: those have 'test' in the names as well, so they can go in
the test subdir as well.

While I'm renaming, also renamed testcrypt.h to testcrypt-func.h to
distinguish it from the new testcrypt-enum.h.
This commit is contained in:
Simon Tatham 2021-11-22 18:50:12 +00:00
parent 9ceb2c49ae
commit 67b11add59
8 changed files with 27 additions and 27 deletions

View File

@ -69,7 +69,7 @@ add_library(otherbackends STATIC
add_subdirectory(otherbackends)
add_executable(testcrypt
testcrypt.c sshpubk.c ssh/crc-attack-detector.c)
test/testcrypt.c sshpubk.c ssh/crc-attack-detector.c)
target_link_libraries(testcrypt
keygen crypto utils ${platform_libraries})

View File

@ -1133,11 +1133,11 @@ OPTIONAL_PTR_FUNC(string)
/*
* HERE BE DRAGONS: the horrible C preprocessor business that reads
* testcrypt.h and generates a marshalling wrapper for each exported
* function.
* testcrypt-func.h and generates a marshalling wrapper for each
* exported function.
*
* In an ideal world, we would start from a specification like this in
* testcrypt.h
* testcrypt-func.h
*
* FUNC(val_foo, example, (ARG(val_bar, bar), ARG(uint, n)))
*
@ -1159,14 +1159,14 @@ OPTIONAL_PTR_FUNC(string)
*
* With a more general macro processor such as m4, or custom code in
* Perl or Python, or a helper program like llvm-tblgen, we could just
* do that directly, reading function specifications from testcrypt.h
* and writing out exactly the above. But we don't have a fully
* general macro processor (since everything in that category
* introduces an extra build dependency that's awkward on plain
* Windows, or requires compiling and running a helper program which
* is awkward in a cross-compile). We only have cpp. And in cpp, a
* macro can't expand one of its arguments differently in two parts of
* its own expansion. So we have to be more clever.
* do that directly, reading function specifications from
* testcrypt-func.h and writing out exactly the above. But we don't
* have a fully general macro processor (since everything in that
* category introduces an extra build dependency that's awkward on
* plain Windows, or requires compiling and running a helper program
* which is awkward in a cross-compile). We only have cpp. And in cpp,
* a macro can't expand one of its arguments differently in two parts
* of its own expansion. So we have to be more clever.
*
* In place of the above code, I instead generate three successive
* declarations for each function. In simplified form they would look
@ -1191,8 +1191,8 @@ OPTIONAL_PTR_FUNC(string)
*
* Each of these mentions the arguments and their types just _once_,
* so each one can be generated by a single expansion of the FUNC(...)
* specification in testcrypt.h, with FUNC and ARG and VOID defined to
* appropriate values.
* specification in testcrypt-func.h, with FUNC and ARG and VOID
* defined to appropriate values.
*
* Or ... *nearly*. In fact, I left out several details there, but
* it's a good starting point to understand the full version.
@ -1251,8 +1251,8 @@ OPTIONAL_PTR_FUNC(string)
* containing *two* int variables, and in between them is the vital
* comma that we need!
*
* So in that pass through testcrypt.h, the ARG(type, name) macro has
* to expand to the weird piece of text
* So in that pass through testcrypt-func.h, the ARG(type, name) macro
* has to expand to the weird piece of text
*
* _predummy_name; // terminating the previous int declaration
* TD_type name; // declaring the thing we actually wanted
@ -1309,8 +1309,8 @@ OPTIONAL_PTR_FUNC(string)
* Finally, what if a wrapped function has _no_ arguments? Two out of
* three uses of the argument list here need some kind of special case
* for that. That's why you have to write 'VOID' explicitly in an
* empty argument list in testcrypt.h: we make VOID expand to whatever
* is needed to avoid a syntax error in that special case.
* empty argument list in testcrypt-func.h: we make VOID expand to
* whatever is needed to avoid a syntax error in that special case.
*/
#define DEPARENTHESISE(...) __VA_ARGS__
@ -1326,7 +1326,7 @@ OPTIONAL_PTR_FUNC(string)
typedef struct ARGS_##fname { \
int DEPARENTHESISE args; \
} ARGS_##fname;
#include "testcrypt.h"
#include "testcrypt-func.h"
#undef FUNC_INNER
#undef ARG
#undef VOID
@ -1340,7 +1340,7 @@ OPTIONAL_PTR_FUNC(string)
args; \
return _args; \
}
#include "testcrypt.h"
#include "testcrypt-func.h"
#undef FUNC_INNER
#undef ARG
#undef VOID
@ -1353,7 +1353,7 @@ OPTIONAL_PTR_FUNC(string)
(void)_args; /* suppress warning if no actual arguments */ \
return_##outtype(_out, realname args); \
}
#include "testcrypt.h"
#include "testcrypt-func.h"
#undef FUNC_INNER
#undef ARG
@ -1383,7 +1383,7 @@ static void process_line(BinarySource *in, strbuf *out)
#define ARG1(type, arg)
#define ARGN(type, arg)
#define VOID
#include "testcrypt.h"
#include "testcrypt-func.h"
#undef FUNC_INNER
#undef ARG
#undef VOID

View File

@ -313,7 +313,7 @@ def _lex_testcrypt_header(header):
while pos < end:
m = pat.match(header, pos)
assert m is not None, (
"Failed to lex testcrypt.h at byte position {:d}".format(pos))
"Failed to lex testcrypt-func.h at byte position {:d}".format(pos))
pos = m.end()
tok = m.group(1)
@ -339,7 +339,7 @@ def _parse_testcrypt_header(tokens):
description = lambda: "'"+what+"' "
ok = tok == what
if not ok:
sys.exit("testcrypt.h:{:d}: expected {}{}".format(
sys.exit("testcrypt-func.h:{:d}: expected {}{}".format(
pos, description(), why))
return tok
@ -392,7 +392,7 @@ def _setup(scope):
arg = arg[:arg.index("_", len(valprefix))]
return arg
with open(os.path.join(putty_srcdir, "testcrypt.h")) as f:
with open(os.path.join(putty_srcdir, "test", "testcrypt-func.h")) as f:
header = f.read()
tokens = _lex_testcrypt_header(header)
for function, rettype, arglist in _parse_testcrypt_header(tokens):

View File

@ -98,11 +98,11 @@ add_executable(cgtest
target_link_libraries(cgtest keygen console crypto utils)
add_executable(testsc
${CMAKE_SOURCE_DIR}/testsc.c)
${CMAKE_SOURCE_DIR}/test/testsc.c)
target_link_libraries(testsc keygen crypto utils)
add_executable(testzlib
${CMAKE_SOURCE_DIR}/testzlib.c
${CMAKE_SOURCE_DIR}/test/testzlib.c
${CMAKE_SOURCE_DIR}/ssh/zlib.c)
target_link_libraries(testzlib utils)