-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[os_log][stdlib-private] Add tests for checking the correctness of buffer and format string construction in the new OS log APIs. #23437
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
Conversation
@swift-ci Please test |
Build failed |
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please clean test |
@swift-ci Please test linux platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
h.log("\'Imagination is more important than knowledge\' - Einstein") | ||
h.log("Imagination is more important than knowledge \n - Einstein") | ||
h.log("Imagination is more important than knowledge - \\Einstein") | ||
h.log("The log message will be truncated here.\0 You wont see this") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h.log("The log message will be truncated here.\0 You wont see this") | |
h.log("The log message will be truncated here.\0 You won't see this") |
withUnsafeBytes(of: expectedData) { expectedBytes in | ||
for i in 0..<Int(size) { | ||
// Argument data starts after the two header bytes. | ||
expectEqual(expectedBytes[i], buffer[startIndex + 2 + i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably to make a failure more useful, add a message to the expectEqual
call, containing the index at which the mismatch happened.
) { | ||
checkArgument( | ||
startIndex: startIndex, | ||
size: UInt8(Int.bitWidth / bitsPerByte), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size: UInt8(Int.bitWidth / bitsPerByte), | |
size: MemryLayout<UInt8>.size, |
// A stress test that checks whether the log APIs handle messages with more | ||
// than 48 interpolated expressions. Interpolated expressions beyond this | ||
// limit must be ignored. | ||
OSLogTestSuite.test("messages with too many arguments") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests that don't call any expectXXXX
fucntions, they can't really fail, can they? Is it possible to somehow validate the output produced by calling os_log? Maybe it can be done in a separate file that does not use StdlibUnitttest, and instead simply validates the stdout output... Just a thought. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's is right. We need to have some way of checking the logged messages. I will see how this could be done. As you say, we can't use StdlibUnittest. The logs don't get printed to stdout by default and may require registering a stream handler. I will create a new PR for that.
buffer and format string construction in the new OS log APIs.
1cb5d23
to
2f2afd0
Compare
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An enthusiastic looks good to me! It is great to see these tests!!
@swift-ci Please test and merge |
@swift-ci Please test and merge |
1 similar comment
@swift-ci Please test and merge |
@swift-ci Please test Linux Platform |
Build failed |
@swift-ci Please test Linux platform |
No description provided.