diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-21 10:20:55 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-24 00:34:29 -0800 |
| commit | 3f7561417bec08226bcfeb107d94be0dbf71b09e (patch) | |
| tree | 409901d7929df5eeb7295ab971b34c2e1040f507 /tests/sha1.c | |
| parent | 9e7a4aff25139703bbc375b6dda263d6d42341a8 (diff) | |
| download | nng-3f7561417bec08226bcfeb107d94be0dbf71b09e.tar.gz nng-3f7561417bec08226bcfeb107d94be0dbf71b09e.tar.bz2 nng-3f7561417bec08226bcfeb107d94be0dbf71b09e.zip | |
fixes #1032 Figure out Darwin bustedness
fixes #1035 Convey is awkward -- consider acutest.h
This represents a rather large effort towards cleaning up our
testing and optional configuration infrastructure.
A separate test library is built by default, which is static, and
includes some useful utilities design to make it easier to write
shorter and more robust (not timing dependent) tests. This also means
that we can cover pretty nearly all the tests (protocols etc.) in
every case, even if the shipped image will be minimized.
Subsystems which are optional can now use a few new macros to configure
what they need see nng_sources_if, nng_headers_if, and nng_defines_if.
This goes a long way to making the distributed CMakefiles a lot simpler.
Additionally, tests for different parts of the tree can now be located
outside of the tests/ tree, so that they can be placed next to the code
that they are testing.
Beyond the enabling work, the work has only begun, but these changes
have resolved the most often failing tests for Darwin in the cloud.
Diffstat (limited to 'tests/sha1.c')
| -rw-r--r-- | tests/sha1.c | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/tests/sha1.c b/tests/sha1.c deleted file mode 100644 index 6877e89e..00000000 --- a/tests/sha1.c +++ /dev/null @@ -1,61 +0,0 @@ -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This software is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -#include <stdint.h> -#include <string.h> - -#include <nng/nng.h> - -#include "convey.h" -#include "supplemental/sha1/sha1.h" - -// The following test vectors are from RFC 3174. -#define TEST1 "abc" -#define TEST2a "abcdbcdecdefdefgefghfghighijhi" -#define TEST2b "jkijkljklmklmnlmnomnopnopq" -#define TEST2 TEST2a TEST2b -#define TEST3 "a" -#define TEST4a "01234567012345670123456701234567" -#define TEST4b "01234567012345670123456701234567" -/* an exact multiple of 512 bits */ -#define TEST4 TEST4a TEST4b - -char *testarray[4] = { TEST1, TEST2, TEST3, TEST4 }; -int repeatcount[4] = { 1, 1, 1000000, 10 }; -char *resultarray[4] = { - "A9 99 3E 36 47 06 81 6A BA 3E 25 71 78 50 C2 6C 9C D0 D8 9D", - "84 98 3E 44 1C 3B D2 6E BA AE 4A A1 F9 51 29 E5 E5 46 70 F1", - "34 AA 97 3C D4 C4 DA A4 F6 1E EB 2B DB AD 27 31 65 34 01 6F", - "DE A3 56 A2 CD DD 90 C7 A7 EC ED C5 EB B5 63 93 4F 46 04 52" -}; - -TestMain("SHA1 Verification", { - Convey("SHA1 Works", { - for (int i = 0; i < 4; i++) { - nni_sha1_ctx ctx; - size_t slen = strlen(testarray[i]); - uint8_t digest[20]; - char strout[20 * 3 + 1]; - memset(digest, 0, sizeof(digest)); - nni_sha1_init(&ctx); - for (int j = 0; j < repeatcount[i]; j++) { - nni_sha1_update( - &ctx, (uint8_t *) testarray[i], slen); - } - nni_sha1_final(&ctx, digest); - for (int j = 0; j < 20; j++) { - snprintf( - strout + j * 3, 4, "%02X ", digest[j]); - } - strout[20 * 3 - 1] = '\0'; - So(strcmp(strout, resultarray[i]) == 0); - } - }); -}) |
