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

Add a crashy program for SetString test. #4443

Open
wants to merge 1 commit into
base: 25.lts.1+
Choose a base branch
from

Conversation

v-kryachko
Copy link
Collaborator

b/358663298

Change-Id: If8931dac92837bc7295006e7c3e57fe8f91dc627

Copy link
Member

@kaidokert kaidokert left a comment

Choose a reason for hiding this comment

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

lgtm - lets just describe the intent clearly in a comment above the test, too.


TEST(ExtensionTest, SetString) {
typedef CobaltExtensionCrashHandlerApi ExtensionApi;
const char* kExtensionName = kCobaltExtensionCrashHandlerName;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this variable needed? It seems more clear to just pass kCobaltExtensionCrashHandlerName directly to SbSystemGetExtension().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

#include "starboard/system.h"
#include "testing/gtest/include/gtest/gtest.h"

const char* long_string =
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it important that this string is so long? If so, I'd recommend adding a comment explaining why this length is an important thing to test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This time it is not critical. Initial idea was to test the maximum amount of data, transferred in annotations, but implementation should be different. Fixed.

// https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests,
// except, it doesn't spawn another process, but terminates itself.
// It is intended to be started from a host machine on a target device
// to generate a coredump, which is verified on the host.
Copy link
Contributor

Choose a reason for hiding this comment

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

This test doesn't actually do any verifications about the expected annotations in the core dump. Will those be added later? Or is the expectation that the core dump, and its annotations, will be verified manually after this test is run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Such happened, target part of the test is cross-platform. But verification code, apparently, can be platform-specific only. I've implemented it for PlayStation, but I see no way to implement similar for UWP/Windows. This is current status.

Copy link
Member

Choose a reason for hiding this comment

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

I support getting the code in, if it helps bringing up integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could enable platforms to add platform-specific verification code, if we wanted to (and there's a viable way to automatically do the verification locally on the platform, for example by examining an expected crash dump stored on the file system).

One way to do that would be by adding a new method to the CrashHandler Starboard extension itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have had a doubt about possible way to make verification locally on the platform. This way is preferable, as doesn't involve host side. I can consider this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hlwarriner I see no a viable way to automatically do the verification locally on the platform.

@niranjanyardi niranjanyardi removed their request for review December 10, 2024 02:05
b/358663298

Change-Id: If8931dac92837bc7295006e7c3e57fe8f91dc627
@@ -29,3 +29,13 @@ target(gtest_target_type, "extension_test") {
deps += cobalt_platform_dependencies
}
}

target(gtest_target_type, "setstring_test") {
Copy link
Contributor

Choose a reason for hiding this comment

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

A downside of adding this setstring_test is that it would need to be built and run manually by developers, and won't run automatically in any CI. A cursory look shows that InitAndRunAllTests() is unnecessary since it doesn't do anything special. Why not just add setstring_test.cc to a larger test-only build target, e.g. "extension_test" in l.15 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

We could alternatively just add this test target to cobalt/build/cobalt_configuration.py so that it's run in CI.

I think there's limited utility in running it automatically, though, as long as it requires manual steps in order to verify the result (see other comment thread).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yell0wd0g I can suggest rename the executable to 'crashy_process' or alike and remove use of gtest library to avoid confusion with tests, because it is not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I didn't notice the need for manual test.

An interesting pattern to consider then would be the "MANUAL_FooTest" used by Chromium (some doc here, one example here). Test cases go into a larger binary (easier to deploy and conceptualize) but don't run by default unless the test binary is run with the "--run-manual" command line flag.

Perhaps it'd be overkill for this case since it's going to 25.lts, but certainly something to consider for 26+.

Otherwise I'm good with other reviewers' LGTMs. Thanks!

@v-kryachko v-kryachko requested a review from amurovanyi January 7, 2025 09:55
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.

5 participants