Skip to content

[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

Merged
merged 1 commit into from
Apr 5, 2019

Conversation

ravikandhadai
Copy link
Contributor

No description provided.

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 1cb5d23035092ce27faadac1cfa95163f1ba36eb

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 1cb5d23035092ce27faadac1cfa95163f1ba36eb

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 1cb5d23035092ce27faadac1cfa95163f1ba36eb

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please clean test

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test linux platform

Copy link
Contributor

@moiseev moiseev left a 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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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])
Copy link
Contributor

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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") {
Copy link
Contributor

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?

Copy link
Contributor Author

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.
@ravikandhadai
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@devincoughlin devincoughlin left a 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!!

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test and merge

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test and merge

1 similar comment
@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test and merge

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test Linux Platform

@swift-ci
Copy link
Contributor

swift-ci commented Apr 5, 2019

Build failed
Swift Test Linux Platform
Git Sha - 1cb5d23035092ce27faadac1cfa95163f1ba36eb

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test Linux platform

@ravikandhadai ravikandhadai merged commit 6317b17 into swiftlang:master Apr 5, 2019
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.

4 participants