summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/lhash/lhash_test.c
diff options
context:
space:
mode:
authorjsing <>2024-05-06 14:31:25 +0000
committerjsing <>2024-05-06 14:31:25 +0000
commit4e29b729919a3b50ee082f0b51f3ed4d5fd4e50b (patch)
tree43f3a3e3abc365a0c2ed5424f90e0a49910b9934 /src/regress/lib/libcrypto/lhash/lhash_test.c
parenteb3509d70ad7057433e1728209206d42fa5cddfb (diff)
downloadopenbsd-4e29b729919a3b50ee082f0b51f3ed4d5fd4e50b.tar.gz
openbsd-4e29b729919a3b50ee082f0b51f3ed4d5fd4e50b.tar.bz2
openbsd-4e29b729919a3b50ee082f0b51f3ed4d5fd4e50b.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.
Diffstat (limited to 'src/regress/lib/libcrypto/lhash/lhash_test.c')
-rw-r--r--src/regress/lib/libcrypto/lhash/lhash_test.c59
1 files changed, 59 insertions, 0 deletions
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
24static void
25test_doall_fn(void *arg1, void *arg2)
26{
27}
28
29static int
30test_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
51int
52main(int argc, char **argv)
53{
54 int failed = 0;
55
56 failed |= test_lhash_doall();
57
58 return failed;
59}