src: add --version-short option; support doctest --dt-XXX options; cleanups
This commit is contained in:
+1
-1
@@ -161,7 +161,7 @@ endif()
|
|||||||
# "make test"
|
# "make test"
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
if (NOT CMAKE_CROSSCOMPILING)
|
if(NOT CMAKE_CROSSCOMPILING)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
set(exe ${CMAKE_EXECUTABLE_SUFFIX})
|
set(exe ${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
set(upx_self_exe "$<TARGET_FILE:upx>")
|
set(upx_self_exe "$<TARGET_FILE:upx>")
|
||||||
|
|||||||
+1
-1
@@ -778,7 +778,7 @@ void show_head();
|
|||||||
void show_help(int verbose=0);
|
void show_help(int verbose=0);
|
||||||
void show_license();
|
void show_license();
|
||||||
void show_usage();
|
void show_usage();
|
||||||
void show_version(int);
|
void show_version(bool one_line=false);
|
||||||
|
|
||||||
// compress.cpp
|
// compress.cpp
|
||||||
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
|
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
|
||||||
|
|||||||
+3
-3
@@ -376,18 +376,18 @@ void show_license(void)
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
void show_version(int x)
|
void show_version(bool one_line)
|
||||||
{
|
{
|
||||||
FILE *fp = stdout;
|
FILE *fp = stdout;
|
||||||
const char *v;
|
const char *v;
|
||||||
UNUSED(x);
|
|
||||||
UNUSED(v);
|
|
||||||
|
|
||||||
fprintf(fp, "upx %s\n", UPX_VERSION_STRING
|
fprintf(fp, "upx %s\n", UPX_VERSION_STRING
|
||||||
#if defined(UPX_VERSION_GITREV)
|
#if defined(UPX_VERSION_GITREV)
|
||||||
"-git-" UPX_VERSION_GITREV
|
"-git-" UPX_VERSION_GITREV
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
if (one_line)
|
||||||
|
return;
|
||||||
#if (WITH_NRV)
|
#if (WITH_NRV)
|
||||||
v = upx_nrv_version_string();
|
v = upx_nrv_version_string();
|
||||||
if (v != nullptr && v[0])
|
if (v != nullptr && v[0])
|
||||||
|
|||||||
+39
-2
@@ -419,10 +419,11 @@ static int do_option(int optc, const char *arg) {
|
|||||||
set_cmd(CMD_VERSION);
|
set_cmd(CMD_VERSION);
|
||||||
break;
|
break;
|
||||||
case 'V' + 256:
|
case 'V' + 256:
|
||||||
|
case 998:
|
||||||
/* according to GNU standards */
|
/* according to GNU standards */
|
||||||
set_term(stdout);
|
set_term(stdout);
|
||||||
opt->console = CON_FILE;
|
opt->console = CON_FILE;
|
||||||
show_version(0);
|
show_version(optc == 998 ? true : false);
|
||||||
e_exit(EXIT_OK);
|
e_exit(EXIT_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -760,6 +761,11 @@ static int do_option(int optc, const char *arg) {
|
|||||||
opt->o_unix.force_pie = true;
|
opt->o_unix.force_pie = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||||
|
case 999: // doctest --dt-XXX option
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
return -1;
|
return -1;
|
||||||
case ':':
|
case ':':
|
||||||
@@ -923,6 +929,35 @@ int main_get_options(int argc, char **argv) {
|
|||||||
{"8mib-ram", 0x10, N, 673},
|
{"8mib-ram", 0x10, N, 673},
|
||||||
{"8mb-ram", 0x10, N, 673},
|
{"8mb-ram", 0x10, N, 673},
|
||||||
|
|
||||||
|
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||||
|
// [doctest] Query flags - the program quits after them. Available:
|
||||||
|
{"dt-c", 0x10, N, 999},
|
||||||
|
{"dt-count", 0x10, N, 999},
|
||||||
|
{"dt-h", 0x10, N, 999},
|
||||||
|
{"dt-help", 0x10, N, 999},
|
||||||
|
{"dt-lr", 0x10, N, 999},
|
||||||
|
{"dt-list-reporters", 0x10, N, 999},
|
||||||
|
{"dt-ltc", 0x10, N, 999},
|
||||||
|
{"dt-list-test-cases", 0x10, N, 999},
|
||||||
|
{"dt-lts", 0x10, N, 999},
|
||||||
|
{"dt-list-test-suites", 0x10, N, 999},
|
||||||
|
{"dt-v", 0x10, N, 999},
|
||||||
|
{"dt-version", 0x10, N, 999},
|
||||||
|
// [doctest] Bool options - can be used like flags and true is assumed. Available:
|
||||||
|
{"dt-d", 0x12, N, 999},
|
||||||
|
{"dt-duration", 0x12, N, 999},
|
||||||
|
{"dt-e", 0x12, N, 999},
|
||||||
|
{"dt-exit", 0x12, N, 999},
|
||||||
|
{"dt-m", 0x12, N, 999},
|
||||||
|
{"dt-minimal", 0x12, N, 999},
|
||||||
|
{"dt-nt", 0x12, N, 999},
|
||||||
|
{"dt-no-throw", 0x12, N, 999},
|
||||||
|
{"dt-nr", 0x12, N, 999},
|
||||||
|
{"dt-no-run", 0x12, N, 999},
|
||||||
|
{"dt-s", 0x12, N, 999},
|
||||||
|
{"dt-success", 0x12, N, 999},
|
||||||
|
#endif
|
||||||
|
|
||||||
{nullptr, 0, nullptr, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1100,6 +1135,8 @@ static void first_options(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
if (strcmp(argv[i], "--version") == 0)
|
if (strcmp(argv[i], "--version") == 0)
|
||||||
do_option('V' + 256, argv[i]);
|
do_option('V' + 256, argv[i]);
|
||||||
|
if (strcmp(argv[i], "--version-short") == 0)
|
||||||
|
do_option(998, argv[i]);
|
||||||
}
|
}
|
||||||
for (i = 1; i < n; i++)
|
for (i = 1; i < n; i++)
|
||||||
if (strcmp(argv[i], "--help") == 0)
|
if (strcmp(argv[i], "--help") == 0)
|
||||||
@@ -1195,7 +1232,7 @@ int upx_main(int argc, char *argv[]) {
|
|||||||
e_exit(EXIT_OK);
|
e_exit(EXIT_OK);
|
||||||
break;
|
break;
|
||||||
case CMD_VERSION:
|
case CMD_VERSION:
|
||||||
show_version(1);
|
show_version();
|
||||||
e_exit(EXIT_OK);
|
e_exit(EXIT_OK);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ void options_t::reset() {
|
|||||||
#endif
|
#endif
|
||||||
o->verbose = 2;
|
o->verbose = 2;
|
||||||
|
|
||||||
|
opt->o_unix.osabi0 = 3; // 3 == ELFOSABI_LINUX
|
||||||
|
|
||||||
o->win32_pe.compress_exports = 1;
|
o->win32_pe.compress_exports = 1;
|
||||||
o->win32_pe.compress_icons = 2;
|
o->win32_pe.compress_icons = 2;
|
||||||
o->win32_pe.compress_resources = -1;
|
o->win32_pe.compress_resources = -1;
|
||||||
|
|||||||
+12
-15
@@ -42,38 +42,35 @@ bool upx_doctest_check(int argc, char **argv) {
|
|||||||
bool minimal = true; // only show failing tests
|
bool minimal = true; // only show failing tests
|
||||||
bool duration = false; // show timings
|
bool duration = false; // show timings
|
||||||
bool success = false; // show all tests
|
bool success = false; // show all tests
|
||||||
|
#if DEBUG
|
||||||
|
minimal = false;
|
||||||
|
#endif
|
||||||
e = getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
e = getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
||||||
if (e && e[0] && strcmp(e, "0") != 0) {
|
if (e && e[0]) {
|
||||||
minimal = false;
|
minimal = false;
|
||||||
if (strcmp(e, "2") == 0)
|
if (strcmp(e, "0") == 0) {
|
||||||
|
minimal = true;
|
||||||
|
} else if (strcmp(e, "2") == 0) {
|
||||||
duration = true;
|
duration = true;
|
||||||
if (strcmp(e, "3") == 0) {
|
} else if (strcmp(e, "3") == 0) {
|
||||||
duration = true;
|
duration = true;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if DEBUG
|
|
||||||
minimal = false;
|
|
||||||
// duration = true;
|
|
||||||
#endif
|
|
||||||
doctest::Context context;
|
doctest::Context context;
|
||||||
#if 0
|
|
||||||
if (argc > 0 && argv != nullptr)
|
|
||||||
context.applyCommandLine(argc, argv);
|
|
||||||
#else
|
|
||||||
UNUSED(argc);
|
|
||||||
UNUSED(argv);
|
|
||||||
#endif
|
|
||||||
if (minimal)
|
if (minimal)
|
||||||
context.setOption("dt-minimal", true);
|
context.setOption("dt-minimal", true);
|
||||||
if (duration)
|
if (duration)
|
||||||
context.setOption("dt-duration", true);
|
context.setOption("dt-duration", true);
|
||||||
if (success)
|
if (success)
|
||||||
context.setOption("dt-success", true);
|
context.setOption("dt-success", true);
|
||||||
|
// this requires that main_get_options() understands "--dt-XXX" options
|
||||||
|
if (argc > 0 && argv != nullptr)
|
||||||
|
context.applyCommandLine(argc, argv);
|
||||||
int r = context.run();
|
int r = context.run();
|
||||||
if (context.shouldExit() || r != 0)
|
if (context.shouldExit() || r != 0)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif // DOCTEST_CONFIG_DISABLE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,13 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#define DOCTEST_CONFIG_IMPLEMENT
|
#define DOCTEST_CONFIG_IMPLEMENT
|
||||||
|
#if !defined(UPX_DOCTEST_CONFIG_MULTITHREADING)
|
||||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||||
#define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
|
#endif
|
||||||
#if defined(__MSDOS__) && defined(__DJGPP__)
|
#if defined(__MSDOS__) && defined(__DJGPP__)
|
||||||
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
|
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
|
||||||
#endif
|
#endif
|
||||||
|
#define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
|
||||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||||
#include <doctest/parts/doctest.cpp>
|
#include <doctest/parts/doctest.cpp>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user