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

Consider splitting tests into one file per API #3

Closed
PatrickvL opened this issue Jan 3, 2018 · 3 comments · Fixed by #78
Closed

Consider splitting tests into one file per API #3

PatrickvL opened this issue Jan 3, 2018 · 3 comments · Fixed by #78

Comments

@PatrickvL
Copy link
Member

Currently, tests are grouped together according to kernel prefix (Ob, Ex, Mm, etc).

It's probably better to create a separate test file per API, because otherwise there's a real chance some test files will become too big. Also, having separate test file per API results in a cleaner revision history.

This comes at a cost though:

  • The current setup has to be split up
  • Any change in testing method later on in the lifetime of this project, will require updating 379 files

This last point makes it even more important to get the testing framework "first-time-right" (see issue #2).

@PatrickvL PatrickvL changed the title Consider splitting tests into one for per API Consider splitting tests into one file per API Jan 3, 2018
@PatrickvL
Copy link
Member Author

PatrickvL commented Jan 3, 2018

PS: this suggestion is inspired by https://github.com/mborgerson/OpenXBOX/tree/master/src/kernel

@JayFoxRox
Copy link

The issue with the current grouping per prefix is that it doesn't make much sense anyway: the functions interact, and the prefixes are mostly irrelevant.

I don't think that changing all 379 files will be a typical issue. The test start and end could be hidden in macros (although this strongly interacts with #2 ).

So I agree with the proposal: a single file per function does sound okay, if we continue to use nxdk and C, without another unit-testing framework (which might not require code at all).

@RadWolfie
Copy link
Member

RadWolfie commented Mar 9, 2023

In my opinion, prefixes are important as it can help group APIs better. I propose to use prefix per folder then inside each folder don't include prefix of each API file, or do include, either way will be fine for me. That way, we will have cleaner directory to navigate. Some of APIs aren't really worth writing test since other APIs could already included the tests.

Also, I rather have all of source code files inside src folder than everything at top directory which isn't cleaner view. Re-haul file system in my opinion should look like:

  • src
    • main.c
    • template (mainly to reuse APIs)
      • DeferredProcedureCall.c
      • DeferredProcedureCall.h
      • InterruptServiceRoutine.c
      • InterruptServiceRoutine.h
    • assertions
      • common.c
      • common.h
      • defines.h (might will be migrate into common.h file)
      • ex.c
      • ex.h
      • ke.c
      • ke.h
    • include
      • func_table.h (contain each prefix tests header and array of API functions linkage variable)
      • tests_<prefix>.h
    • tests
      • suite (for organize a group of mixed functions together, this is optional)
        • timer.c (or whatever is mixed APIs functionality do)
      • Av
        • AvGetSavedDataAddress.c
        • AvSendTVEncoderOption.c
        • ...
      • Dbg
        • DbgBreakPoint
        • DbgBreakPointWithStatus
        • ...
      • Ke
        • suite (for organize a group of relative functions together)
          • interrupt.c
          • dpc.c
        • KeAlertResumeThread.c
        • ...
    • utils
      • output.c
      • output.h
      • string_extra.c
      • string_extra.h
      • vector.c
      • vector.h

TODO: There's different type of assertions files, where should they go into?

and so on.

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 a pull request may close this issue.

3 participants