-
Notifications
You must be signed in to change notification settings - Fork 1k
Mcdc test coverage: part 5 #11039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Mcdc test coverage: part 5 #11039
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
28f4440
tests: add port group for wc_port.c MC/DC
danielinux 9ddb7ff
tests: add compress group for compress.c MC/DC
danielinux 65ffd32
tests: add pkcs12 container DecisionCoverage case
danielinux a123863
tests: add she DecisionCoverage case
danielinux a914dd2
tests: expand ecc and rsa white-box coverage
danielinux 2c8fcab
tests: add asn and pkcs12 white-box tests
danielinux ef430a9
tests: give the deterministic ocsp tests a group
danielinux b4942e9
tests: add wc_port white-box for wolfSSL_strnstr
danielinux 3fa2307
tests: add asn and pkcs7 white-boxes
danielinux 3010192
tests: repair two interrupted asn white-boxes
danielinux fe71d61
tests: add asn DecodedCert and pkcs7 decode white-boxes
danielinux ee158ca
tests: add tsp and pkcs12 parse white-boxes
danielinux 5ad0a0c
tests: cover the ed25519 verify-helper key guards
danielinux dd3ded6
tests: make the wc_lms_impl gap white-box run in every lms variant
danielinux f07b0c4
tests: drop an unused variable in the tsp white-box
danielinux 877b94b
tests: cover the sha3 vendor-gated AVX2 select and block-count guards
danielinux 13016c3
tests: cover the hpke copy-private-key cleanup guard
danielinux b5c6753
tests: address review feedback on the Part 5 tests
danielinux dd2ab49
tests: add a puf white-box for the m33mu lane
danielinux a7e5504
tests: assert the documented strlcpy/strlcat and PKCS7 stream contracts
danielinux b66da93
tests: drive the mlkem SIMD dispatch rows
danielinux 318835b
tests: drive the mldsa and sp_x86_64 SIMD dispatch rows
danielinux 44de269
tests: fix codespell hits in the MC/DC test files
danielinux e79f833
tests: wrap error-code operands and fix the test_compress include order
danielinux a28499c
tests: drive the argument-guard rows in the MC/DC white-boxes
danielinux f4a27a3
tests: fix a codespell hit in the asn white-box
danielinux 06a8f53
tests: correct the wc_PKCS7 reuse note in the tsp white-box
danielinux 1f58871
tests: wrap the error-code operands in the sp_cortexm white-box
danielinux a9212ac
tests: complete the mldsa SIMD dispatch ladder
danielinux 1344162
tests: cover the conditions master added under the campaign
danielinux 6897290
tests: repair the white-boxes that stopped building
danielinux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* test_compress.c | ||
| * | ||
| * Copyright (C) 2006-2026 wolfSSL Inc. | ||
| * | ||
| * This file is part of wolfSSL. | ||
| * | ||
| * wolfSSL is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * wolfSSL is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
|
|
||
| #include <tests/unit.h> | ||
|
|
||
| /* After <tests/unit.h>: that header establishes wolfSSL's feature-test | ||
| * macros, and a libc header pulled in ahead of it fixes glibc's exposure | ||
| * before they are seen -- under -std=c89 that leaves POSIX types the rest of | ||
| * the suite needs undeclared. Every other file in tests/api/ starts with | ||
| * <tests/unit.h> for the same reason. INT_MAX is used below. */ | ||
| #include <limits.h> | ||
|
|
||
| #ifdef HAVE_LIBZ | ||
| #include <wolfssl/wolfcrypt/compress.h> | ||
| #endif | ||
| #include <wolfssl/wolfcrypt/error-crypt.h> | ||
| #include <tests/api/api.h> | ||
| #include <tests/api/test_compress.h> | ||
|
|
||
| /* | ||
| * MC/DC decision coverage for the zlib wrapper (wolfcrypt/src/compress.c). | ||
| * compress_test() in testwolfcrypt exercises the round trips; this drives the | ||
| * argument guards, each operand flipped independently: | ||
| * - "out == NULL || in == NULL" in wc_Compress_ex, wc_DeCompress_ex and | ||
| * wc_DeCompressDynamic; | ||
| * - "inSz == 0 || inSz > INT_MAX/2" in wc_DeCompressDynamic, the cap that | ||
| * keeps the buffer doubling from overflowing. | ||
| */ | ||
| int test_wc_CompressDecisionCoverage(void) | ||
| { | ||
| EXPECT_DECLS; | ||
| #ifdef HAVE_LIBZ | ||
| static const byte sample[] = | ||
| "wolfSSL compress decision coverage sample text, repeated enough to " | ||
| "actually compress: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | ||
| byte packed[512]; | ||
| byte plain[512]; | ||
| byte* dynOut = NULL; | ||
| int packedSz; | ||
|
|
||
| XMEMSET(packed, 0, sizeof(packed)); | ||
| XMEMSET(plain, 0, sizeof(plain)); | ||
|
|
||
| /* wc_Compress_ex "out == NULL || in == NULL" */ | ||
| ExpectIntEQ(wc_Compress_ex(NULL, sizeof(packed), sample, sizeof(sample), | ||
| 0, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
| ExpectIntEQ(wc_Compress_ex(packed, sizeof(packed), NULL, sizeof(sample), | ||
| 0, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
|
|
||
| /* both operands false: a real compression, whose output feeds the | ||
| * decompression guards below. */ | ||
| ExpectIntGT(packedSz = wc_Compress(packed, sizeof(packed), sample, | ||
| sizeof(sample), 0), 0); | ||
|
|
||
| /* wc_DeCompress_ex "out == NULL || in == NULL" */ | ||
| ExpectIntEQ(wc_DeCompress_ex(NULL, sizeof(plain), packed, sizeof(packed), | ||
| 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
| ExpectIntEQ(wc_DeCompress_ex(plain, sizeof(plain), NULL, sizeof(packed), | ||
| 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
|
|
||
| if (EXPECT_SUCCESS() && packedSz > 0) { | ||
| ExpectIntEQ(wc_DeCompress(plain, sizeof(plain), packed, | ||
| (word32)packedSz), (int)sizeof(sample)); | ||
| ExpectIntEQ(XMEMCMP(plain, sample, sizeof(sample)), 0); | ||
| } | ||
|
|
||
| /* wc_DeCompressDynamic "out == NULL || in == NULL" */ | ||
| ExpectIntEQ(wc_DeCompressDynamic(NULL, 1, DYNAMIC_TYPE_TMP_BUFFER, packed, | ||
| (word32)packedSz, 0, NULL), | ||
| WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
| ExpectIntEQ(wc_DeCompressDynamic(&dynOut, 1, DYNAMIC_TYPE_TMP_BUFFER, NULL, | ||
| (word32)packedSz, 0, NULL), | ||
| WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
|
|
||
| /* wc_DeCompressDynamic "inSz == 0 || inSz > INT_MAX/2", one operand true | ||
| * per call, then both false on the working round trip. */ | ||
| ExpectIntEQ(wc_DeCompressDynamic(&dynOut, 1, DYNAMIC_TYPE_TMP_BUFFER, | ||
| packed, 0, 0, NULL), | ||
| WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
| ExpectIntEQ(wc_DeCompressDynamic(&dynOut, 1, DYNAMIC_TYPE_TMP_BUFFER, | ||
| packed, (word32)(INT_MAX / 2) + 1, 0, NULL), | ||
| WC_NO_ERR_TRACE(BAD_FUNC_ARG)); | ||
|
danielinux marked this conversation as resolved.
|
||
|
|
||
| if (EXPECT_SUCCESS() && packedSz > 0) { | ||
| ExpectIntEQ(wc_DeCompressDynamic(&dynOut, 4, DYNAMIC_TYPE_TMP_BUFFER, | ||
| packed, (word32)packedSz, 0, NULL), | ||
| (int)sizeof(sample)); | ||
| ExpectNotNull(dynOut); | ||
| if (dynOut != NULL) { | ||
| ExpectIntEQ(XMEMCMP(dynOut, sample, sizeof(sample)), 0); | ||
| XFREE(dynOut, NULL, DYNAMIC_TYPE_TMP_BUFFER); | ||
| dynOut = NULL; | ||
| } | ||
| } | ||
| #endif /* HAVE_LIBZ */ | ||
| return EXPECT_RESULT(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* test_compress.h | ||
| * | ||
| * Copyright (C) 2006-2026 wolfSSL Inc. | ||
| * | ||
| * This file is part of wolfSSL. | ||
| * | ||
| * wolfSSL is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * wolfSSL is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
|
|
||
| #ifndef WOLFCRYPT_TEST_COMPRESS_H | ||
| #define WOLFCRYPT_TEST_COMPRESS_H | ||
|
|
||
| #include <tests/api/api_decl.h> | ||
|
|
||
| int test_wc_CompressDecisionCoverage(void); | ||
|
|
||
| #define TEST_COMPRESS_DECLS \ | ||
| TEST_DECL_GROUP("compress", test_wc_CompressDecisionCoverage) | ||
|
|
||
| #endif /* WOLFCRYPT_TEST_COMPRESS_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.