X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=test%2Fasynctest.c;h=dc357da8b7a4a8b574064857529665941e8adae8;hb=c720fc35f4aa90cdc7cdc424b976c5322fb0098e;hp=c2740e6e8f567a9b6116c606e58483190014d025;hpb=3cb7c5cfef25463bd197b0c12ca7966f525ebf73;p=oweals%2Fopenssl.git diff --git a/test/asynctest.c b/test/asynctest.c index c2740e6e8f..dc357da8b7 100644 --- a/test/asynctest.c +++ b/test/asynctest.c @@ -1,7 +1,7 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. * - * Licensed under the OpenSSL license (the "License"). You may not use + * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html @@ -123,6 +123,43 @@ static int test_ASYNC_init_thread(void) return 1; } +static int test_callback(void *arg) +{ + printf("callback test pass\n"); + return 1; +} + +static int test_ASYNC_callback_status(void) +{ + ASYNC_WAIT_CTX *waitctx = NULL; + int set_arg = 100; + ASYNC_callback_fn get_callback; + void *get_arg; + int set_status = 1; + + if ( !ASYNC_init_thread(1, 0) + || (waitctx = ASYNC_WAIT_CTX_new()) == NULL + || ASYNC_WAIT_CTX_set_callback(waitctx, test_callback, (void*)&set_arg) + != 1 + || ASYNC_WAIT_CTX_get_callback(waitctx, &get_callback, &get_arg) + != 1 + || test_callback != get_callback + || get_arg != (void*)&set_arg + || (*get_callback)(get_arg) != 1 + || ASYNC_WAIT_CTX_set_status(waitctx, set_status) != 1 + || set_status != ASYNC_WAIT_CTX_get_status(waitctx)) { + fprintf(stderr, "test_ASYNC_callback_status() failed\n"); + ASYNC_WAIT_CTX_free(waitctx); + ASYNC_cleanup_thread(); + return 0; + } + + ASYNC_WAIT_CTX_free(waitctx); + ASYNC_cleanup_thread(); + return 1; + +} + static int test_ASYNC_start_job(void) { ASYNC_JOB *job = NULL; @@ -275,10 +312,8 @@ int main(int argc, char **argv) fprintf(stderr, "OpenSSL build is not ASYNC capable - skipping async tests\n"); } else { - CRYPTO_set_mem_debug(1); - CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - - if ( !test_ASYNC_init_thread() + if (!test_ASYNC_init_thread() + || !test_ASYNC_callback_status() || !test_ASYNC_start_job() || !test_ASYNC_get_current_job() || !test_ASYNC_WAIT_CTX_get_all_fds()