|
| 1 | +// Copyright 2024 The Cobalt Authors. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +// This is a kind of death test, as described in |
| 16 | +// https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests, |
| 17 | +// except, it doesn't spawn another process, but terminates itself. |
| 18 | +// It is intended to be started from a host machine on a target device |
| 19 | +// to generate a coredump, which is manually verified on the host. |
| 20 | + |
| 21 | +#include "starboard/client_porting/wrap_main/wrap_main.h" |
| 22 | +#include "starboard/event.h" |
| 23 | +#include "starboard/extension/crash_handler.h" |
| 24 | +#include "starboard/system.h" |
| 25 | +#include "testing/gtest/include/gtest/gtest.h" |
| 26 | + |
| 27 | +const char* test_string = "TestString"; |
| 28 | + |
| 29 | +TEST(ExtensionTest, MANUAL_SetString) { |
| 30 | + typedef CobaltExtensionCrashHandlerApi ExtensionApi; |
| 31 | + |
| 32 | + const ExtensionApi* extension_api = static_cast<const ExtensionApi*>( |
| 33 | + SbSystemGetExtension(kCobaltExtensionCrashHandlerName)); |
| 34 | + if (!extension_api) { |
| 35 | + return; |
| 36 | + } |
| 37 | + |
| 38 | + extension_api->SetString("Annotation1", test_string); |
| 39 | + extension_api->SetString("Annotation2", test_string); |
| 40 | + extension_api->SetString("Annotation3", test_string); |
| 41 | + extension_api->SetString("Annotation4", test_string); |
| 42 | + |
| 43 | + SbSystemBreakIntoDebugger(); |
| 44 | +} |
| 45 | + |
| 46 | +namespace { |
| 47 | +int InitAndRunAllTests(int argc, char** argv) { |
| 48 | + ::testing::InitGoogleTest(&argc, argv); |
| 49 | + return RUN_ALL_TESTS(); |
| 50 | +} |
| 51 | +} // namespace |
| 52 | + |
| 53 | +// When we are building Evergreen we need to export SbEventHandle so that the |
| 54 | +// ELF loader can find and invoke it. |
| 55 | +#if SB_IS(MODULAR) |
| 56 | +SB_EXPORT |
| 57 | +#endif // SB_IS(MODULAR) |
| 58 | +STARBOARD_WRAP_SIMPLE_MAIN(InitAndRunAllTests); |
0 commit comments