Skip to content
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

Activate the tests, fix broken funcs #10

Closed
rurban opened this issue Aug 24, 2017 · 3 comments
Closed

Activate the tests, fix broken funcs #10

rurban opened this issue Aug 24, 2017 · 3 comments
Assignees
Labels

Comments

@rurban
Copy link
Owner

rurban commented Aug 24, 2017

The tests actually do not return FAIL on any fails.
They only checked if crashing or not, but didn't promote any functional tests error, like wrong result or wrong error code.

In particular throw ESLEMAX when smax exceeds max, before the smax>dmax check (ESNOSPC).

Broken tests or functions:

  • sprintf_s (wrong tests)
  • snprintf_s (wrong tests)
  • memcpy_s (wrong ESNOSPC with smax)
  • memcpy16_s (wrong ESNOSPC with smax, wrong test)
  • memcpy32_s (wrong ESNOSPC with smax, wrong test)
  • t_memcmp_s (wrong ESNOSPC with smax)
  • t_memcmp16_s (wrong ESNOSPC with smax)
  • t_memcmp32_s (wrong ESNOSPC with smax)
  • t_memmove_s (wrong ESNOSPC with smax, wrong test)
  • t_memmove16_s (wrong ESNOSPC with smax, wrong test)
  • t_memmove32_s (wrong ESNOSPC with smax, wrong test)
  • t_memset_s (loose tests with C11)
  • t_strcpyfldout_s (wrong test)
  • t_strljustify_s (fix impl - original was ok, fix 2 test)
@rurban rurban added the bug label Aug 24, 2017
@rurban rurban changed the title Activate the tests Activate the tests, fix sprintf_s, snprintf_s Aug 24, 2017
rurban added a commit that referenced this issue Aug 24, 2017
The tests actually do not return FAIL on any fails.  They only checked if
crashing or not, but didn't promote any functional tests error, like wrong
result or wrong error code.
See #10
rurban added a commit that referenced this issue Aug 24, 2017
The tests actually do not return FAIL on any fails.  They only checked if
crashing or not, but didn't promote any functional tests error, like wrong
result or wrong error code.
See #10
rurban added a commit that referenced this issue Aug 24, 2017
The tests actually do not return FAIL on any fails.  They only checked if
crashing or not, but didn't promote any functional tests error, like wrong
result or wrong error code.
See #10
@rurban rurban changed the title Activate the tests, fix sprintf_s, snprintf_s Activate the tests, fix broken funcs Aug 24, 2017
@rurban rurban self-assigned this Aug 24, 2017
rurban added a commit that referenced this issue Aug 25, 2017
The tests actually do not return FAIL on any fails.  They only checked if
crashing or not, but didn't promote any functional tests error, like wrong
result or wrong error code.
See #10

Tests or impl. fixed in subsequent commits
rurban added a commit that referenced this issue Aug 25, 2017
The tests actually do not return FAIL on any fails.  They only checked if
crashing or not, but didn't promote any functional tests error, like wrong
result or wrong error code.
See #10

Tests or impl. fixed in subsequent commits
@Juno-Explorer
Copy link
Contributor

You can try unity framework, wherein you can have test assertions on failure.

For example:

If you intend to test strcpy_s and you know that return value is EOK on success then any scenario of buffer overflow should make this test fail. Using TEST_ASSERT_EQUAL which takes first parameter as expected and second as actual, you can get appropriate test assertions.

TEST( C11AnnexK, strcpy_s_ReturnsEOKWhenCopyIsSuccess)

{

int retVal; // To catch return Value

char src[] = "strcpy_s Test";

char dest [5]; // Purposely dest is choosen smaller than src to demonstrate assertion

retVal = strcpy_s (destLargerThanSrc, sizeof(destLargerThanSrc, src);

TEST_ASSERT_EQUAL( EOK, retVal); // This should fail as retVal would differ (retVal will be ESNOSPC in this scenario)

// This will result in assertion claiming that this test failed

}

@rurban
Copy link
Owner Author

rurban commented Aug 25, 2017

There are many such C test frameworks.
I'll rather use the current one. It's already fixed.

@rurban
Copy link
Owner Author

rurban commented Aug 25, 2017

Fixed with 2.1

@rurban rurban closed this as completed Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants