Skip to content

Allow passing config as a fixture #78

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

Merged

Conversation

khangng-ampere
Copy link
Contributor

This MR adds the capability to write tests for mctpd as an endpoint. This caught an uninitialized read bug on link data.

@khangng-ampere
Copy link
Contributor Author

Weird, I can run and pass all the test locally. Is there anyway I can view the logs? (Or I guess another PR for printing the log file on CI? 😄)

@jk-ozlabs
Copy link
Member

I'll see if I can reproduce here; if that's also passing, maybe a CI update would be handy...

@jk-ozlabs
Copy link
Member

Yeah, all passes here too - not sure what's up with the runner environment...

On non-bus-owner modes, link->slot_busowner will be uninitialized,
leading to segmentation fault when running sd_bus_slot_unref.

    ==3850684== Conditional jump or move depends on uninitialised value(s)
    ==3850684==    at 0x48FB448: sd_bus_slot_unref (in /usr/lib/aarch64-linux-gnu/libsystemd.so.0.38.0)
    ==3850684==    by 0x1123E3: free_link (mctpd.c:3263)
    ==3850684==    by 0x1125CB: free_links (mctpd.c:3308)
    ==3850684==    by 0x113D63: main (mctpd.c:3900)

Simply zero initialize the link data.

Signed-off-by: Khang D Nguyen <[email protected]>
@khangng-ampere
Copy link
Contributor Author

Seems like ASAN caught some more bugs, I can reproduce with meson setup build -Db_sanitize=address just like how CI does. Let me see what it is and push a fix.

@jk-ozlabs
Copy link
Member

OK, I had a run here with -Db_sanitize=address work fine (maybe my ASAN isn't picky enough!). Let me know what you find/fix there.

ASAN complained about this config file path memory leak. Free it on
program exit.

Also, there is a clangd warning on implicitly freeing const char*.
Instead of casting to void* explicitly, I changed it to be char* to
reflect the fact that we own the string allocation better.

Signed-off-by: Khang D Nguyen <[email protected]>
mctpd now requests a config fixture, which is None by default to ensure
previous behaviour.

Test authors can now override the config using pytest fixtures
overriding facility. An example on overriding per file basis is
included in the commit.

Signed-off-by: Khang D Nguyen <[email protected]>
@khangng-ampere khangng-ampere force-pushed the khangng/push-wnzlykommpko branch from 6471906 to b2463e1 Compare June 3, 2025 05:26
@khangng-ampere
Copy link
Contributor Author

CI passed now. There was a memory leak when we copied the config file path from CLI args.

@jk-ozlabs jk-ozlabs merged commit b2463e1 into CodeConstruct:main Jun 3, 2025
1 check passed
@khangng-ampere khangng-ampere deleted the khangng/push-wnzlykommpko branch June 3, 2025 07:18
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.

3 participants