diff options
| author | jsing <> | 2014-06-22 14:30:52 +0000 |
|---|---|---|
| committer | jsing <> | 2014-06-22 14:30:52 +0000 |
| commit | 440ff25a446d028b864136cc92f0469572b7d187 (patch) | |
| tree | 2c9edbbbc900ed48351ad4bd3156f414bde51e0a /src | |
| parent | af1321a7967f494d3fb83c108ae4165671e79dd9 (diff) | |
| download | openbsd-440ff25a446d028b864136cc92f0469572b7d187.tar.gz openbsd-440ff25a446d028b864136cc92f0469572b7d187.tar.bz2 openbsd-440ff25a446d028b864136cc92f0469572b7d187.zip | |
Add a skeleton regress for crypto/bio, which currently only covers
BIO_get_port() and fails since the current code believes that "-1" is a
valid port.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/Makefile | 3 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/bio/Makefile | 9 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/bio/biotest.c | 83 |
3 files changed, 94 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/Makefile b/src/regress/lib/libcrypto/Makefile index d9bd92f637..19cb9ab4ad 100644 --- a/src/regress/lib/libcrypto/Makefile +++ b/src/regress/lib/libcrypto/Makefile | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.13 2014/06/22 14:28:07 jsing Exp $ | 1 | # $OpenBSD: Makefile,v 1.14 2014/06/22 14:30:52 jsing Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR= \ | 3 | SUBDIR= \ |
| 4 | aead \ | 4 | aead \ |
| 5 | aeswrap \ | 5 | aeswrap \ |
| 6 | base64 \ | 6 | base64 \ |
| 7 | bf \ | 7 | bf \ |
| 8 | bio \ | ||
| 8 | bn \ | 9 | bn \ |
| 9 | cast \ | 10 | cast \ |
| 10 | chacha \ | 11 | chacha \ |
diff --git a/src/regress/lib/libcrypto/bio/Makefile b/src/regress/lib/libcrypto/bio/Makefile new file mode 100644 index 0000000000..9955cd4b8f --- /dev/null +++ b/src/regress/lib/libcrypto/bio/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2014/06/22 14:30:52 jsing Exp $ | ||
| 2 | |||
| 3 | PROG= biotest | ||
| 4 | LDADD= -lcrypto | ||
| 5 | DPADD= ${LIBCRYPTO} | ||
| 6 | WARNINGS= Yes | ||
| 7 | CFLAGS+= -Werror | ||
| 8 | |||
| 9 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/bio/biotest.c b/src/regress/lib/libcrypto/bio/biotest.c new file mode 100644 index 0000000000..3639cb1f36 --- /dev/null +++ b/src/regress/lib/libcrypto/bio/biotest.c | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /* $OpenBSD: biotest.c,v 1.1 2014/06/22 14:30:52 jsing Exp $ */ | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2014 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 <stdlib.h> | ||
| 19 | |||
| 20 | #include <openssl/bio.h> | ||
| 21 | #include <openssl/err.h> | ||
| 22 | |||
| 23 | struct bio_get_port_test { | ||
| 24 | char *input; | ||
| 25 | unsigned short port; | ||
| 26 | int ret; | ||
| 27 | }; | ||
| 28 | |||
| 29 | struct bio_get_port_test bio_get_port_tests[] = { | ||
| 30 | {NULL, 0, 0}, | ||
| 31 | {"", 0, 0}, | ||
| 32 | {"-1", 0, 0}, | ||
| 33 | {"0", 0, 1}, | ||
| 34 | {"1", 1, 1}, | ||
| 35 | {"12345", 12345, 1}, | ||
| 36 | {"65535", 65535, 1}, | ||
| 37 | {"65536", 0, 0}, | ||
| 38 | {"999999999999", 0, 0}, | ||
| 39 | {"xyzzy", 0, 0}, | ||
| 40 | {"https", 443, 1}, | ||
| 41 | {"imaps", 993, 1}, | ||
| 42 | {"telnet", 23, 1}, | ||
| 43 | }; | ||
| 44 | |||
| 45 | #define N_BIO_GET_PORT_TESTS \ | ||
| 46 | (sizeof(bio_get_port_tests) / sizeof(*bio_get_port_tests)) | ||
| 47 | |||
| 48 | static int | ||
| 49 | do_bio_get_port_tests(void) | ||
| 50 | { | ||
| 51 | struct bio_get_port_test *bgpt; | ||
| 52 | unsigned short port; | ||
| 53 | int failed = 0; | ||
| 54 | size_t i; | ||
| 55 | int ret; | ||
| 56 | |||
| 57 | for (i = 0; i < N_BIO_GET_PORT_TESTS; i++) { | ||
| 58 | bgpt = &bio_get_port_tests[i]; | ||
| 59 | port = 0; | ||
| 60 | |||
| 61 | ret = BIO_get_port(bgpt->input, &port); | ||
| 62 | if (ret != bgpt->ret) { | ||
| 63 | fprintf(stderr, "FAIL: test %zi (\"%s\") %s, want %s\n", | ||
| 64 | i, bgpt->input, ret ? "success" : "failure", | ||
| 65 | bgpt->ret ? "success" : "failure"); | ||
| 66 | failed = 1; | ||
| 67 | continue; | ||
| 68 | } | ||
| 69 | if (ret && port != bgpt->port) { | ||
| 70 | fprintf(stderr, "FAIL: test %zi (\"%s\") returned port " | ||
| 71 | "%u != %u\n", i, bgpt->input, port, bgpt->port); | ||
| 72 | failed = 1; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | return failed; | ||
| 77 | } | ||
| 78 | |||
| 79 | int | ||
| 80 | main(int argc, char **argv) | ||
| 81 | { | ||
| 82 | return do_bio_get_port_tests(); | ||
| 83 | } | ||
