xref: /aosp_15_r20/external/cronet/base/test/immediate_crash_test_helper.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/immediate_crash.h"  // nogncheck
6 
7 #if defined(WIN32)
8 #define IMMEDIATE_CRASH_TEST_HELPER_EXPORT __declspec(dllexport)
9 #else  // defined(WIN32)
10 #define IMMEDIATE_CRASH_TEST_HELPER_EXPORT \
11   __attribute__((visibility("default")))
12 #endif  // defined(WIN32)
13 
14 extern "C" {
15 
TestFunction1(int x,int y)16 IMMEDIATE_CRASH_TEST_HELPER_EXPORT int TestFunction1(int x, int y) {
17   if (x < 1)
18     base::ImmediateCrash();
19   if (y < 1)
20     base::ImmediateCrash();
21   return x + y;
22 }
23 
TestFunction2(int x,int y)24 IMMEDIATE_CRASH_TEST_HELPER_EXPORT int TestFunction2(int x, int y) {
25   if (x < 2)
26     base::ImmediateCrash();
27   if (y < 2)
28     base::ImmediateCrash();
29   return x * y;
30 }
31 
32 }  // extern "C"
33