-
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
Open
danielinux
wants to merge
28
commits into
wolfSSL:master
Choose a base branch
from
danielinux:mcdc-test-coverage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Mcdc test coverage: part 5 #11039
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
38c354d
tests: add port group for wc_port.c MC/DC
danielinux 09d783a
tests: add compress group for compress.c MC/DC
danielinux 0e80968
tests: add pkcs12 container DecisionCoverage case
danielinux d95307b
tests: add she DecisionCoverage case
danielinux 286f3df
tests: expand ecc and rsa white-box coverage
danielinux 5bfbf32
tests: add asn and pkcs12 white-box tests
danielinux e8ef86c
tests: give the deterministic ocsp tests a group
danielinux 61d0a53
tests: add wc_port white-box for wolfSSL_strnstr
danielinux 0e66bb9
tests: add asn and pkcs7 white-boxes
danielinux 3887584
tests: repair two interrupted asn white-boxes
danielinux 7ebf5fa
tests: add asn DecodedCert and pkcs7 decode white-boxes
danielinux a9d0d90
tests: add tsp and pkcs12 parse white-boxes
danielinux d1f5753
tests: cover the ed25519 verify-helper key guards
danielinux 9a00307
tests: make the wc_lms_impl gap white-box run in every lms variant
danielinux a96f352
tests: drop an unused variable in the tsp white-box
danielinux fb6bfd6
tests: cover the sha3 vendor-gated AVX2 select and block-count guards
danielinux bc6146c
tests: cover the hpke copy-private-key cleanup guard
danielinux ec53550
tests: address review feedback on the Part 5 tests
danielinux 75f66a8
tests: add a puf white-box for the m33mu lane
danielinux 3888ca3
tests: assert the documented strlcpy/strlcat and PKCS7 stream contracts
danielinux 505a1a0
tests: drive the mlkem SIMD dispatch rows
danielinux 0479fe6
tests: drive the mldsa and sp_x86_64 SIMD dispatch rows
danielinux 5c4005c
tests: fix codespell hits in the MC/DC test files
danielinux 1b89c78
tests: wrap error-code operands and fix the test_compress include order
danielinux 750bd86
tests: drive the argument-guard rows in the MC/DC white-boxes
danielinux c6c5d67
tests: fix a codespell hit in the asn white-box
danielinux 937eb73
tests: correct the wc_PKCS7 reuse note in the tsp white-box
danielinux 31d5f7c
tests: wrap the error-code operands in the sp_cortexm white-box
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.