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

Add max-msg run-time option #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RosscoG
Copy link

@RosscoG RosscoG commented Nov 30, 2024

Intro

Thank you @mity for a great tool that I use for every bit of C I work with.
I wanted to get into contributing to open source projects for practice and internet points. Working on something I have a passion for and am familiar with seemed like a good place to start.

I have implemented the cmd line option for changing message output limit at run-time.
Resolves #33

New features

Added run-time option to change the max output message length without having to recompile. Features:

  • cmd line option --max-msg=NUMBER
  • TEST_MSG_MAXSIZE is kept and used as default. It can still be defined before acutest include.
  • Added --help line for --max-msg usage
  • Changes match formatting, style and layout of existing code.

Tested with:
x64 Windows: gcc -Wall -Wextra -pedantic.

Recreate issue and Verify solution

A test rig was setup to recreate a character limited test message.
Length of test message was larger than TEST_MSG_MAXSIZE (1024), increased to (1024 + 200 - 24) = 1200 characters (for a nice round number).
On a failing test, as shown below, the # symbols represent long TEST_MSG output. As expected, the character count is 1024 - 1 (null terminated), defined by TEST_MSG_MAXSIZE. It does not show the final sentence, confirming the long message output is limited by the compile-time defined value.

Normal default length limited output:
image

Using the new run-time option --max-msg=1200, the full message can be seen without having to recompile. It includes the closing words right up to the final period, verifying intended behaviour.

Run-time option extended output:
image

Re-compiling with pre-defined TEST_MSG_MAXSIZE 1200 is confirmed to still operate as expected, needing no option to show full message.

Compile-time define extended output:
image

Bad input argument behaviour

There are several possible arg errors, nonsense input or genuine user misunderstanding. eg. user could misinterpret "--max-msg" is to set max possible etc. To handle these type of cases, the acutest_cmdline_options_ argument field was set to ACUTEST_CMDLINE_OPTFLAG_REQUIREDARG_. Other bad input is handled by setting exit value and usage hint output, matching other options.

Bad arg outputs:

  1. Missing arg
  2. Empty NUMBER arg
  3. Non-numeric NUMBER arg
  4. Negative NUMBER arg

image

--help options output includes --max-msg line:
image

Conclusion

This implementation meets requirements and is sufficiently verified for expected behaviour and error handling (IMO). I have not tested on other machines although I do not see these changes causing any problem. I will provide an update if anything arises from that testing.

Issue #34 is an equivalent feature for TEST_DUMP_MAXSIZE. I think it would be best to have that implemented for consistency. I'm happy to do that one next.

Resolves mity#33
- Defaults to TEST_MSG_MAXSIZE as normal.
- Adds new usage line in --help output
@RosscoG RosscoG changed the title Run-time max-msg command Add max-msg run-time option Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

For beginners: Change TEST_MSG_MAXSIZE into a run-time limit.
1 participant