p11test: Debug level from commandline
This replaces the debug level defined at build time with -NDEBUG, which turned out to be quite confusing. Fixes #2304
This commit is contained in:
parent
a69ab7c70c
commit
a8a4bddfad
|
@ -31,7 +31,7 @@ p11test_SOURCES = p11test.c p11test_loader.c \
|
|||
p11test_case_pss_oaep.c \
|
||||
p11test_case_interface.c \
|
||||
p11test_helpers.c
|
||||
p11test_CFLAGS = -DNDEBUG $(CMOCKA_CFLAGS)
|
||||
p11test_CFLAGS = $(CMOCKA_CFLAGS)
|
||||
p11test_LDADD = $(OPTIONAL_OPENSSL_LIBS) $(CMOCKA_LIBS)
|
||||
|
||||
if WIN32
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
/* Global variable keeping information about token we are using */
|
||||
token_info_t token;
|
||||
int debug_flag = 0;
|
||||
|
||||
void display_usage() {
|
||||
fprintf(stdout,
|
||||
|
@ -98,7 +99,7 @@ int main(int argc, char** argv) {
|
|||
token.slot_id = (unsigned long) -1;
|
||||
token.log.outfile = NULL;
|
||||
|
||||
while ((command = getopt(argc, argv, "?hm:s:p:io:")) != -1) {
|
||||
while ((command = getopt(argc, argv, "?hm:s:p:io:v")) != -1) {
|
||||
switch (command) {
|
||||
case 'o':
|
||||
token.log.outfile = strdup(optarg);
|
||||
|
@ -120,6 +121,9 @@ int main(int argc, char** argv) {
|
|||
case '?':
|
||||
display_usage();
|
||||
return 0;
|
||||
case 'v':
|
||||
debug_flag = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -498,9 +498,7 @@ int verify_message(test_cert_t *o, token_info_t *info, CK_BYTE *message,
|
|||
CK_FUNCTION_LIST_PTR fp = info->function_pointer;
|
||||
CK_MECHANISM sign_mechanism = { mech->mech, NULL_PTR, 0 };
|
||||
static int verify_support = 1;
|
||||
#ifndef NDEBUG
|
||||
char *name;
|
||||
#endif
|
||||
|
||||
if (!verify_support)
|
||||
goto openssl_verify;
|
||||
|
@ -531,15 +529,11 @@ int verify_message(test_cert_t *o, token_info_t *info, CK_BYTE *message,
|
|||
/* Final */
|
||||
rv = fp->C_VerifyFinal(info->session_handle,
|
||||
sign, sign_length);
|
||||
#ifndef NDEBUG
|
||||
name = "C_VerifyFinal";
|
||||
#endif
|
||||
} else {
|
||||
rv = fp->C_Verify(info->session_handle,
|
||||
message, message_length, sign, sign_length);
|
||||
#ifndef NDEBUG
|
||||
name = "C_Verify";
|
||||
#endif
|
||||
}
|
||||
if (rv == CKR_OK) {
|
||||
mech->result_flags |= FLAGS_SIGN;
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
|
||||
#define MAX_MECHS 200
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define debug_print(fmt, ...) \
|
||||
{ fprintf(stderr, fmt "\n", ##__VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define debug_print(fmt, ...)
|
||||
#endif
|
||||
#define debug_print(fmt, ...) \
|
||||
do { \
|
||||
if (debug_flag) { \
|
||||
fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FLAGS_SIGN 0x01
|
||||
#define FLAGS_SIGN_OPENSSL 0x02
|
||||
|
@ -89,6 +89,7 @@ typedef struct {
|
|||
} token_info_t;
|
||||
|
||||
extern token_info_t token;
|
||||
extern int debug_flag;
|
||||
|
||||
#endif /* P11TEST_COMMON_H */
|
||||
|
||||
|
|
Loading…
Reference in New Issue