Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
runtime
bin
process_test.cc
Go to the documentation of this file.
1
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4
5
#include <
stdio.h
>
6
#include <stdlib.h>
7
#include <string.h>
8
9
// Force .lib-file creation on Windows, make ninja happy with zero-build.
10
#if defined(_WIN32)
11
extern
"C"
__declspec(dllexport)
void
dummy() {}
12
#endif
13
14
#if defined(__has_feature)
15
#if __has_feature(undefined_behavior_sanitizer)
16
__attribute__
((no_sanitize(
"undefined"
)))
17
#endif
18
#endif
19
void
Crash
() {
20
int
* segfault =
nullptr
;
21
*segfault = 1;
22
}
23
24
/*
25
* Run ./process_test <outstream> <echocount> <exitcode> <crash>
26
* <outstream>: 0 = stdout, 1 = stderr, 2 = stdout and stderr
27
* <echocount>: program terminates after <echocount> replies
28
* <exitcode>: program terminates with exit code <exitcode>
29
* <crash>: 0 = program terminates regularly, 1 = program segfaults
30
*/
31
int
main
(
int
argc,
char
* argv[]) {
32
if
(argc != 5) {
33
fprintf(stderr,
34
"./process_test <outstream> <echocount> <exitcode> <crash>\n"
);
35
exit(1);
36
}
37
38
int
outstream = atoi(
argv
[1]);
39
if
(outstream < 0 || outstream > 2) {
40
fprintf(stderr,
"unknown outstream"
);
41
exit(1);
42
}
43
44
int
echo_counter = 0;
45
int
echo_count = atoi(
argv
[2]);
46
int
exit_code = atoi(
argv
[3]);
47
int
crash = atoi(
argv
[4]);
48
49
if
(crash == 1) {
50
Crash
();
51
}
52
53
const
int
kLineSize = 128;
54
char
line[kLineSize];
55
56
while
((echo_count != echo_counter) &&
57
(fgets(line, kLineSize, stdin) !=
nullptr
)) {
58
if
(outstream == 0) {
59
fprintf(stdout,
"%s"
, line);
60
fflush(stdout);
61
}
else
if
(outstream == 1) {
62
fprintf(stderr,
"%s"
, line);
63
fflush(stderr);
64
}
else
if
(outstream == 2) {
65
fprintf(stdout,
"%s"
, line);
66
fprintf(stderr,
"%s"
, line);
67
fflush(stdout);
68
fflush(stderr);
69
}
70
echo_counter++;
71
}
72
73
return
exit_code;
74
}
__attribute__
__attribute__((visibility("default"))) int RunBenchmarks(int argc
argv
char ** argv
Definition
library.h:9
main
Definition
main.py:1
Crash
void Crash()
Definition
process_test.cc:19
stdio.h
Generated on Fri Apr 26 2024 06:14:43 for Flutter Engine by
1.9.8