diff options
author | jsing <> | 2024-05-06 14:31:25 +0000 |
---|---|---|
committer | jsing <> | 2024-05-06 14:31:25 +0000 |
commit | d8b68bed853f60a20b979d5840f5e7a0e25ea153 (patch) | |
tree | 43f3a3e3abc365a0c2ed5424f90e0a49910b9934 | |
parent | 39176fb1389c5daf8cc1b84bbf27eef3936a1ba4 (diff) | |
download | openbsd-d8b68bed853f60a20b979d5840f5e7a0e25ea153.tar.gz openbsd-d8b68bed853f60a20b979d5840f5e7a0e25ea153.tar.bz2 openbsd-d8b68bed853f60a20b979d5840f5e7a0e25ea153.zip |
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.
-rw-r--r-- | src/regress/lib/libcrypto/lhash/Makefile | 12 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/lhash/lhash_test.c | 59 |
2 files changed, 71 insertions, 0 deletions
diff --git a/src/regress/lib/libcrypto/lhash/Makefile b/src/regress/lib/libcrypto/lhash/Makefile new file mode 100644 index 0000000000..5c80b82679 --- /dev/null +++ b/src/regress/lib/libcrypto/lhash/Makefile | |||
@@ -0,0 +1,12 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2024/05/06 14:31:25 jsing Exp $ | ||
2 | |||
3 | PROG = lhash_test | ||
4 | |||
5 | DPADD+= ${LIBCRYPTO} | ||
6 | WARNINGS= Yes | ||
7 | LDFLAGS+= -lcrypto | ||
8 | CFLAGS+= -DLIBRESSL_INTERNAL | ||
9 | CFLAGS+= -Wall -Wundef -Werror | ||
10 | CFLAGS+= -I${.CURDIR}/../../../../lib/libcrypto | ||
11 | |||
12 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/lhash/lhash_test.c b/src/regress/lib/libcrypto/lhash/lhash_test.c new file mode 100644 index 0000000000..c7bd51c042 --- /dev/null +++ b/src/regress/lib/libcrypto/lhash/lhash_test.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $OpenBSD: lhash_test.c,v 1.1 2024/05/06 14:31:25 jsing Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <stdint.h> | ||
19 | #include <stdio.h> | ||
20 | #include <stdlib.h> | ||
21 | |||
22 | #include <openssl/lhash.h> | ||
23 | |||
24 | static void | ||
25 | test_doall_fn(void *arg1, void *arg2) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | static int | ||
30 | test_lhash_doall(void) | ||
31 | { | ||
32 | _LHASH *lh; | ||
33 | int i; | ||
34 | int failed = 1; | ||
35 | |||
36 | if ((lh = lh_new(NULL, NULL)) == NULL) | ||
37 | goto failure; | ||
38 | |||
39 | /* Call doall multiple times while linked hash is empty. */ | ||
40 | for (i = 0; i < 100; i++) | ||
41 | lh_doall_arg(lh, test_doall_fn, NULL); | ||
42 | |||
43 | lh_free(lh); | ||
44 | |||
45 | failed = 0; | ||
46 | |||
47 | failure: | ||
48 | return failed; | ||
49 | } | ||
50 | |||
51 | int | ||
52 | main(int argc, char **argv) | ||
53 | { | ||
54 | int failed = 0; | ||
55 | |||
56 | failed |= test_lhash_doall(); | ||
57 | |||
58 | return failed; | ||
59 | } | ||