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

[CN-Exec] Preprocessor directives for better testing support #784

Open
4 tasks
ZippeyKeys12 opened this issue Dec 23, 2024 · 1 comment
Open
4 tasks

[CN-Exec] Preprocessor directives for better testing support #784

ZippeyKeys12 opened this issue Dec 23, 2024 · 1 comment
Assignees
Labels
CN spec testing cn CN-exec Related to CN executable spec generation, called using `cn instrument` enhancement New feature or request

Comments

@ZippeyKeys12
Copy link
Collaborator

Right now there is a --with-test-gen flag, which throws an error if there is a main function.

Instead, there should be a more generally named --with-testing (or something more descriptive) flag which performs at least the following:

  • Allows the main function to be absent
  • If a main function is present, wraps it in #ifndef CN_TESTING_MODE
  • Based on CN_TESTING_MODE, for a given static global static <ty> <ident>;, has extern <ty> <ident>; in cn.h and <ty> <ident>; in cn.c instead.
  • For static functions, wrap these modifiers in #ifndef CN_TESTING_MODE

Since these changes would be behind a compiler flag, they could in theory be enabled by default rather than by a flag. However, this could add unnecessary noise to the instrumented files.

The end result is that compiling the instrumented file with CN_TESTING_MODE will allow various forms of testing to link against functions and globals where they otherwise could not.

CN-Test-Gen currently works around this by just acting as an addendum to the instrumented file, which is far from ideal.

Once implemented, CN-Test-Gen (and other testing efforts) can be updated to work with the new flag and --with-test-gen can eventually be removed.

@ZippeyKeys12 ZippeyKeys12 added enhancement New feature or request cn CN spec testing CN-exec Related to CN executable spec generation, called using `cn instrument` labels Dec 23, 2024
@dc-mak
Copy link
Contributor

dc-mak commented Dec 23, 2024

Can also use line directives to not mess up source location info too much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CN spec testing cn CN-exec Related to CN executable spec generation, called using `cn instrument` enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants