diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b60c9d2..c2e69e3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/testcrypt-enum.h b/test/testcrypt-enum.h similarity index 100% rename from testcrypt-enum.h rename to test/testcrypt-enum.h diff --git a/testcrypt.h b/test/testcrypt-func.h similarity index 100% rename from testcrypt.h rename to test/testcrypt-func.h diff --git a/testcrypt.c b/test/testcrypt.c similarity index 97% rename from testcrypt.c rename to test/testcrypt.c index 68e2d11d..e8593431 100644 --- a/testcrypt.c +++ b/test/testcrypt.c @@ -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 diff --git a/test/testcrypt.py b/test/testcrypt.py index b71f851d..18a741d5 100644 --- a/test/testcrypt.py +++ b/test/testcrypt.py @@ -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): diff --git a/testsc.c b/test/testsc.c similarity index 100% rename from testsc.c rename to test/testsc.c diff --git a/testzlib.c b/test/testzlib.c similarity index 100% rename from testzlib.c rename to test/testzlib.c diff --git a/unix/CMakeLists.txt b/unix/CMakeLists.txt index 825ac35f..cff15de0 100644 --- a/unix/CMakeLists.txt +++ b/unix/CMakeLists.txt @@ -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)