diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2024-05-06 14:31:26 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2024-05-06 14:31:26 +0000 |
commit | fd046fab3cb41d0de62e126db93925a1f495d01a (patch) | |
tree | 8f883e5893e4ebc881759d50ec53e05d9654bea6 /regress/lib/libcrypto | |
parent | e81ad1b7c1816f3b3e3863dbf17bc59ca55c0d7b (diff) |
Provide initial regress for lhash.
For now, this is very limited and only tests calling lh_doall_arg()
multiple times on an empty linked hash. This process currently triggers
a SIGSEGV, which will be soon fixed.
Diffstat (limited to 'regress/lib/libcrypto')
-rw-r--r-- | regress/lib/libcrypto/lhash/Makefile | 12 | ||||
-rw-r--r-- | regress/lib/libcrypto/lhash/lhash_test.c | 59 |
2 files changed, 71 insertions, 0 deletions
diff --git a/regress/lib/libcrypto/lhash/Makefile b/regress/lib/libcrypto/lhash/Makefile new file mode 100644 index 00000000000..5c80b82679b --- /dev/null +++ b/regress/lib/libcrypto/lhash/Makefile @@ -0,0 +1,12 @@ +# $OpenBSD: Makefile,v 1.1 2024/05/06 14:31:25 jsing Exp $ + +PROG = lhash_test + +DPADD+= ${LIBCRYPTO} +WARNINGS= Yes +LDFLAGS+= -lcrypto +CFLAGS+= -DLIBRESSL_INTERNAL +CFLAGS+= -Wall -Wundef -Werror +CFLAGS+= -I${.CURDIR}/../../../../lib/libcrypto + +.include <bsd.regress.mk> diff --git a/regress/lib/libcrypto/lhash/lhash_test.c b/regress/lib/libcrypto/lhash/lhash_test.c new file mode 100644 index 00000000000..c7bd51c042e --- /dev/null +++ b/regress/lib/libcrypto/lhash/lhash_test.c @@ -0,0 +1,59 @@ +/* $OpenBSD: lhash_test.c,v 1.1 2024/05/06 14:31:25 jsing Exp $ */ +/* + * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +#include <openssl/lhash.h> + +static void +test_doall_fn(void *arg1, void *arg2) +{ +} + +static int +test_lhash_doall(void) +{ + _LHASH *lh; + int i; + int failed = 1; + + if ((lh = lh_new(NULL, NULL)) == NULL) + goto failure; + + /* Call doall multiple times while linked hash is empty. */ + for (i = 0; i < 100; i++) + lh_doall_arg(lh, test_doall_fn, NULL); + + lh_free(lh); + + failed = 0; + + failure: + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= test_lhash_doall(); + + return failed; +} |